使用 TikZ 的惯性和局部垂直局部水平参考框架

使用 TikZ 的惯性和局部垂直局部水平参考框架

如何使用 TikZ 包创建包含两个参考框架的简单 3D 图?为了参考目的,该图可能大致如下所示:在此处输入图片描述

答案1

TikZ 允许您指定三维坐标,并将其投影到页面上。重要的是,您可以指定(并局部更改)该投影。如果您想在同一幅图像中使用多个坐标系,您可能需要为它们设置样式。

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{calc}
\tikzset{
  > = {stealth},
  % specifying distances in cm puts them in the paper coordinates,
  % without units puts them in these tikz xy(z) coordinates
  inertial frame/.style = {x={(-20:2cm)}, y={(-160:2cm)}, z={(90:2cm)}},
  local frame/.style = {shift={(local origin)}, x={(40:.7cm)}, y={(150:.7cm)}, z={(105:.7cm)}}
}

\begin{document}
\begin{tikzpicture}[scale=2, inertial frame]
  % draw axes
  \draw[->] (0,0,0) -- (1,0,0) node[above] {$i_1$};
  \draw[->] (0,0,0) -- (0,1,0) node[above] {$i_2$};
  \draw[->] (0,0,0) -- (0,0,1) node[left] {$i_3$};
  % draw dashed lines and set the coordinate (local origin) which is used in the local frame style
  \draw[dashed] (0,0,0) -- ++(15:1) coordinate (projection) -- ++(0,0,1) coordinate (local origin);

  \draw[very thick, ->] (0,0,0) -- (local origin);
  \draw[<->] (90:.5) arc (90:15:.5) node[below, pos=.5] {$\alpha$};
  % arcs are drawn in the x-y plane, so locally set x and y to an orthonormal basis to the desired plane
  \draw[y={(0,0,1)}, x={(projection)}, <->] (0:.4) arc (0:45:.4) node[right, pos=.5] {$\delta$};

  \begin{scope}[local frame]
    % draw local axes
    \draw[->] (0,0,0) -- (1,0,0) node[above] {$l_1$};
    \draw[->] (0,0,0) -- (0,1,0) node[above] {$l_2$};
    \draw[->] (0,0,0) -- (0,0,1) node[left] {$l_3$};
    % draw right angle
    \draw[thin] (.2,0,0) -- (.2,.2,0) -- (0,.2,0);
  \end{scope}\end{tikzpicture}
\end{document}

在此处输入图片描述

由于上述样式local frame引用了坐标(local origin),因此在使用该样式之前需要定义该坐标。

答案2

我希望能用一个简单的代码(2D)帮助你。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3.52,-2.76) rectangle (7.36,5.76);
\draw (0,0) -- (-23.1:1.4) arc (-23.1:43.3:1.4) -- cycle;
\draw [->] (0.,0.) -- (0.,4.);
\draw [->] (0.,0.) -- (-2.84,-2.02);
\draw [->,line width=1.6pt] (0.,0.) -- (3.84,3.62);
\draw [dash pattern=on 4pt off 4pt] (3.84,3.62)-- (3.84,-1.64);
\draw [dash pattern=on 4pt off 4pt] (0.,0.)-- (3.84,-1.64);
\draw [shift={(-0.4,1.76)}] plot[domain=4.4:5.3,variable=\t]({1.*2.79*cos(\t r)+0.*2.79*sin(\t r)},{0.*2.79*cos(\t r)+1.*2.79*sin(\t r)});
\draw [->] (0.,0.) -- (5.34,-1.3);
\draw [->] (3.84,3.62) -- (2.2,4.42);
\draw [->] (3.84,3.62) -- (3.44,5.5);
\draw [->] (3.84,3.62) -- (5.28,4.78);
\draw (3.4,3.85)-- (3.8,4.22);
\draw (3.8,4.22)-- (4.28,4);
\draw (-0.54,4.74) node[anchor=north west] {$\mathbf{i_3}$};
\draw (-3.2,-1.4) node[anchor=north west] {$\mathbf{i_2}$};
\draw (0.08,-0.9) node[anchor=north west] {$\mathbf{\alpha}$};
\draw (1.4,0.8) node[anchor=north west] {$\mathbf{\delta}$};
\draw (5.48,-0.96) node[anchor=north west] {$\mathbf{i_1}$};
\draw (3.66,5.82) node[anchor=north west] {$\mathbf{i_3}$};
\draw (5.36,5.5) node[anchor=north west] {$\mathbf{i_1}$};
\draw (1.9,5.28) node[anchor=north west] {$\mathbf{i_2}$};
\begin{scriptsize}
\draw [fill=white] (0.,0.) circle (0.5pt);
\end{scriptsize}
\end{tikzpicture}
\end{document}

相关内容