我想在 3d 球体表面画一条随机闭合线(像一个有点变形的圆)。它看起来应该像是从球体上切下一小块。它应该位于北半球。球体应该用除了“圆”之外的线条阴影突出显示,然后反转。
到目前为止我成功地画出了一个球体:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,3,0) node[anchor=north west]{$z$};
\draw[thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{$y$};
\draw (0,0) circle (2cm);
\draw (-2,0) arc (180:360:2 and 0.6);
\draw[dashed] (2,0) arc (0:180:2 and 0.6);
\fill[fill=black] (0,0) circle (1pt);
\end{tikzpicture}
\end{document}
答案1
这是一个手动但简单的解决方案,不需要太多代码。
- 该
hobby
库提供了创建封闭的块状形状的解决方案。 - 该
patterns
库用于用图案填充形状。 - 可
even odd rule
用于填充圆圈,但不能填充其中的斑点。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,hobby}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\draw[use Hobby shortcut,closed=true,pattern=north east lines]
(-0.2,0.3) .. (0.2,0.2) .. (1.1,0.6) .. (1.1,1) .. (0.3,1.4) .. (-0.4,1.2) .. (-0.3,0.8);
\draw (-2,0) arc (180:360:2 and 0.6);
\draw[dashed] (2,0) arc (0:180:2 and 0.6);
\fill[fill=black] (0,0) circle (1pt);
\begin{scope}[xshift=5cm]
\draw[use Hobby shortcut,closed=true,pattern=north east lines,even odd rule] (0,0) circle (2cm)
(-0.2,0.3) .. (0.2,0.2) .. (1.1,0.6) .. (1.1,1) .. (0.3,1.4) .. (-0.4,1.2) .. (-0.3,0.8);
\draw (-2,0) arc (180:360:2 and 0.6);
\draw[dashed] (2,0) arc (0:180:2 and 0.6);
\fill[fill=black] (0,0) circle (1pt);
\end{scope}
\end{tikzpicture}
\end{document}