带有 tikz-3D 的 3D 笛卡尔空间以及测量弧的放置以显示仰角

带有 tikz-3D 的 3D 笛卡尔空间以及测量弧的放置以显示仰角

我目前有以下代码

\tdplotsetmaincoords{60}{45}
\begin{tikzpicture}[tdplot_main_coords]

    \coordinate (0) at (0,0,0);
    \tdplotsetcoord{P}{3}{45}{45} 


    \draw[thick, ->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$ (front)};
    \draw[thick, ->] (0,0,0) -- (0,3,0) node[anchor=north west]{$y$ (left)};
    \draw[thick, ->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$ (up)};


    \draw[-stealth, color=red](0) -- (P) node[anchor=west]{$r$};
    \draw[dashed, color=red] (0) -- (Pxy);
    \draw[dashed, color=red] (Pxy) -- (P);

    
    \tdplotsetcoord{Pxy}{3}{\tdplotresphi}{0}
    \tdplotgetpolarcoords{1.5}{1.5}{2.12}
    \tdplotsetthetaplanecoords{\tdplotresphi}


    \tdplotdrawarc{(0)}{1.5}{0}{\tdplotresphi}{anchor=west}{$\theta$}
    \tdplotdrawarc[dashed]{(0)}{1.5}{\tdplotresphi}{90}{anchor=west}{$\phi$}

\end{tikzpicture}

我想改变它,以便标记的角度\phi从其当前原点 Pxy 到矢量 测量r,从而给出仰角。因此,它应该从 Pxy 向 Z 轴测量和定位。

在此处输入图片描述

答案1

根据手册第 27 页,您需要切换到旋转的平面。

\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{45}
\begin{tikzpicture}[tdplot_main_coords]

    \coordinate (0) at (0,0,0);
    \tdplotsetcoord{P}{3}{45}{45} 


    \draw[thick, ->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$ (front)};
    \draw[thick, ->] (0,0,0) -- (0,3,0) node[anchor=north west]{$y$ (left)};
    \draw[thick, ->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$ (up)};


    \draw[-stealth, color=red](0) -- (P) node[anchor=west]{$r$};
    \draw[dashed, color=red] (0) -- (Pxy);
    \draw[dashed, color=red] (Pxy) -- (P);
    
    \tdplotgetpolarcoords{1.5}{1.5}{2.12}
    \tdplotsetcoord{Pxy}{3}{\tdplotresphi}{0}
    \tdplotsetthetaplanecoords{\tdplotresphi}


    \tdplotdrawarc{(0)}{1.5}{0}{\tdplotresphi}{anchor=west}{$\theta$}
    %\tdplotdrawarc[dashed]{(0)}{1.5}{\tdplotresphi}{90}{anchor=west}{$\phi$}
    
    \tdplotsetthetaplanecoords{\tdplotresphi}
    \tdplotdrawarc[tdplot_rotated_coords,dashed]{(0,0,0)}{1.5}{90}%
        {\tdplotresphi}{anchor=west}{$\phi$}


\end{tikzpicture}    
\end{document}

在此处输入图片描述

相关内容