# Project this triangle on surface of a sphere

I have the following triangle in TikZ MWE:

\documentclass[tikz]{standalone}
\usepackage{pgfplots,mathtools}
\usetikzlibrary{hapes,decorations.pathreplacing}
\usetikzlibrary{patterns}
\definecolor{RoyalAzure}{rgb}{0.0, 0.22, 0.66}

\begin{document}

\begin{tikzpicture}
\draw[pattern color=black!50!white,pattern=dots, line width=0.6pt] (0,0) -- (2,3.4641) -- (4,0)--cycle;
\end{tikzpicture}

\end{document}


that generates:

I would like to project this triangle to the surface of a sphere, much like this figure:

How can I do this?

The angles of the triangle on the sphere are 3 times 90 degrees whereas the angles of the triangle in the plane are 60 degrees each. Therefore I do not precisely understand what is meant by "project". If it is meant that the triangle on the sphere should also have three equal angles, you could do e.g.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{patterns,backgrounds}
\begin{document}
\tdplotsetmaincoords{70}{30}
\begin{tikzpicture}[tdplot_main_coords,declare function={R=pi;}]
\draw plot[variable=\x,domain=\tdplotmainphi-180:\tdplotmainphi,smooth]
({R*cos(\x)},{R*sin(\x)},0);
\draw[blue,pattern=dots,pattern color=blue]
plot[variable=\x,domain=90:00,smooth] (0,{-R*sin(\x)},{R*cos(\x)})
coordinate   (p1)
-- plot[variable=\x,domain=0:90,smooth] ({R*sin(\x)},0,{R*cos(\x)})
coordinate   (p2)
-- plot[variable=\x,domain=0:90,smooth] ({R*cos(\x)},{-R*sin(\x)},0)
coordinate   (p3);
\begin{scope}[on background layer]
\foreach \X in {1,2,3}
{ \draw[dashed] (O) -- (p\X); }
\end{scope}
\end{tikzpicture}
\end{document}


An alternative could be to use nonlinear transformations to project anything you want on a sphere. We have used this for the Christmas balls in this video (at a time in which the atmosphere were better...). However, when doing this, we run into the above-mentioned problem that the triangle has different angles on the sphere.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{patterns}
\usepgfmodule{nonlineartransformations}
\makeatletter
% from https://tex.stackexchange.com/a/434247/121799
\tikzdeclarecoordinatesystem{sphere}{
\tikz@scan@one@point\relax(#1)
\spheretransformation
}
%
\def\spheretransformation{% similar to the pgfmanual section 103.4.2
\pgfmathsincos@{\pgf@sys@tonumber\pgf@x}%
\pgfmathsetmacro{\relX}{\the\pgf@x/28.3465}%
\pgfmathsetmacro{\relY}{\the\pgf@y/28.3465}%min(max(
\pgf@x=\myx pt%
\pgf@y=\myy pt%
}
\makeatother
\begin{document}
\begin{tikzpicture}[pics/trian/.style={code={
\draw[pattern color=black!50!white,pattern=dots, line width=0.6pt] (0,0) -- (2,3.4641) -- (4,0)--cycle;}}]
\begin{scope}[xshift=-10cm]
\path (0,0) pic{trian};
\end{scope}
\begin{scope}[transform shape nonlinear=true]
\pgftransformnonlinear{\spheretransformation}
\pic[local bounding box=box1] at (0,0) {trian};
\end{scope}
\end{tikzpicture}
\end{document}


• In this case, I did only want a triangle with the same angles but on the surface of the sphere. I do have other examples where I want to perform a strict projection - but you have very helpfully included an example on how to do that too! Thank you. P.s. a lot of marmots in the video :D – Sid Apr 15 at 15:07
• For the first method you have, is it possible you could add the axes as in the image in the question? – Sid Apr 15 at 16:31
• @Sid Done....... – marmot Apr 15 at 18:06