
특정 순서로 두 경로 사이의 교차점을 얻고 싶습니다.
이러한 경로를 2D 그림으로 그리면 모든 것이 정상입니다.
그러나 어떤 이유로 라이브러리를 사용하여 동일한 그림을 플롯하면 3d
키에도 불구하고 교차점 순서가 변경됩니다 sort by
.
3D 케이스에서 올바른 순서를 얻는 방법을 아는 사람이 있나요?
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 그림:
3D 그림:
답변1
IMHO 이것은 3D와 아무 관련이 없지만 구문으로 그려진 직선을 따라 정렬하면 --
결과가 약간 복권이라는 사실과 관련이 있습니다. 이에 대해서는 아래에서 자세히 논의했습니다.이 질문, 그리고 이 문제를 해결하기 위해 곡선인 척하는 직선을 그릴 수 있습니다.
\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}