So, I'm new to using latex and I need to draw some figures, specifically spheres and arcs and how to label endpoints.
[Tex/LaTex] How to draw spheres and arcs on a sphere on latex
tikz-pgf
Related Solutions
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`.
For question 1, you can use markings
:
reset arc/.style = {
decoration={markings,mark=at position #1 with {
\draw (-2pt,-2pt) -- (2pt,2pt);
\draw (2pt,-2pt) -- (-2pt,2pt);
}
},
postaction={decorate,draw}},
And for second, you have to declare a coordinate in the middle:
\draw[Dash] (a) -> (c) coordinate[midway] (d);
And then use that coordinate (d) as in
\draw [Snake] (d) -- +(-1cm,0);
And the styles will be:
Dash/.style={dashed,
-latex
},
Snake/.style={
decoration={snake, amplitude=+2pt, segment length=+2pt},
decorate
},
Full code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing, decorations.markings}
\tikzset{
reset arc/.style = {
decoration={markings,mark=at position #1 with {
\draw (-2pt,-2pt) -- (2pt,2pt);
\draw (2pt,-2pt) -- (-2pt,2pt);
}
},
postaction={decorate,draw}},
Dash/.style={dashed,
-latex
},
Snake/.style={
decoration={snake, amplitude=+2pt, segment length=+2pt},
decorate
},
}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (1,0);
\coordinate (c) at (0,1);
\draw[reset arc=.9] (a) -- (b) ;
\draw[Dash] (a) -> (c) coordinate[midway] (d);
\draw [Snake] (d) -- +(-1cm,0);
\end{tikzpicture}
\end{document}
Best Answer
You can have a nice starting point in
Spherical and cartesian grids
by Tomasz M. Trzeciak, inTeXample.net
; below I reproduce part of the original code:An animation obtained using
beamer
overlays and the code above: