半球体,x 轴上每 5 度有一条线

半球体,x 轴上每 5 度有一条线

我有一张使用 TikZ 在 LaTeX 中创建的复杂图像,我很难重新创建它。我尝试了几种方法,但都没有成功。该图像涉及各种形状和连接,因此很有挑战性。以下是图像。我想寻求帮助在 LaTeX 中重新创建图像。如果有人可以为我提供示例代码或有关如何解决此问题的指导,我将不胜感激。

在此处输入图片描述

这是我尝试用于该过程的代码,但它非常繁琐和困难,花了将近一天的时间才到达那里

\documentclass[border=0.2cm]{standalone}

\usepackage{pgfplots}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{60}{115}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}[tdplot_main_coords, scale = 2.5]

\tdplotsetrotatedcoords{90}{90}{-90};
\draw[dashed, tdplot_rotated_coords, gray] (0,-1,0) arc (-90:90:1);


\tdplotsetrotatedcoords{0}{90}{0};
\draw[tdplot_rotated_coords, black] (0,0,0) circle (1);

\tdplotsetrotatedcoords{90}{90}{-90};
\draw[dashed, tdplot_rotated_coords, gray] (0,-1,0) arc (-90:90:1);

\tdplotsetrotatedcoords{0}{0}{0};
\draw[dashed, tdplot_rotated_coords, gray] (0,-1,0) arc (-90:90:1);

\draw[-stealth] (0,0,0) -- (1.8,0,0) node[below left] {$x$};
\draw[-stealth] (0,0,0) -- (0,1.3,0) node[below right] {$y$};
\draw[-stealth] (0,0,0) -- (0,0,1.3) node[above] {$z$};

\draw[dashed, black] (0,0,0) -- (-1.3,0,0);
\draw[dashed, black] (0,0,0) -- (0,-1.3,0);
\draw[dashed, black] (0,0,0) -- (0,0,-1.3);

\draw[fill = lightgray!50] (2,2,2) circle (0.5pt);

\end{tikzpicture}

\end{document}

答案1

只需使用 TikZ 自己的3d库就可以绘制这样的地球仪。

由于 PGF/TikZ 只是一个 2d 工具,你需要弄清楚-自己设置元素的顺序。在本例中,我只对轴。它在地球仪之后绘制,以便覆盖其元素,但不覆盖中间的点。

在此示例中,我使用xy以及z设置三维坐标系,但perspective图书馆提供3d view设置角度的功能。我相信tikz-3dplot\tdplotsetmaincoords功能类似。

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta, 3d, quotes}
\tikzset{
  math nodes/.style={execute at begin node=$, execute at end node=$},
  edges/.style={every edge/.append style={#1}}}
\begin{document}
\begin{tikzpicture}[
  very thin,
  > = {Latex [round]},
  x = (-10:2.75cm), y = (90:3cm), z = (-140:1.8cm),
  axis/.style={very thick, red!50!black},
  math nodes, at end,
  dot/.style={shape=circle, draw, inner sep=+0pt, minimum size=+2.5pt},
  ang 90/.style={thick, nodes=fill, nodes={name=n\pos}},
  pos 9/.style=fill
]
\coordinate (O) at (0, 0, 0);
\path[axis, ->] (O) edge["x" right] (1.5, 0,   0  )
                    edge["y" above] (0,   1.5, 0  ) [-]
                    edge            (0,   0,   1  ) [edges=dashed]
                    edge           (-1.7, 0,   0  )
                    edge           ( 0,  -1.7, 0  )
                    edge           ( 0,   0,  -1.7);
\foreach \ang in {10, 20, ..., 170}
  \draw[ang \ang/.try]
    (xyz spherical cs: radius=1, longitude=\ang) % start point for arc
    [canvas is xz plane at y=0] % arc is 2d → XY cs in xz plane
    arc[start angle=0, delta angle=180, radius=sin \ang];

\foreach \ang in {0, 10, ..., 180}
  \draw[ang \ang/.try]
    (0, 1, 0) % start point for arc (always on the top)
    [rotate around y=\ang] % arc is 2d → rotate XY cs
    arc[start angle=90, delta angle=180, radius=1]
      % let's add the dots along the arc
      node foreach \pos in {1, ..., 17} [dot, pos \pos/.try, pos=\pos/18]{};

% Top and bottom nodes (no need to do an arc with radius 0 or place these 18 times)
\node foreach \y in {-1, 1} [dot, pos 9] at (0, \y, 0) {};

% z-axis on top of globe but not on top of dot
\path[axis, ->] (n9) edge["z" below left] +( 0, 0, 0.9);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

答案2

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={25}{25},
axis lines=center,
axis equal,
enlargelimits=0.2,
ticks=none,
]
\addplot3[
mesh, black, ultra thin,
mark=o, mark size=0.5,
domain=180:360, samples=19,
y domain=0:180, samples y=19,
] ({sin(x)*cos(y)},{sin(x)*sin(y)},{cos(x)});
\end{axis}
\end{tikzpicture}
\end{document}

带网格和标记的半球

相关内容