
我正在嘗試使用 Tikz 創建與此類似的圖像
我寫了這段程式碼,部分基於程式碼這個線程作為
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\newcommand{\xangle}{7}
\newcommand{\yangle}{137.5}
\newcommand{\zangle}{90}
\newcommand{\xlength}{1}
\newcommand{\ylength}{0.5}
\newcommand{\zlength}{1}
\pgfmathsetmacro{\xx}{\xlength*cos(\xangle)}
\pgfmathsetmacro{\xy}{\xlength*sin(\xangle)}
\pgfmathsetmacro{\yx}{\ylength*cos(\yangle)}
\pgfmathsetmacro{\yy}{\ylength*sin(\yangle)}
\pgfmathsetmacro{\zx}{\zlength*cos(\zangle)}
\pgfmathsetmacro{\zy}{\zlength*sin(\zangle)}
\begin{tikzpicture}
[ x={(\xx cm,\xy cm)},
y={(\yx cm,\yy cm)},
z={(\zx cm,\zy cm)},
]
\draw[dashed] (0,0,0) circle (4.5);
\draw[blue!80!black,->] (240:4.5) -- (240:5.5);
\node[blue!80!black] at (240:5.8) {y};
\draw[green!80!black,->] (240:4.5) -- ++(0,0,1);
\node[green!80!black] at ($(240:4.5)+(0,0,1.2)$) {z};
\draw[red!80!black,->] (240:4.5) -- ++ (240+90:1);
\node[red!80!black] at ($(240:4.5)+(240+90:1.3)$) {x};
\fill[black!50!gray,draw=black!50!black] (240:4.5) circle (0.05cm);
\foreach \d in {0,60,120,180,240,300}
{
\draw[thick, black,->] (\d:4.5) -- ++(1,1,1);
}
\end{tikzpicture}
\end{document}
但我得到了所有指向同一方向的向量。我怎麼才能將其修復為與第一張圖相似?另外,如何像第一張圖一樣加入角度 α 和 β ?
答案1
您可以使用tikz-3dplot
在這裡使用。它允許您切換到旋轉座標。我的看法是你真的想並行傳輸旋轉的向量,如螢幕截圖所示。切線的平行傳輸會容易得多,只需使用 xy 平面即可。 (如果這是您想要的,請告訴我。)
要平行傳輸的向量的旋轉角度儲存在“函數”alpha
和中beta
。它們以及視角都可以隨意調整。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{00}%<- set view angles
\begin{tikzpicture}[>=stealth,line cap=round,
tdplot_main_coords,%<- install 3d view
declare function={R=4;alpha=-40;beta=-50;}%<- radius of the circle and angles
]
\begin{scope}[canvas is xy plane at z=0]
\draw[semithick] (0,0) circle[radius=R];
\draw[thick,->,blue] (-1.5,-R) -- ++ (3,0) node[right]{$t$};
\draw (1,-R) arc[start angle=0,end angle=alpha,radius=1];
\path foreach \X in {0,...,5}
{(-90+\X*60:R) coordinate (p\X)}; % points along the circle
\end{scope}
% rotated plane at p0
\tdplotsetrotatedcoords{alpha}{0}{0}
\begin{scope}[tdplot_rotated_coords,canvas is xz plane at y=0,shift={(p0)}]
\draw (0,0) rectangle ++ ((90+beta:{1/abs(cos(alpha))}) (1,0) node[right]{$\alpha$};
\draw[thick,->,red] (-90+beta:{1/abs(cos(alpha))})
-- ++ (90+beta:{2/abs(cos(alpha))});
\draw[->] (0,-1) -- (0,1) node[above]{$z$};
\draw (0,0.5) arc[start angle=90,end angle=90+beta,radius=0.5]
node[midway,above right] {$\beta$};
\end{scope}
% other planes
\foreach \X in {1,...,5}
{\tdplotsetrotatedcoords{alpha}{0}{\X*60}
\begin{scope}[tdplot_rotated_coords,canvas is xz plane at y=0,shift={(p\X)}]
\draw[thick,->,red] (-90+beta:{1/abs(cos(alpha))})
-- ++ (90+beta:{2/abs(cos(alpha))});
\end{scope}}
\end{tikzpicture}
\end{document}