3

Using tikz package, I am trying to draw a figure that looks something like this: enter image description here

I am having trouble drawing arcs on top of the spherical caps. I would truly appreciate it if someone can help me. Here is the output image:

enter image description here

Here is the code that I have so far:

\documentclass[letter, 10pt]{article}


% Mathematics 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm} 
\usepackage{physics}
\usepackage{siunitx} 
\usepackage{gensymb} 
\usepackage{esvect} % Use \hat{} for vectors 

% Fonts
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

% Graphics
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots} % Allows for plots/graphs
\usepackage{xcolor}

% Other
\usepackage{epstopdf}
\usepackage{float}
\usepackage{array}
\usepackage{hhline} 
\usepackage{arydshln}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{framed}
\usepackage{mdframed} 
\usepackage{multicol} 
\usepackage{enumitem} 


\begin{document}
    
    
    \begin{figure}[H]
        \centering
        \begin{tikzpicture}[font=\tiny]
            % Coordinate System
            \draw[dashed, line width=0.1pt] (0,-3) -- (0,3) ;
            \draw[dashed, line width=0.1pt] (3,0) -- (-3,0) ;
            \draw[dashed, line width=0.1pt] (0,0) -- (30:2.5) ;
            \draw[dashed, line width=0.1pt] (0,0) -- (30:-2.5) ;
            
            % Top cap
            \draw (-1,2) arc (180:360:1 and 0.35) ;
            \draw (1,2) arc (0:180:1 and 0.35) ;
            \fill (0,2.25) circle (0.5pt);
            % A bad attempt to draw arcs...
            \draw[line width=0.1pt] (0,2.25) arc (90:15:0.69);
            \draw[line width=0.1pt] (0,2.25) arc (90:60:2);
            \draw[line width=0.1pt] (0,2.25) arc (90:70:2.85);

            % Bottom cap
            \draw (-0.5,1) arc (180:360:0.5 and 0.175) ;
            \draw[dashed] (0.5,1) arc (0:180:0.5 and 0.175) ;
            \fill (0,1.125) circle (0.5pt); 
            
            % Cone structure
            \draw[dashed] (0,0) -- (0.505,1);   
            \draw[dashed] (0,0) -- (-0.505,1);  
            \draw (0.505,1) -- (1,1.97);
            \draw (-0.505,1) -- (-1,1.97);                        
        \end{tikzpicture}
    \end{figure}

    
\end{document}

P.S. If there is any other ("cooler") way to do this, perhaps using shading instead of lines to illustrate a 3D spherical cap, I would love to see it implemented.

1 Answer 1

3

Only for getting started. You can do something like the following. It's easier in isometric 3d (but it requires a couple of trigonometric calculations). Tikz draws for you the ellipse arcs, if you use the option rotate around z. It's this and some \foreach commands and you have it.

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

\def\ch{3.75} % cone height
\def\cv{2}    % cone visibility height
\def\ph{20}   % cone angle

% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}

\pgfmathsetmacro\cr {\ch*tan(\ph)} % cone radius
\pgfmathsetmacro\cg {\ch/cos(\ph)} % cone generatrix
\pgfmathsetmacro\crv{\cv*tan(\ph)} % cone radius     (not visible part)
\pgfmathsetmacro\cgv{\cv/cos(\ph)} % cone generatrix (not visible part)

\pgfmathsetmacro\gs{sqrt((2*\ch*\ch-\cr*\cr)/(3*\cr*\cr))} % generatrix slope
\pgfmathsetmacro\xt{sqrt(6)*\gs*\ch/(1+3*\gs*\gs)}         % tangent point x
\pgfmathsetmacro\yt{\gs*\xt}                               % tangent point y
\pgfmathsetmacro\aa{(\ch*\zz-\yt)/\xy/2-\xt/\xx/2}         % coordinate x in xy plane
\pgfmathsetmacro\bb{(\ch*\zz-\yt)/\xy/2+\xt/\xx/2}         % coordinate y in xy plane
\pgfmathsetmacro\at{atan(\bb/\aa)+180}                     % angle to the tangent point

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}]
\begin{scope}[canvas is xy plane at z=\ch]
  \draw (0,0) circle (\cr);
\end{scope}
\draw ($(\at:\cr)+(0,0,\ch)$) -- ($(\at:\crv)+(0,0,\cv)$) arc (\at:90-\at:\crv) -- ($(90-\at:\cr)+(0,0,\ch)$);
\draw[dashed] (0,0,0) -- ($(\at:\crv)+(0,0,\cv)$) arc (\at:450-\at:\crv) -- cycle;
% meridians
\foreach \a in {0,30,...,179}
{%
  \begin{scope}[rotate around z=\a, canvas is xz plane at y=0]
    \draw[red] (0,0) ++ (90-\ph:\cg)  arc (90-\ph:90+\ph:\cg);
    \draw[red] (0,0) ++ (90-\ph:\cgv) arc (90-\ph:90+\ph:\cgv);
  \end{scope}
}
% parallels
\foreach \i in {1,2} \foreach \j in {\cg,\cgv}
{%
  \pgfmathsetmacro\a{\i*\ph/3}
  \begin{scope}[canvas is xy plane at z={\j*cos(\a)}]
    \draw[red] (0,0) circle ({\j*sin(\a)} );
  \end{scope}
}
\end{tikzpicture}
\end{document}

enter image description here

3
  • Thank you so much! I have a question: How can I offset the point in the center of the ellipse to be more north (middle of the semi-minor axis)? I think it will look more realistic. That is what I tried to do in my drawing (first image).
    – Vladimir
    Apr 4, 2021 at 16:17
  • 1
    @Vladimir, you can change the angle \ph value for a bigger one. That will move a little the pole to the north. Or you can change the perspective, but in this case you need to do all the calculations again Apr 4, 2021 at 16:31
  • Juan, could you by any chance help with the question I continued on this post: tex.stackexchange.com/questions/591451/… ? At least with the fill.
    – Vladimir
    Apr 4, 2021 at 22:08

You must log in to answer this question.

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