如何在 tikz 3dplot 中显示立方体的旋转方向

如何在 tikz 3dplot 中显示立方体的旋转方向

我尝试使用两端都有箭头的半圆形箭头。所有箭头的中心都应围绕 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}

演示

相关内容