2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-19 11:38:05 +02:00

added sphere example

This commit is contained in:
Martin Thoma 2013-07-02 15:47:01 +02:00
parent 5279c340d6
commit 85e029236c
4 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,35 @@
SOURCE = sphere-sphere
DELAY = 80
DENSITY = 300
WIDTH = 512
make:
latexmk -pdf $(SOURCE).tex
make clean
clean:
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot *.dvi *.ps *.pre *.fls *.fdb_latexmk *.asy sphere-sphere-1.tex
gif:
pdfcrop $(SOURCE).pdf
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
make clean
png:
make
make svg
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
transparentGif:
convert $(SOURCE).pdf -transparent white result.gif
make clean
svg:
make
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
pdf2svg $(SOURCE).pdf $(SOURCE).svg
# Necessary, as pdf2svg does not always create valid svgs:
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg
inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg
rm $(SOURCE)2.svg

View file

@ -0,0 +1,9 @@
This is an example from `pst-solides3d` documentation.
Compiled example
----------------
![Example](sphere-sphere.png)
Credits
-------
Thanks to [g.kov](http://tex.stackexchange.com/users/27243/g-kov) ([answer](http://tex.stackexchange.com/a/121900/5645))

View file

@ -0,0 +1,4 @@
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");

View file

@ -0,0 +1,53 @@
\documentclass{article}
\usepackage{lmodern}
\usepackage[inline]{asymptote}
\begin{document}
\begin{figure}
\begin{asy}
settings.prc=false;
settings.render=0;
import graph3;
currentprojection=orthographic(camera=(150,900,412),up=(-0.4,-0.7,1.4),target=(100,111,1),zoom=0.5);
currentlight=nolight;
size(300);size3(300);
real r1=162;
real r2=100;
triple v1=(0,0,0);
triple v2=(250,0,0);
// from http://mathworld.wolfram.com/Sphere-SphereIntersection.html :
real d=arclength(v1--v2); // distance between v1,v2
real a=1/2/d*sqrt((2*d*r1)^2-(d^2-r2^2+r1^2)^2);
triple P=(sqrt(r1^2-a^2),0,-a);
triple fs1(pair t){
return v1+r1*(cos(t.x)*sin(t.y),sin(t.x)*sin(t.y),cos(t.y));
}
triple fs2(pair t){
return v2+r2*(cos(t.x)*sin(t.y),sin(t.x)*sin(t.y),cos(t.y));
}
surface s1=surface(fs1,(0,0),(2pi,pi),16,Spline);
surface s2=surface(fs2,(0,0),(2pi,pi),16,Spline);
draw(s1
,darkgreen+opacity(0.2)
,render(compression=Low,merge=true)
);
draw(s2
,darkblue+opacity(0.2)
,render(compression=Low,merge=true)
);
dot(v1); label("$V_1$",v1,-X+Z);
dot(v2); label("$V_2$",v2,-X+Z);
dot(P); label("$P$",P,-X-Z);
\end{asy}
\end{figure}
\end{document}