8

I have tried the following tikz-pgf code to draw the stereographic projection:


\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}[scale=3]

% Sphere (circle in 2D projection)
\draw[thick] (0,0) circle (1);

% Equator ellipse 
\draw[thick,dashed] (-1,0) arc[start angle=180,end angle=360,x radius=1,y radius=0.25];
\draw[thick] (1,0) arc[start angle=0,end angle=180,x radius=1,y radius=0.25];

% North pole N
\fill (0,1) circle (0.02) node[above] {$N=(0,0,1)$};

% Center O
\node at (0,-0.05) {$O$};

% Point P on the sphere
\coordinate (Z) at (0.5,0.5);
\fill (Z) circle (0.015) node[right] {$P=(\xi, \eta, \zeta)$};

% Horizontal plane
\draw[thick] (-1.6,-0.35) -- (2.2,-0.35);
\draw[thick] (-1.6,-0.9) -- (2.2,-0.9);
\draw[thick] (-1.6,-0.35) -- (-1.6,-0.9);
\draw[thick] (2.2,-0.35) -- (2.2,-0.9);

%Horizontal line
\draw[->] (0,1) -- (0.8,1);
% line from N to P and P to z
\draw[thick, dotted] (0,1) -- (0.5,0.5);
\draw[thick] (0.5,0.5) -- (1.4,-0.5);

% Intersection point on plane
\coordinate (P) at (1.4,-0.5);
\fill (P) circle (0.015);
\node[below right] at (P) {$z=(x,y,0)$};

% Infinity symbol
\node at (1,1) {$\infty$};

% Equation label
\node at (2.1,0.6) {$x_1^2+x_2^2+x_3^2=1$};

\end{tikzpicture}
\end{document}

I got the following figure:

enter image description here

I want to create a 3D animation or gif where I want to show that the straight line joining the point N=(0,0,1) and point z=(x,y,0) tends to become horizontal as as the point z(x,y,0) moves away to the right.

Or I want to create a gif showing that if z=(x,y,0) in the plane moves away to the right towards infinity, the point P approaches to the north pole N(0,0,1).

Remark: I put dotted line from N to P because this segment lies inside the sphere. And my graph is not quite perfect as the plane will lie along the equator, which is not in my case.

Thanks

18
  • I think even so: The straight line joining the point (0,0,1) to a point P(x,y,0) tends toward a horizontal direction as P moves farther away from the origin. Commented 2 days ago
  • You want o do must we drawing for you? Commented 2 days ago
  • 2
    I can answer this, but I'd much prefer it if you posted an attempt of your own first. I actually already made the gif. Commented 2 days ago
  • The diagram provided in the question is objectively incorrect in terms of its positioning of the north pole. When you are looking down on a sphere, the north pole should come out at you. Commented 2 days ago
  • @Jasper, see my edit, the reason of being unable to show my primary effort Commented 2 days ago

1 Answer 1

10

I threw this together pretty quickly, The idea is that the inverse stereographic projection of a line always is a circle which intersects the north pole.

This is tikz, so it will not handle large numbers, nor will it compute heavy duty calculations fast.

I would recommend doing the math in lua, and outputting to something like tikz or metapost.

This is my best way to do it now, but when I develop better lua infrastructure, then this will be obsolete. For instance, there is no perspective, and we cannot set an arbitrary camera position.

Just to help you get started:

\documentclass[
    tikz
    ,border = 3.14mm
]{standalone}
\usetikzlibrary{arrows.meta}
\usepackage{tikz-3dplot}
% #1  - x
% #2  - y
% returns xi
\pgfmathdeclarefunction{inversestereographicprojectionxi}{2}{%
    \pgfmathparse{2*#1/(1+(#1)^2+(#2)^2)}%
}
% #1  - x
% #2  - y
% returns eta
\pgfmathdeclarefunction{inversestereographicprojectioneta}{2}{%
    \pgfmathparse{2*#2/(1+(#1)^2+(#2)^2)}%
}
% #1  - x
% #2  - y
% returns zeta
\pgfmathdeclarefunction{inversestereographicprojectionzeta}{2}{%
    \pgfmathparse{(-1+(#1)^2+(#2)^2)/(1+(#1)^2+(#2)^2)}%
}
\begin{document}
    \foreach \y in {1,...,24} { 
    \pgfmathsetmacro{\azimuth}{100}
    \pgfmathsetmacro{\elevation}{30}
    \pgfmathsetmacro{\x}{1.5}
    \pgfmathsetmacro{\y}{\y}
    \tdplotsetmaincoords{90-\elevation}{\azimuth}
    \begin{tikzpicture}[tdplot_main_coords,very thin,scale = 2]
        \useasboundingbox (-3,-3) rectangle (3,3);
        % x, y and z axes (pre-clip)
        \draw[-latex] 
            (-2.5,0,0) -- (2.5,0,0)
            node[pos=1,below] 
            {$\scriptstyle x,\xi,\mbox{\scriptsize Re}(z)$};
        \draw[-latex] 
            (0,-1.5,0) -- (0,1.5,0)
            node[pos=1,below] 
            {$\scriptstyle y,\eta,\mbox{\scriptsize Im}(z)$};
        \draw[-latex] 
            (0,0,-1.5) -- (0,0,1.5);
        \begin{scope}
            % clip and blank out sphere
            \clip[
                tdplot_screen_coords
                ,postaction = {
                    %tdplot_screen_coords
                    ,fill
                    ,white
                }
            ] (0,0) circle [radius = {1}];
            % x, y and z axes (post-clip)
            \draw[densely dashed] 
                (-2.5,0,0) -- (1,0,0);
            \draw[densely dashed] 
                (0,-1.5,0) -- (0,1,0);
            \draw[densely dashed] 
                (0,0,-1.5) -- (0,0,1);
            % outer circle
            \draw[tdplot_screen_coords]
                (0,0) circle [radius = {1}];
            \draw[densely dashed]
                (\azimuth:1) arc [
                    start angle = {\azimuth}
                    ,end angle = {\azimuth+180}
                    ,radius = {1}
                ];
            \draw (\azimuth:1) arc [
                    start angle = {\azimuth}
                    ,end angle = {\azimuth-180}
                    ,radius = {1}
                ];
                % origin
                \coordinate (O) at (0,0);
                % point on sphere
                \coordinate (P') at 
                    (
                        {inversestereographicprojectionxi(\x,\y)}
                        ,{inversestereographicprojectioneta(\x,\y)}
                        ,{inversestereographicprojectionzeta(\x,\y)}
                    )
                ;
                % stereographic projection 
                % of point on sphere
                \coordinate (P) at (\x,\y);
                % north pole
                \coordinate (N) at (0,0,1);
                % constructions which don't exceed the clip
                \draw[densely dashed,domain = -20:20,variable = \t,samples=100] plot (
                    {inversestereographicprojectionxi(\x,\t)}
                    ,{inversestereographicprojectioneta(\x,\t)}
                    ,{inversestereographicprojectionzeta(\x,\t)}
                ) -- cycle;
                \draw 
                    (N) -- (0,0,1.5)
                    (1,0,0) -- (2.5,0,0)
                    (0,1,0) -- (0,1.5,0)
                ;
        \end{scope}
        % constructions which exceed the clip
        \draw 
            (N) -- (P)
        ;
        % points
        \pgfmathsetmacro{\pointradius}{0.025}
        \begin{scope}[tdplot_screen_coords]
            \fill 
                (P') circle[radius = \pointradius]
                node[above right]{$\scriptstyle P$};
            \fill 
                (P) circle[radius = \pointradius]
                node[right]{$\scriptstyle z$};
            \fill 
                (N) circle[radius = \pointradius]
                node[above left]{$\scriptstyle N$};
        \end{scope}
    \end{tikzpicture}
    }
\end{document}

I will attach the gif, but I sincerely recommend that you play around with it yourself and make any aesthetic improvements that you see fit. This is a conceptual proof-of-concept construct, and could definitely be improved for formal teaching. I would call it "good enough" as is, but it is not what I would produce if I were going all in.

The gif also uses a low dpi and is a bit choppy due to only taking 24 samples. I just don't want to sell it as something it's not, hence my heavy disclaimer here.

output

5
  • Thanks. Could you attach the gif please? I need it urgently as I will show it to my students and explain the stereographic projection Commented 2 days ago
  • @Learner Use it at your own risk. I intended for this answer to be a conceptual display of how one might achieve the kinds of trajectories found in a stereographic projection. It is not by any means a polished diagram, nor is it polished code. I would have polished it more, but I am disinclined to since the lua infrastructure to improve on it will soon be complete. Commented 2 days ago
  • Thanks. It is perfect, but how to slow the animation, as it quite faster. Also you can add other gifs, which might also be worthy for visualization. I will teach theoretical part, with the visualization. Don't worry about it. Commented 2 days ago
  • @Learner If you slow it down, it will go too slow at the end. What you'd probably like more would be to parameterize the inscribed circle, and then move along it and take the stereographic projection of that. I know you're in a rush, but it's better to teach a man to fish. If you want to do this, I suggest you map a line onto the sphere, find the centre and radius of its map (it is a circle through the north pole), then parameterize it in terms of cosine and sine, then use a rotation matrix to move it into position. Commented 2 days ago
  • It was so helpful, my students understood stereographic projection and enjoyed your drawn picture Commented 2 days ago

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.