使用 3d tikz 庫的交叉點順序問題

使用 3d tikz 庫的交叉點順序問題

我想以特定的順序取得兩條路徑之間的交集。

當這些路徑被繪製為二維圖片時,一切都很好。

但由於某種原因,當我使用庫繪製相同的圖形時,3d儘管有鍵,但交集的順序會改變sort by

有人知道如何在 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) -- (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 圖片:

2D圖片

3D圖片:

3D圖片

答案1

恕我直言,這與 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}

在此輸入影像描述

相關內容