18

Does anyone know how to draw spherical arcs and spherical triangles using LaTeX?

  • A package like »pst-3dplot« or »tikz-3dplot« could help here. – Thorsten Donig Aug 25 '13 at 8:49
  • ePiX has built-ins for this, if you don't mind using external software. – user86418 Aug 25 '13 at 11:46
  • You can fake it in picture mode by drawing all the "straight lines" using arcs. Getting to look right won't be easy. – John Kormylo Aug 25 '13 at 14:33
  • 1
    parametrize them and use pgfplots or PSTricks? – cmhughes Aug 25 '13 at 16:05
  • I think this example gives a good overview of all cases of spherical coordinates with tikz-3dplot: texample.net/tikz/examples/the-3dplot-package – Henri Menke Aug 25 '13 at 20:33
17

enter image description here

Here is MWE using Asymptote 3D drawing:

% sphtri.tex:
\documentclass{article}
\usepackage[inline]{asymptote}
\usepackage{lmodern}

\begin{document}
\begin{figure}
\centering
\begin{asy}
settings.prc=false;
settings.tex="pdflatex";
settings.render=0;

import three;
size(100); size3(100);

currentprojection=orthographic(
camera=(5.4290316601351,2.94352790610013,1.1108527434919),up=Z,target=O,zoom=0.7);
real r=1;

triple A,B,C;
A=dir(60.0,20.0);
B=dir(40.0,40.0);
C=dir(80.0,80.0);

guide3 AB=arc(O,A,B,CCW);
guide3 BC=arc(O,B,C,CCW);
guide3 CA=arc(O,C,A,CCW);

radialshade(project(circle((0,0,0),1
,currentprojection.camera-currentprojection.target))
,rgb(0.79,0.79,0.85), project(O), 1.0
,rgb(0.99,0.99,0.85), project(O), 0.2
);

guide3 g=AB--BC--CA--cycle;
fill(project(g),rgb(1,1,0.8));

draw(arc(O,A,B,CCW),red+1bp);
draw(arc(O,B,C,CCW),olive+1bp);
draw(arc(O,C,A,CCW),blue+1bp);

pen alphaPen=red;
pen betaPen=darkgreen;
pen gammaPen=blue;

void markAngle(string lab,triple v, guide3 gright, guide3 gleft, real arcdist, pen arcpen=currentpen){
  triple t,s;
  t=arcpoint(gright,arcdist); 
  s=arcpoint(gleft,arcdist);
  draw(arc(v,t,s,cross(t-v,s-v),CCW),arcpen);
  label("$"+lab+"$",(v+t+s)/3,arcpen);
}

real ra,rb,rg; 
ra=0.17; rb=0.21; rg=0.4;
markAngle("\alpha",A,reverse(CA),AB,ra,alphaPen);
markAngle("\beta",B,reverse(AB),BC,rb,betaPen);
markAngle("\gamma",C,reverse(BC),CA,rg,gammaPen);

dot(A,red); dot(B,olive); dot(C,blue);

label("$A$",project(A),SW);
label("$B$",project(B),N);
label("$C$",project(C),SE);    
\end{asy}
\caption{Spherical arcs and spherical triangles}
\end{figure}
\end{document}
% 
% To process it with `latexmk`, create file `latexmkrc`:
% 
%     sub asy {return system("asy '$_[0]'");}
%     add_cus_dep("asy","eps",0,"asy");
%     add_cus_dep("asy","pdf",0,"asy");
%     add_cus_dep("asy","tex",0,"asy");
% 
% and run `latexmk -pdf sphtri.tex`.
13
\documentclass{article}
\usepackage{pst-3dplot}
\begin{document}

\def\radius{4 }\def\PhiI{20 }\def\PhiII{50 }
\def\RadIs{\radius \PhiI sin mul}
\def\RadIc{\radius \PhiI cos mul}

\begin{pspicture}(-4,-4)(4,5)
  \psset{Alpha=45,Beta=30,linestyle=dashed}
  \pstThreeDSphere[linecolor=black!15](0,0,0){4}
  \pstThreeDCoor[linestyle=solid,xMin=-5,xMax=5,yMax=5,zMax=5,IIIDticks]
  \pstThreeDEllipse(\RadIs,0,0)(0,\RadIc,0)(0,0,\RadIc)
  \pstThreeDEllipse[SphericalCoor](0,0,0)(\radius,90,\PhiI)(\radius,0,0)
  \pstThreeDEllipse[SphericalCoor](0,0,0)(\radius,90,\PhiII)(\radius,0,0)
%
  \psset{linecolor=blue,arrows=->,arrowscale=2,linewidth=1.5pt,linestyle=solid}
    \pstThreeDEllipse[SphericalCoor,beginAngle=\PhiI,endAngle=90](0,0,0)(\radius,90,\PhiII)(\radius,0,0)
    \pstThreeDEllipse[SphericalCoor,beginAngle=90,endAngle=\PhiI](0,0,0)(\radius,90,\PhiI)(\radius,0,0)
    \pstThreeDEllipse[beginAngle=\PhiI,endAngle=\PhiII](\RadIs,0,0)(0,\RadIc,0)(0,0,\RadIc)
  \pscustom[fillstyle=solid,fillcolor=blue!40,opacity=0.4]{
    \pstThreeDEllipse[SphericalCoor,beginAngle=\PhiI,endAngle=90](0,0,0)(\radius,90,\PhiII)(\radius,0,0)
    \pstThreeDEllipse[SphericalCoor,beginAngle=90,endAngle=\PhiI](0,0,0)(\radius,90,\PhiI)(\radius,0,0)
    \pstThreeDEllipse[beginAngle=\PhiI,endAngle=\PhiII](\RadIs,0,0)(0,\RadIc,0)(0,0,\RadIc)
  }
\end{pspicture}

\end{document}

enter image description here

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.