我正在尝试在球体上绘制测地线。虽然有很多方法,例如这个,我对另一种方式更感兴趣。如果我在球体上指定两个点,比如q
和p
,我想用测地线(即圆弧)连接它们。无论是较长的圆弧还是较短的圆弧,都可能对后续操作造成问题,我设法做到了以下几点
\documentclass[a4paper]{standalone}
\usepackage{tikz,tikz-3dplot}
\tikzstyle{point}=[inner sep=0pt, outer sep=0pt,%
minimum size=2pt,fill=black,shape=circle]
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}
\begin{scope}[tdplot_main_coords]
%draw sphere
\tdplotsphericalsurfaceplot{72}{36}{1}{black!75!white}{blue!20!white}%
{\draw[color=black,thick,->] (1,0,0) -- (1.5,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};}%
% draw geodesics
\tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0,0.7071,0.7071)
\tdplotdrawpolytopearc[thick,red!50!black]{1}{}{}
\tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0.7071,0.7071,0)
\tdplotdrawpolytopearc[thick,blue!50!black]{1}{}{}
\tdplotdefinepoints(0,0,0)(0.7071,0.7071,0)(0,0.7071,0.7071)
\tdplotdrawpolytopearc[thick,green!50!black]{1}{}{}
%draw point
\tdplotsetcoord{P}{1}{30}{60}
\node[point,label={0:\(p\)}] at (P) {};
\end{scope}
\end{tikzpicture}
\end{document}
得出
并引出了我的两个问题:
1) 我希望能够指定两个“跨越”点(极坐标中的第二点和第三点) 。有一个对 执行的\tdplotdefinepoints
函数就足够了,类似于对点 使用的函数。或者也许也可以从标签中提取这些坐标;这两种方法都可以吗?theta,phi
px,py,pz
P
2) 绘制圆弧时,是否有可能像平常一样\draw
访问中点?只要能在那里放置一个节点(带有样式)并贴上标签就足够了,否则\coordinate
当然也可以。有什么想法可以实现这一点吗?
答案1
这最多只是答案的 50%,因为我根本就不明白第一个请求。\tdplotsetcoord{P}{1}{30}{60}
确实定义了 3d 中的一个点。您能否重新表述第一个请求?
第二点很简单。decorations.markings
允许您在路径的任何位置标记一个点,当然包括中间。样式add coordinate={<name> at <pos>}
在以下 MWE 中执行此操作。
\documentclass[a4paper]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{decorations.markings}
\tikzset{point/.style={inner sep=0pt, outer sep=0pt,%
minimum size=2pt,fill=black,shape=circle},
add coordinate/.style args={#1 at #2}{postaction={decorate,
decoration={markings,mark=at position #2 with {\coordinate (#1);}}}}}
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}
\begin{scope}[tdplot_main_coords]
%draw sphere
\tdplotsphericalsurfaceplot{72}{36}{1}{black!75!white}{blue!20!white}%
{\draw[color=black,thick,->] (1,0,0) -- (1.5,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};}%
% draw geodesics
\tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0,0.7071,0.7071)
\tdplotdrawpolytopearc[thick,red!50!black,add coordinate={M1 at 0.5}]{1}{}{}
\tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0.7071,0.7071,0)
\tdplotdrawpolytopearc[thick,blue!50!black,add coordinate={M2 at 0.5}]{1}{}{}
\tdplotdefinepoints(0,0,0)(0.7071,0.7071,0)(0,0.7071,0.7071)
\tdplotdrawpolytopearc[thick,green!50!black,add coordinate={M3 at 0.5}]{1}{}{}
%draw point
\tdplotsetcoord{P}{1}{30}{60}
\node[point,label={0:\(p\)}] at (P) {};
\node[point,label={90:{$M_1$}}] at (M1){};
\node[point,label={-90:{$M_2$}}] at (M2){};
\node[point,label={0:{$M_3$}}] at (M3){};
\end{scope}
\end{tikzpicture}
\end{document}