是否可以使用连接路径在 1/8 球体上绘制阴影?

是否可以使用连接路径在 1/8 球体上绘制阴影?

所以我知道如何遮蔽一个球体,甚至是半球,但我无法遮蔽一个八分圆:球面八分圆

绘制要着色的区域的边缘非常简单,但为了使用圆弧绘制它,必须旋转绘制圆弧的平面。为了完整起见,我包含了整个代码块,但我的问题涉及最后几行。

%define use path
\makeatletter
\tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}
\makeatother

%set the orientation of the coordinate system
\tdplotsetmaincoords{60}{110}

\begin{tikzpicture}[scale=5,tdplot_main_coords]
%draw the main coordinate system axes
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};

%set the orientation for the drawing of the first arc
\pgfmathsetmacro{\radius}{1}
\pgfmathsetmacro{\thetavec}{0}
\pgfmathsetmacro{\phivec}{0}

%make path from x=0,y=0,z=r to x=1,y=0,z=0
\tdplotsetthetaplanecoords{\phivec}
\path[save path=\ztoxarc,tdplot_rotated_coords] (\radius,0,0) arc (0:90:\radius);

%rotate the plane of drawing and make path from x=0,y=0,z=r to x=0,y=1,z=0
\pgfmathsetmacro{\phivec}{90}
\tdplotsetthetaplanecoords{\phivec}
\path[save path=\ztoyarc,tdplot_rotated_coords] (\radius,0,0) arc (0:90:\radius);

%make path from x=r,y=0,z=0 to x=0,y=r,z=0
\path[save path=\xtoyarc] (1,0) arc (0:90:1);

%draw all three arcs
\draw [use path=\xtoyarc \ztoxarc \ztoyarc,dashed];

%draw approximate shading
\shade[ball color=blue!10!white,opacity=0.5] (0,0,1) -- (0,1,0) -- (1,0,0);

\end{tikzpicture}

有没有办法将最后一行和倒数第二行合并起来,并使用我保存的路径

\xtoyarc \ztoxarc \ztoyarc

以及 \shade 命令来为圆弧之间的区域添加阴影?

未完全被阴影覆盖的八分圆

或者,如果失败了,可以采用其他一些直接的方法来做到这一点,而这不需要(我的备用计划)进行大量的数学运算来找出一个新的路径参数化,以巧妙地替换我当前近似中的坐标:

\shade[ball color=blue!10!white,opacity=0.5] (0,0,1) -- (0,1,0) -- (1,0,0);

答案1

我不知道如何连接单独定义的路径,但您可以仅为路径的一部分设置旋转坐标:

\documentclass[tikz, border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}
  \draw[->] (0,0,0) -- (2,0,0) node[right] {$x$};
  \draw[->] (0,0,0) -- (0,2,0) node[above] {$y$};
  \draw[->] (0,0,0) -- (0,0,2) node[below left] {$z$};

  \shade[ball color=blue!10!white,opacity=0.5] (1.5,0) arc (0:90:1.5) {[x={(0,0,1)}] arc (90:0:1.5)} {[y={(0,0,1)}] arc (90:0:1.5)};
\end{tikzpicture}
\end{document}

阴影球

如果你想保留你所拥有的大部分内容,那么看起来就像use path=\xtoyarc \ztoxarc \ztoyarc在当前\shade命令中添加阴影球体的一部分外部三角形(具有相同的球参数),因此您可以将其分成两部分进行着色:

\shade[use path=\xtoyarc \ztoxarc \ztoyarc, ball color=blue!10!white,opacity=0.5] (1,0,0) -- (0,1,0) -- (0,0,1) -- cycle;
\shade[ball color=blue!10!white,opacity=0.5] (1,0,0) -- (0,1,0) -- (0,0,1) -- cycle;

另一个阴影球

相关内容