# Spherical Helix

Edit and compile if you like:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{math}
\usepackage{ifthen}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{1pt}
%
% File name: spherical-helix.tex
% Description:
% A geometric representation of a spherical helix is shown.
%
% Date of last modification: October, 9th, 2022.
% Author: Efraín Soto Apolinar.
% https://www.aprendematematicas.org.mx/author/efrain-soto-apolinar/instructing-courses/
% Source: page 223 of the
% Glosario Ilustrado de Matem\'aticas Escolares.
% https://tinyurl.com/5udm2ufy
%
% According to TikZ.net
%
\begin{document}
%
\tdplotsetmaincoords{80}{120}
%
\begin{tikzpicture}[tdplot_main_coords]
% Parametric equations of the curve (spherical helix)
\tikzmath{function equis(\t) {return \a*sin(\t/(2.0*\c) r)*cos(\t r);};}
\tikzmath{function ye(\t) {return \a*sin(\t/(2.0*\c) r)*sin(\t r);};}
\tikzmath{function zeta(\t) {return \a*cos(\t/(2.0*\c) r);};}
% Values to indicate the domain of the graph
\pgfmathsetmacro{\ti}{-0.5*pi+pi/6.0}
\pgfmathsetmacro{\tf}{0.5*pi+pi/6.0}
\pgfmathsetmacro{\tm}{0.5*pi+pi/6.0}
\pgfmathsetmacro{\tn}{1.5*pi+pi/6.0}
\pgfmathsetmacro{\a}{2.5}
\pgfmathsetmacro{\b}{\a}
\pgfmathsetmacro{\c}{5.0}
\pgfmathsetmacro{\r}{sqrt(\a*\a+\b*\b)}
\pgfmathsetmacro{\vueltas}{10.0}
\pgfmathsetmacro{\factor}{10.0}
\pgfmathsetmacro{\ejez}{\a+0.5}
% Graph of the curve (back)
\foreach \n in {0,2,4}{
\pgfmathsetmacro{\ti}{0.5*pi+\n*pi+pi/6.0}
\pgfmathsetmacro{\tf}{1.5*pi+\n*pi+pi/6.0}
\draw[red,thick] plot[domain=\ti:\tf,smooth,variable=\t,samples=50] ({equis(\t)},{ye(\t)},{zeta(\t)});
}
\foreach \n in {0,2,4,6}{
\draw[red,thick] plot[domain=\tm:\tn,smooth,variable=\t,samples=50] ({equis(\t*\n)},{ye(\t*\n)},{zeta(\t*\n)});
}
\draw[red,thick] plot[domain=8.5*pi:10*pi,smooth,variable=\t,samples=50] ({equis(\t)},{ye(\t)},{zeta(\t)});
% Coordinate axis
\draw[thick] (-\a-0.25,0,0) -- (\a,0,0); % $x$ axis
\draw[thick] (0,-\b-0.25,0) -- (0,\b,0); % $y$ axis
\draw[thick,->] (0,0,-\ejez) -- (0,0,\ejez) node[above] {$z$}; % $z axis$
% A sphere
\shade[ball color=cyan,opacity=0.35] (0,0) circle (\a cm);
% Graph of the curve (front)
\pgfmathsetmacro{\tf}{0.5*pi+pi/6.0}
\draw[red,thick] plot[domain=0:\tf,smooth,variable=\t,samples=100] ({equis(\t)},{ye(\t)},{zeta(\t)});
%
\foreach \n in {2,4,6,8}{
\pgfmathsetmacro{\ti}{-0.5*pi+\n*pi+pi/6.0}
\pgfmathsetmacro{\tf}{0.5*pi+\n*pi+pi/6.0}
\draw[red,thick] plot[domain=\ti:\tf,smooth,variable=\t,samples=50] ({equis(\t)},{ye(\t)},{zeta(\t)});
}
%
\draw[thick,->] (\a,0,0) -- (\a+2.5,0,0) node[below left] {$x$}; % $x$ axis
\draw[thick,->] (0,\b,0) -- (0,\b+0.75,0) node[right] {$y$}; % $y$ axis
\end{tikzpicture}
%
\end{document}