
Ich möchte Schnittpunkte zwischen zwei Pfaden in einer bestimmten Reihenfolge erhalten.
Wenn diese Pfade als 2D-Bild gezeichnet werden, ist alles in Ordnung.
3d
Aber aus irgendeinem Grund ändert sich die Reihenfolge der Schnittpunkte trotz des sort by
Schlüssels , wenn ich dieselbe Figur mithilfe der Bibliothek plotte .
Weiß jemand, wie man im 3D-Fall die richtige Reihenfolge erhält?
MWE:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d, intersections}
\begin{document}
% 2D picture : order of intersections is OK
\begin{tikzpicture}
\draw[red, name path = structure] (3,-1)coordinate(A) -- (3,1) -- (1,1)coordinate(B) -- (0,0) -- (2,0) -- (3,1);
\draw[blue,->, name path = line] (A) -- (B);
\draw [name intersections={of=structure and line, name=i, sort by=line}] (i-1) node{+}node[below]{1} (i-2) node{+}node[below]{2} (i-3) node{+}node[below]{3};
\end{tikzpicture}
% 3D picture : order of intersections is weird
\begin{tikzpicture}[x = {(1cm,0cm)}, y = {(0.5cm,0.5cm)}, z = {(0cm,1cm)}]
\draw[red, name path = structure] (2,2,0)coordinate(A) -- ++(0,0,2) --++(-2,0,0)coordinate(B) --++(0,-2,0) --++(2,0,0) --++(0,2,0);
\draw[blue,->, name path = line] (A) -- (B);
\draw [name intersections={of=structure and line, name=i, sort by=line}] (i-1) node{+}node[below]{1} (i-2) node{+}node[below]{2} (i-3) node{+}node[below]{3};
\end{tikzpicture}
\end{document}
2D Bild:
3D Bild:
Antwort1
Meiner Meinung nach hat das nichts mit 3D zu tun, sondern mit der Tatsache, dass das Sortieren entlang gerader Linien, die mit der Syntax gezeichnet werden, --
ein bisschen wie ein Lotterieergebnis ist. Dies wurde ausführlich unterdiese Frage, und um es zu lösen, können Sie eine gerade Linie zeichnen, die vorgibt, eine Kurve zu sein.
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d, intersections}
\begin{document}
% 2D picture : order of intersections is OK
\begin{tikzpicture}
\draw[red, name path = structure] (3,-1)coordinate(A) -- (3,1) -- (1,1)coordinate(B) -- (0,0) -- (2,0) -- (3,1);
\draw[blue,->, name path = line] (A) -- (B);
\draw [name intersections={of=structure and line, name=i, sort by=line}] (i-1) node{+}node[below]{1} (i-2) node{+}node[below]{2} (i-3) node{+}node[below]{3};
\end{tikzpicture}
% 3D picture : order of intersections is weird
\begin{tikzpicture}[x = {(1cm,0cm)}, y = {(0.5cm,0.5cm)}, z = {(0cm,1cm)}]
\draw[red, name path = structure] (2,2,0)coordinate(A) -- ++(0,0,2) --++(-2,0,0)coordinate(B) --++(0,-2,0) --++(2,0,0) --++(0,2,0);
\draw[blue,->, name path = line] (A) to[bend left=0] (B);
\draw [name intersections={of=structure and line, name=i, sort by=line}] (i-1) node{+}node[below]{1} (i-2) node{+}node[below]{2} (i-3) node{+}node[below]{3};
\end{tikzpicture}
\end{document}