
我嘗試製作兩端都有頭的半圓形箭頭。它們都應該以 O 為中心。 它們應該標記繪製的立方體的旋轉方向。例如,一個半圓形箭頭將從 S1 開始,接觸 S2,並在 S3 結束。所以總共應該有 6 個箭頭。
我現在嘗試了兩個小時,但沒有獲得“arc”的功能。我得到的只是
有人可以提供我如何到達我想去的地方的提示或解決方案嗎?
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{adjustbox}
\usetikzlibrary{calc}
\begin{document}
\trimbox{6.8cm 0cm 0cm 0cm}{
\tdplotsetmaincoords{0}{0}
\tdplotsetrotatedcoords{60}{70}{35}%
\begin{tikzpicture}
[tdplot_rotated_coords,
cube/.style={black},
arr/.style={-latex,color=green!70,thick,line cap=round,shorten <= 1.5pt}]
\coordinate (A1) at (0,0,0);
\coordinate (A2) at (0,1,0);
\coordinate (A3) at (1,1,0);
\coordinate (A4) at (1,0,0);
\coordinate (B1) at (0,0,1);
\coordinate (B2) at (0,1,1);
\coordinate (B3) at (1,1,1);
\coordinate (B4) at (1,0,1);
\coordinate (O) at ($(A1)!0.5!(B3)$);
\coordinate (S1) at ($(A1)!0.5!(B2)$);
\coordinate (S2) at ($(B2)!0.5!(A3)$);
\coordinate (S3) at ($(A3)!0.5!(B4)$);
\coordinate (S4) at ($(B4)!0.5!(A1)$);
\coordinate (S5) at ($(B1)!0.5!(B3)$);
\coordinate (S6) at ($(A1)!0.5!(A3)$);
\draw[cube] (B1) -- (B2) -- (B3) -- (B4) -- cycle;
\draw[cube] (A2) -- (B2);
\draw[cube] (A3) -- (B3);
\begin{scope}[canvas is zy plane at x=0]
\draw[arr] (0:0.5) arc (90:0:-0.5) ;
\draw[arr] (0:0.5) arc (-180:0:-0.5) ;
\end{scope}
\begin{scope}[canvas is zx plane at y=0]
\draw[arr] (0:0.5) arc (180:0:-0.5) ;
\draw[arr] (0:0.5) arc (-180:0:-0.5) ;
\end{scope}
\begin{scope}[canvas is yx plane at z=0]
\draw[arr] (0:0.5) arc (180:0:-0.5) ;
\draw[arr] (0:0.5) arc (-180:0:-0.5) ;
\end{scope}
\draw[cube] (A1) -- (A2) -- (A3) -- (A4) -- cycle;
\draw[cube] (A1) -- (B1);
\draw[cube] (A4) -- (B4);
\end{tikzpicture}}
\end{document}
答案1
(O) +
如果您採納 John Kormylo 的建議並使用... 作為起始座標並將第一個圓弧固定為從 180 度而不是 90 度開始,您的原始程式碼實際上非常接近您的要求。
不幸的是,生成的圖表非常混亂,並且(在我看來)很難在 3D 中正確解釋弧線。可能有幫助的一件事是使用雙線來強化這樣的想法:您的某些線位於其他線的“前面”。我還添加了bending
庫,這使得箭頭看起來不那麼尷尬,並將箭頭沿著各自的圓圈放置,這樣它們就不會全部指向同一個地方。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{adjustbox}
\usetikzlibrary{calc, arrows.meta}
\usetikzlibrary{bending}
\begin{document}
\trimbox{6.8cm 0cm 0cm 0cm}{
\tdplotsetmaincoords{0}{0}
\tdplotsetrotatedcoords{60}{70}{35}%
\begin{tikzpicture}[
tdplot_rotated_coords,
cube/.style={white, double=black, double distance=.1mm, join=bevel},
arr/.style={-{latex[color=green!70]},
white, double=green!70, shorten <= 1pt, shorten >=1pt
}
]
\coordinate (A1) at (0,0,0);
\coordinate (A2) at (0,1,0);
\coordinate (A3) at (1,1,0);
\coordinate (A4) at (1,0,0);
\coordinate (B1) at (0,0,1);
\coordinate (B2) at (0,1,1);
\coordinate (B3) at (1,1,1);
\coordinate (B4) at (1,0,1);
\coordinate (O) at ($(A1)!0.5!(B3)$);
\draw[cube] (B1) -- (B2) -- (B3) -- (B4) -- cycle
(A2) -- (B2)
(A3) -- (B3);
% These must be drawn back to front
\draw[arr, canvas is zx plane at y=0] (O) +(0:0.5) arc (0:-180:0.5);
\draw[arr, canvas is yz plane at x=0] (O) +(0:0.5) arc (0:180:0.5);
\draw[arr, canvas is xy plane at z=0] (O) +(180:0.5) arc (180:0:0.5);
\draw[arr, canvas is xy plane at z=0] (O) +(180:0.5) arc (-180:0:0.5);
\draw[arr, canvas is yz plane at x=0] (O) +(0:0.5) arc (0:-180:0.5);
\draw[arr, canvas is zx plane at y=0] (O) +(0:0.5) arc (0:180:0.5);
\draw[cube] (A1) -- (A2) -- (A3) -- (A4) -- cycle
(A1) -- (B1)
(A4) -- (B4);
\end{tikzpicture}
}
\end{document}
答案2
我重新定義arr
為兩個箭頭,並在 處添加了一個點(O)
。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{adjustbox}
\usetikzlibrary{calc}
\begin{document}
\trimbox{6.8cm 0cm 0cm 0cm}{
\tdplotsetmaincoords{0}{0}
\tdplotsetrotatedcoords{60}{70}{35}%
\begin{tikzpicture}
[tdplot_rotated_coords,
cube/.style={black},
arr/.style={latex-latex,color=green!70,thick}]
\coordinate (A1) at (0,0,0);
\coordinate (A2) at (0,1,0);
\coordinate (A3) at (1,1,0);
\coordinate (A4) at (1,0,0);
\coordinate (B1) at (0,0,1);
\coordinate (B2) at (0,1,1);
\coordinate (B3) at (1,1,1);
\coordinate (B4) at (1,0,1);
\coordinate (O) at ($(A1)!0.5!(B3)$);
\coordinate (S1) at ($(A1)!0.5!(B2)$);
\coordinate (S2) at ($(B2)!0.5!(A3)$);
\coordinate (S3) at ($(A3)!0.5!(B4)$);
\coordinate (S4) at ($(B4)!0.5!(A1)$);
\coordinate (S5) at ($(B1)!0.5!(B3)$);
\coordinate (S6) at ($(A1)!0.5!(A3)$);
\draw[cube] (B1) -- (B2) -- (B3) -- (B4) -- cycle;
\draw[cube] (A2) -- (B2);
\draw[cube] (A3) -- (B3);
\fill (O) circle[radius=1pt];
\begin{scope}[canvas is zy plane at x=0]
\draw[arr] (O) +(90:0.5) arc (90:-90:0.5) ;
\end{scope}
\begin{scope}[canvas is zx plane at y=0]
\draw[arr] (O) +(90:0.5) arc (90:-90:0.5) ;
\end{scope}
\begin{scope}[canvas is yx plane at z=0]
\draw[arr] (O) +(90:0.5) arc (90:-90:0.5) ;
\end{scope}
\draw[cube] (A1) -- (A2) -- (A3) -- (A4) -- cycle;
\draw[cube] (A1) -- (B1);
\draw[cube] (A4) -- (B4);
\end{tikzpicture}}
\end{document}