add tag
Anonymous 1123
I am trying to draw stereographic projection of a circle on a plane [like this](https://tex.stackexchange.com/questions/238258/stereographic-projection-of-a-circle-to-a-plane-in-asymptote). I tried
```
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=100,theta=70},line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},declare function={R=2;a=5;myphi=-30; mytheta =60;myphi1= 50; mytheta1 =40;myphi2= 70; mytheta2 =-50;}] 
	\path
	(0,0,0) coordinate (O)
	(0,0,R) coordinate (S)
	(0,0,-R) coordinate (S')
	({R*cos(myphi)*sin(mytheta)},{R*sin(myphi)*sin(mytheta)},{R*cos(mytheta)}) coordinate (M)
	
	({R*cos(myphi1)*sin(mytheta1)},{R*sin(myphi1)*sin(mytheta1)},{R*cos(mytheta1)}) coordinate (N)
	
	({R*cos(myphi2)*sin(mytheta2)},{R*sin(myphi2)*sin(mytheta2)},{R*cos(mytheta2)}) coordinate (P)
	;
	\path [save named
	path=sph,3d/screen coords] (O) circle[radius=R];
	
\path[3d/line through={(S) and (M) named lSM}];

\path[3d/line through={(S) and (N) named lSN}];

\path[3d/line through={(S) and (P) named lSP}];

\path[3d/plane with normal={(0,0,1) through (O) named plane}];

\path[overlay][3d/intersection of={lSM with plane}] coordinate (I);
\path[overlay][3d/intersection of={lSN with plane}] coordinate (J);

\path[overlay][3d/intersection of={lSP with plane}] coordinate (K);

	\draw[3d/hidden] (S) -- (S');
	\begin{scope}[canvas is xy plane at z=0]
		\path [shift={(S')}, save named path=bplane] (-a,-a) rectangle (a,a);
	\end{scope}

\path[3d/plane through={(M) and (N) and (P) named pMNP}];
\path[3d/project={(O) on pMNP}] coordinate (X);

\pgfmathsetmacro{\myR}{sqrt(TD("(X)-(M)o(X)-(M)"))} ;

\pic{3d/circle on sphere={R=R,C={(O)}, P={(X)}}};

\path foreach \p/\g in {O/180,S/90,S'/0,M/0,I/-90,N/0,P/0,K/0,J/0}
	{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\draw[3d/hidden] (S) -- (M) (S) -- (N) (S) -- (P);
\draw[3d/visible] (M) -- (I) (N) -- (J) (P) -- (K); 

\path pic{3d circle through 3 points={%
		A={(K)},B={(I)},C={(J)},center name=T}};
\tikzset{3d/draw ordered paths={bplane,sph}}
\end{tikzpicture}
\end{document} 
```
![ScreenHunter 224.png](/image?hash=fdd4aa70bffcd6e381e926717ecaf6a746dbd2911e3a6512a5c488da787c0dc2)

I  do know how to choose the points `P, M, N` on spheres to get a nice view, And my projection seems  incorrect.
How to draw stereographic projection of a circle on a plane correctly?


Top Answer
user 3.14159
I think that the picture you are referring to is not truly a [stereographic projection](https://en.wikipedia.org/wiki/Stereographic_projection). Usually a stereographic projection projects on the equatorial plane whereas your picture seems to project on a plane that touches the sphere at the south pole. Yet you can compute the intersections via `3dtools`. This code maps a bunch of points and connects them via a smooth curve, which appears to be a circle.
```
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=80,theta=70},
	line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},
	declare function={R=1.25;a=5;
	mytheta1=12;myphi1=17;mytheta2=10;myphi2=27;mytheta3=17;myphi3=35;}] 
 \path
	(0,0,0) coordinate (O)
	(0,0,R) coordinate (S)
	(0,0,-R) coordinate (S')
	foreach \X in {1,2,3}
	{({R*cos(myphi\X)*cos(mytheta\X)},{R*sin(myphi\X)*cos(mytheta\X)},{R*sin(mytheta\X)})
	 coordinate[c] (P_\X)};
 \path [save named path=sph,3d/screen coords] (O) circle[radius=R];
 \path[3d/plane with normal={(0,0,1) through (S') named plane}];
 \foreach \X in {1,2,3} 	
 {\tikzset{3d/line through={(S) and (P_\X) named lSP\X}}
 \path[overlay][3d/intersection of={plane with lSP\X}] coordinate[c] (I_\X)
 (P_\X) edge[3d/hidden] (S) edge[3d/visible] (I_\X);
 } 
 \draw[3d/hidden] (S) -- (S');
 \begin{scope}[canvas is xy plane at z=0]
  \path [shift={(S')}, save named path=bplane] (-a,-a) rectangle (a,a);
 \end{scope}
 \path pic[draw=none]{3d circle through 3 points={A={(P_1)},B={(P_2)},C={(P_3)},
 	center name=M}}; 
 \pgfmathsetmacro{\myex}{TDunit("(P_1)-(M)")}		
 \pgfmathsetmacro{\myey}{TDunit("(\myex)x(M)")}		
 \pgfmathsetmacro{\myr}{sqrt(TD("(P_1)-(M)o(P_1)-(M)"))}
 \path foreach \X [count=\Y] in {0,10,...,350}
  {[3d coordinate={(p\Y)={(M)+[\myr*cos(\X)]*(\myex)+[\myr*sin(\X)]*(\myey)}}]};
 \foreach \X in {1,...,35} 	
 {\tikzset{3d/line through={(S) and (p\X) named lSp\X}}
 \path[overlay][3d/intersection of={plane with lSp\X}] coordinate (i\X);
 } 
 \draw[blue,thick] plot[samples at={1,...,35},smooth cycle] (i\x);  
 \pgfmathsetmacro{\coordsM}{TD("(M)")}	
 \path pic{3d/circle on sphere={R=R,C={(O)},P={(M)}}};	
 \path pic{3d/circle on sphere={R=R,C={(O)},P={(O)},n={(0,0,1)}}};	
 \path[dashed] pic{3d circle through 3 points={A={(I_1)},B={(I_2)},C={(I_3)},
 	center name=M'}}; 
 \tikzset{3d/draw ordered paths={bplane,sph}}
\end{tikzpicture}
\end{document}   
```
![Screen Shot 2021-06-07 at 3.50.16 PM.png](/image?hash=f8cd7f347df893ceb1802fd27364105eafe7f9356f7bfa085642d1c5ac863ff9)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.