2

I have just started to use the 3d library in TikZ and would like to get some advise. I would like to create in TikZ a sphere built from a circle in the xy-plane (z pointing out from screen) and a 180 degree dashed arc ("behind" the xy-circle) + a drawn 180 degree arc ("in front of" the xy-circle).

I feel like I am maybe not approaching this problem the right way, so if have you any advice, please let me know!

\documentclass[border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d,calc,positioning}

\begin{document}


\begin{tikzpicture}%[z={(90:10mm)},x={(190:10mm)},y ={(-45:10mm)}]

\coordinate (O) at (0,0,0); 
\coordinate (A) at (1,0,0); 
\coordinate (B) at (0,1,0); 
\coordinate (C) at (0,0,1); 

%\draw (O) -- (A) node {$x$}; 
%\draw (O) -- (B) node {$y$};
%\draw (O) -- (C) node {$z$};  

 \begin{scope}[canvas is xy plane at z=0]
  \draw (A) arc[start angle=0, end angle = 360, radius=1] -- cycle;
 \end{scope}
  \begin{scope}[canvas is xz plane at y=0]
  \draw[dashed] (-1, 0, 0) arc[start angle=180, end angle = 360, radius=1];
   \draw[] (1, 0, 0) arc[start angle=0, end angle = 180, radius=1];
 \end{scope}

\end{tikzpicture}


\end{document}

I would like it to look like when you a draw a sphere by hand.

Update: tried to hard code something to solve the problem, but I believe that this is a really ugly solution.

\documentclass[border=10mm]{standalone}
\usepackage[UseComma, OpenSans]{MagmaGeometry}
\usepackage{marvosym}
\usetikzlibrary{3d,calc,positioning}

\begin{document}


\begin{tikzpicture}%[z={(90:10mm)},x={(190:10mm)},y ={(-45:10mm)}]

\coordinate (O) at (0,0,0); 
\coordinate (A) at (1,0,0); 
\coordinate (B) at (0,1,0); 
\coordinate (C) at (0,0,1); 

%\draw (O) -- (A) node {$x$}; 
%\draw (O) -- (B) node {$y$};
%\draw (O) -- (C) node {$z$};  

 \begin{scope}[canvas is xy plane at z=0]
  \draw (A) arc[start angle=0, end angle = 360, radius=1] -- cycle;
 \end{scope}
  \begin{scope}[canvas is xz plane at y=0]
  \draw[dashed] (-1, 0, 0) arc[start angle=200, end angle = 310, radius=1.1];
   \draw[] (1, 0, 0) arc[start angle=35, end angle = 147, radius=1.215];
 \end{scope}

\end{tikzpicture}


\end{document}

  [1]: https://i.stack.imgur.com/ykHGG.png

1 Answer 1

2

Maybe like this? You can use 3dtools.

    \documentclass[border=2mm]{standalone}
    \usepackage{tikz}
    \usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
    \begin{document}
    \begin{tikzpicture}[3d/install view={phi=110,theta=70},line cap=butt,
            line join=round,declare function={R=2.5;},c/.style={circle,fill,inner sep=1pt}] 
            \path
            (0,0,0) coordinate (O)
            (0,0,R)  coordinate (N)
            (0,0,-R)  coordinate (S);
\draw[3d/screen coords] (O) circle[radius=R]; 
            \path pic{3d/circle on sphere={R=R,C={(O)}}};
            \path  pic{3d/circle on sphere={R=R,C={(O)},P={(O)}, n={(0,1,0)}}}; 
            \draw[3d/hidden] (S) -- (N);
            \path foreach \p/\g in {O/-30,S/0,N/-30}
            {(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
        \end{tikzpicture}
    \end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .