axis環境下的右3D座標計算

axis環境下的右3D座標計算

我使用繪製參數圖pgfplots,並且想在曲線上添加特定點。我使用addplot3+coordinates在曲線上的特定座標處添加特定標記。該點位置很好(紅色)。現在我想在這一點\coordinate上使用axis環境來添加特定的文字。我嘗試過直接座標,axis cs但沒有一個有效。另一個奇怪的事情是,在 pgfplots 文件中,它被寫入(版本 1.16,第 4.17.1 節),它axis cs是環境中的預設座標系axis,可以省略。但是,如果我去掉的axis cs話就不一樣了。我確信,我錯過了一些東西:-)。

微量元素:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}

%parameters
\pgfmathsetmacro{\vrotP}{pi/4}
\def\lengthb{4}
\def\lengthh{3}
\pgfmathsetmacro{\timeTot}{4*pi/\vrotP}
\pgfmathsetmacro{\timeMid}{\timeTot/2}
\pgfmathsetmacro{\timeRef}{7}

\begin{tikzpicture}[
    declare function={%
    theta(\t)=\vrotP*\t;
    px(\t)=\lengthb*cos(theta(\t));
    py(\t)=\lengthb*sin(theta(\t));
    pz(\t)=-\lengthh*theta(\t);
    }%
]
\begin{axis}[axis lines=center,
    axis on top,
    samples y=0,
    trig format plots=rad,
    xmax=5,
    xmin=-5,
    ymax=5,
    ymin=-5,
    zmin=-45,
    zmax=0,
    ]
    % \addplot[variable=t,domain=0:10,samples=50]{pz(t)};
    \addplot3[blue,line width=2pt,variable=t,domain=0:\timeTot,samples=100]({px(t)},{py(t)},{pz(t)});
    % point M
    \addplot3+[red,only marks,line width=2pt] coordinates{({px(\timeRef)},{py(\timeRef)},{pz(\timeRef)})};
    %
    \pgfmathsetmacro{\tmpX}{px(\timeRef)}
    \pgfmathsetmacro{\tmpY}{py(\timeRef)}
    \pgfmathsetmacro{\tmpZ}{pz(\timeRef)}
    \coordinate (orig) at (axis cs:0,0,0);
    \coordinate (M) at (axis cs:\tmpX,\tmpY,\tmpZ);
    \coordinate (Mp) at (\tmpX,\tmpY,\tmpZ);
    \draw(orig)--(M);
    \draw(orig)--(Mp);
    \node[anchor=south] at (orig) {$O$};
    \node[] at (M) {$M$};
\end{axis}
\end{tikzpicture}

\end{document}

結果:

結果

相關內容