How can I draw a Stereographic Projection using tikz?
I tried graph using manual TikZ, but I did not succeed.
Any help?
How can I draw a Stereographic Projection using tikz?
I tried graph using manual TikZ, but I did not succeed.
Any help?
This post is based on this post and makes use of a few more posts that are indicated in the code. I adjusted the code to come close to the screen shot you have posted.
stereox and so on. That is, if you change Px and Py (or Qx and Qy) the points on the sphere will change accordingly.Code and result:
\documentclass[tikz,border=3mm]{standalone}
\usepackage{dsfont}
% based on
% https://tex.stackexchange.com/a/38995/121799
% https://tex.stackexchange.com/a/76216
% https://tex.stackexchange.com/a/59168/194703
% https://tex.stackexchange.com/q/448920/194703
\makeatletter
\tikzset{
reuse path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\tikzset{even odd clip/.code={\pgfseteorule},
protect/.code={
\clip[overlay,even odd clip,reuse path=#1]
(current bounding box.south west) rectangle (current bounding box.north east)
;
}}
\makeatother
\usetikzlibrary{3d,arrows.meta,decorations.markings,perspective}
\tikzset{->-/.style={decoration={% https://tex.stackexchange.com/a/39282/194703
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}},
->-/.default=0.55}
\begin{document}
\begin{tikzpicture}[declare function={%
stereox(\x,\y)=2*\x/(1+\x*\x+\y*\y);%
stereoy(\x,\y)=2*\y/(1+\x*\x+\y*\y);%
stereoz(\x,\y)=(-1+\x*\x+\y*\y)/(1+\x*\x+\y*\y);
Px=1.75;Py=-1.5;Qx=-1.5;Qy=-1.25;amax=2.5;},scale=2.5,
line join=round,line cap=round,
dot/.style={circle,fill,inner sep=1pt},>={Stealth[length=1.2ex]}]
\pgfmathsetmacro{\myaz}{15}
\path[save path=\pathSphere] (0,0) circle[radius=1];
\begin{scope}[3d view={\myaz}{18}]
\draw (-amax,amax) -- (-amax,-amax) coordinate (bl) -- (amax,-amax)
coordinate (br)-- (amax,amax)
%node[above left]{$z=0$}
;
\begin{scope}
\tikzset{protect=\pathSphere}
\draw (-amax,amax) -- (amax,amax) node[below left,xshift=-2em]{$\mathds{C}$};
\end{scope}
\begin{scope}
\clip[reuse path=\pathSphere];
\draw[dashed] (-amax,amax) -- (amax,amax);
\end{scope}
\begin{scope}[canvas is xy plane at z=0]
\draw[dashed] (\myaz:1) arc[start angle=\myaz,end angle=\myaz+180,radius=1];
\draw (\myaz:1) arc[start angle=\myaz,end angle=\myaz-180,radius=1];
\path[save path=\pathPlane] (\myaz:amax) -- (\myaz+180:amax) --(bl) -- (br) -- cycle;
\begin{scope}
\clip[use path=\pathPlane];
\draw[dashed,use path=\pathSphere];
\end{scope}
\begin{scope}
\tikzset{protect=\pathPlane}
\draw[use path=\pathSphere];
\end{scope}
\end{scope}
\draw[->-=0.3] (Px,Py,0) node[dot,label=below:{$w$}](w){}
-- node[auto,pos=0.3,swap]{$\pi$} ({stereox(Px,Py)},{stereoy(Px,-1)},{stereoz(Px,Py)})
node[dot,label=below left:{$w^*$}](w*){};
\draw[->-] (Qx,Qy,0) node[dot,label=below:{$z$}](z){}
-- node[auto,pos=0.5]{$\pi$} ({stereox(Qx,Qy)},{stereoy(Qx,-1)},{stereoz(Qx,Qy)})
node[dot,label=below right:{$z^*$}](z*){};
\draw[dashed] (w*) -- (0,0,1) node[dot,label=above:{$\zeta$}](zeta){}
-- (z*) -- (w*);
\end{scope}
\end{tikzpicture}
\end{document}
Or a colorful version:
\documentclass[tikz,border=3mm]{standalone}
% based on
% https://tex.stackexchange.com/a/38995/121799
% https://tex.stackexchange.com/a/76216
% https://tex.stackexchange.com/a/59168/194703
% https://tex.stackexchange.com/q/448920/194703
\makeatletter
\tikzset{
reuse path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\tikzset{even odd clip/.code={\pgfseteorule},
protect/.code={
\clip[overlay,even odd clip,reuse path=#1]
(current bounding box.south west) rectangle (current bounding box.north east)
;
}}
\makeatother
\usetikzlibrary{3d,arrows.meta,decorations.markings,perspective}
\tikzset{->-/.style={decoration={% https://tex.stackexchange.com/a/39282/194703
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}},
->-/.default=0.55}
\begin{document}
\pgfmathsetmacro{\myaz}{15}
\begin{tikzpicture}[declare function={%
stereox(\x,\y)=2*\x/(1+\x*\x+\y*\y);%
stereoy(\x,\y)=2*\y/(1+\x*\x+\y*\y);%
stereoz(\x,\y)=(-1+\x*\x+\y*\y)/(1+\x*\x+\y*\y);
Px=1.75;Py=-1.5;Qx=-1.5;Qy=-1.25;amax=2.5;},scale=2.5,
line join=round,line cap=round,
dot/.style={circle,fill,inner sep=1pt},>={Stealth[length=1.2ex]}]
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\path[save path=\pathSphere,ball color=gray,fill opacity=0.6]
(0,0) circle[radius=1];
\begin{scope}[3d view={\myaz}{15}]
\draw (-amax,amax) -- (-amax,-amax) coordinate (bl) -- (amax,-amax)
coordinate (br)-- (amax,amax)
%node[above left]{$z=0$}
;
\begin{scope}
\tikzset{protect=\pathSphere}
\draw (-amax,amax) -- (amax,amax);
\end{scope}
\begin{scope}
\clip[reuse path=\pathSphere];
\draw[dashed] (-amax,amax) -- (amax,amax);
\end{scope}
\begin{scope}[canvas is xy plane at z=0]
\draw[dashed] (\myaz:1) arc[start angle=\myaz,end angle=\myaz+180,radius=1];
\draw (\myaz:1) arc[start angle=\myaz,end angle=\myaz-180,radius=1];
\path[save path=\pathPlane] (\myaz:amax) -- (\myaz+180:amax) --(bl) -- (br) -- cycle;
\begin{scope}
%\begin{pgfonlayer}{background}
\clip[use path=\pathPlane];
\draw[dashed,use path=\pathSphere];
%\end{pgfonlayer}
\end{scope}
\begin{scope}
\tikzset{protect=\pathPlane}
\draw[use path=\pathSphere];
\end{scope}
\begin{pgfonlayer}{background}
\fill[blue!30,fill opacity=0.6]
(\myaz:1) arc[start angle=\myaz,end angle=\myaz-180,radius=1]
-- (-amax,0) -- (-amax,amax) -- (amax,amax) -- (amax,0) -- cycle;
\end{pgfonlayer}
\fill[blue!30,fill opacity=0.6]
(\myaz:1) arc[start angle=\myaz,end angle=\myaz-180,radius=1]
-- (-amax,0) -- (-amax,-amax) -- (amax,-amax) -- (amax,0) -- cycle;
\end{scope}
\draw[->-=0.3] (Px,Py,0) node[dot,label=below:{$w$}](w){}
-- node[auto,pos=0.3,swap]{$\pi$} ({stereox(Px,Py)},{stereoy(Px,-1)},{stereoz(Px,Py)})
node[dot,label=below left:{$w^*$}](w*){};
\draw[->-] (Qx,Qy,0) node[dot,label=below:{$z$}](z){}
-- node[auto,pos=0.5]{$\pi$} ({stereox(Qx,Qy)},{stereoy(Qx,-1)},{stereoz(Qx,Qy)})
node[dot,label=below right:{$z^*$}](z*){};
\begin{pgfonlayer}{background}
\draw[dashed] (w*) -- (0,0,1) node[dot,label=above:{$\zeta$}](zeta){}
-- (z*) -- (w*);
\end{pgfonlayer}
\end{scope}
\end{tikzpicture}
\end{document}