3

I have a complex image that was created with TikZ in LaTeX, and I'm having difficulty recreating it. I tried several approaches, but was unsuccessful. The image involves various shapes and connections, making it challenging. Below is the images. I would like to ask for help recreating an image in LaTeX. If anyone can provide me with sample code or guidance on how to approach this problem, I would be very grateful.

enter image description here

This is the code I was trying to use for the process, but it was very cumbersome and difficult, it took almost a day to get there

\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}

AruGip
  • 33

2 Answers2

8

Just with TikZ' own 3d library it is possible to draw such a globe.

Since PGF/TikZ is only a 2d tool you will need to figure out the z-order of the elements yourself. In this case, I've only done this for the z axis. It is drawn after the globe so that it covers its elements but does not cover the middle dot.

In this example, I'm using the keys x, y and z to set up the 3d coordinate system but the perspective library offers 3d view to setup the angles. I believe tikz-3dplot's \tdplotsetmaincoords does something similar.

Code

\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}

Output

enter image description here

Qrrbrbirlbel
  • 119,821
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}

Half sphere with mesh and marks