使用 tikz 绘制方向余弦

使用 tikz 绘制方向余弦

如何使用 TikZ 轻松绘制方向余弦?在此处输入图片描述

答案1

这是通过 得到的 3D 解决方案tikz-3dplot。需要两个输入(1)欧几里得坐标(\ax,\ay,\az)和(2)其欧几里得 2 范数/距离\r

下面的代码基本上执行以下操作

  1. 绘制坐标系
  2. 从输入得到P点,然后通过外部扩展技巧延伸到V点。
  3. tdplot-define-points通过需要 3 个输入(原点、P 和轴上的一个点)的命令分别从 P 到第一象限的 3 个轴绘制角度, 以形成三角多面体
    ,然后通过 绘制每个圆弧tdplot-polytope-arc

在此处输入图片描述

代码

\documentclass[border=10pt,varwidth]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{calc}
\begin{document}

\tikzset{vector/.style={<-,black,thin}
}
%  ---- draw coordinates
\tdplotsetmaincoords{60}{120}
\pgfmathsetmacro{\ax}{0.2}%{0.3}
\pgfmathsetmacro{\ay}{0.3}%{0.3}
\pgfmathsetmacro{\az}{0.6}%{0.5}
\def\r{0.7}               %{0.655} %  2-norm of (x,y,z)
\begin{tikzpicture}[scale=5,tdplot_main_coords]     
\coordinate (O) at (0,0,0);  

\draw[thick,->,orange] 
(0,0,0) -- (1.3,0,0)node[anchor=north east]{$\mathbf{V_x}$};   
\draw[thick,->,orange] (0,0,0) -- (0,1.3,0)node[anchor=north west]{$\mathbf{V_y}$}; 
\draw[thick,->,orange] (0,0,0) -- (0,0,1.3)node[anchor=south]{$\mathbf{V_z}$};

\draw[thick,->,blue] 
(0,0,0) -- (1,0,0)node[above]{$\mathbf{e_x}$}; 
\draw[thick,->,blue]  (0,0,0) -- (0,1,0)node[below]{$\mathbf{e_y}$}; 
\draw[thick,->,blue]  (0,0,0) -- (0,0,1)node[right]{$\mathbf{e_z}$};   
% ---- start from P to draw angles a, b, c
\coordinate [] (P) at (\ax,\ay,\az){}; 
\draw[-stealth,thick] (P) -- ($(P)!-0.3cm!(O)$) coordinate (V)node[above]{$V$};

{     %define 3 points 0,A,B for angle c
\tdplotdefinepoints(0,0,0)(0,0,\r)(\ax,\ay,\az) 
\draw[fill=cyan](0,0,\r) --(0,0,0)--(\tdplotbx,\tdplotby,\tdplotbz);
\tdplotdrawpolytopearc[fill=cyan]{\r}{anchor=south}{$c$}
\tdplotdrawpolytopearc[vector]{\r}{anchor=south}{$c$}     % draw arc arrow
}
{     %define 3 points 0,A,B for angle a
\tdplotdefinepoints(0,0,0)(\r,0,0)(\ax,\ay,\az)
\draw[fill=cyan,opacity=0.8](\r,0,0)--(0,0,0)--(\tdplotbx,\tdplotby,\tdplotbz);
\tdplotdrawpolytopearc[fill=cyan,opacity=0.8]{\r}{anchor=south}{$a$}
\tdplotdrawpolytopearc[vector]{\r}{anchor=south}{$a$}     % draw arc arrow
}
{     % define 3 points 0,A,B for angle b
\tdplotdefinepoints(0,0,0)(0,\r,0)(\ax,\ay,\az) 
\draw[fill=cyan](0,\r,0) --(0,0,0)--(\tdplotbx,\tdplotby,\tdplotbz);
\tdplotdrawpolytopearc[fill=cyan]{\r}{anchor=west}{$b$}
\tdplotdrawpolytopearc[vector]{\r}{anchor=west}{$b$}      % draw arc arrow
}
\end{tikzpicture}
\end{document}

答案2

一个简单的二维解决方案:

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc,positioning}
\definecolor{corange}{rgb}{0.93, 0.57, 0.13}
\begin{document}
\begin{tikzpicture}[>=latex,scale=0.7,inner sep=2pt]
\path coordinate (o) at (0,0)
coordinate (x) at (220:4)node(X) at($(o)!.9!(x)$)[label=below right:$\textcolor{corange}{V_x}\textcolor{blue}{e_x}$]{}
coordinate (y) at (0:6) node(Y)  at($(o)!.9!(y)$)[label=below:$\textcolor{corange}{V_y}\textcolor{blue}{e_y}$]{}
coordinate (z) at (90:6)node(Z)  at($(o)!.9!(z)$)[label=right:$\textcolor{corange}{V_z}\textcolor{blue}{e_z}$]{}
coordinate (v) at (50:5)node at($(o)!1!(v)$)[label=right:$V$]{};

\draw [fill=green,->]($(o)!.42!(y)$)to (o) to($(o)!0.5!(v)$) to [bend left] node[right]{$b$}($(o)!.42!(y)$);
\draw [fill=green,->]($(o)!.37!(z)$)to (o) to($(o)!0.4!(v)$) to [bend right] node[above]{$c$}($(o)!.37!(z)$);
\draw [fill=green,->]($(o)!.3!(x)$)to (o) to($(o)!0.25!(v)$) to [bend right] node[above left]{$a$}($(o)!.3!(x)$);
\draw  (o) edge [->,corange] (x) edge [->,thick,blue] (X)
           edge [->,corange] (y) edge [->,thick,blue] (Y)
           edge [->,corange] (z) edge [->,thick,blue] (Z)
           edge [->,thick] (v); 
\end{tikzpicture}
\end{document}

结果是这样的:

在此处输入图片描述

相关内容