I have the following triangle in TikZ MWE:

\definecolor{RoyalAzure}{rgb}{0.0, 0.22, 0.66}  


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


that generates:


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

Bloch sphere

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.

\begin{tikzpicture}[tdplot_main_coords,declare function={R=pi;}]
 \shade[tdplot_screen_coords,ball color=gray,opacity=0.5] (0,0) coordinate(O)
 \draw plot[variable=\x,domain=\tdplotmainphi-180:\tdplotmainphi,smooth]
 \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); }

enter image description here

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.

% from https://tex.stackexchange.com/a/434247/121799
\def\spheretransformation{% similar to the pgfmanual section 103.4.2
\pgf@x=\myx pt%
\pgf@y=\myy pt%
\draw[pattern color=black!50!white,pattern=dots, line width=0.6pt] (0,0) -- (2,3.4641) -- (4,0)--cycle;}}]
 \shade[ball color=red] (0,0) circle[radius=\Radius];
  \path (0,0) pic{trian};
 \begin{scope}[transform shape nonlinear=true]
  \pic[local bounding box=box1] at (0,0) {trian};

enter image description here

  • 1
    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 '19 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 '19 at 16:31
  • @Sid Done.......
    – user121799
    Apr 15 '19 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.