sphere-sphere.tex 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. \documentclass{article}
  2. \usepackage{lmodern}
  3. \usepackage[inline]{asymptote}
  4. \begin{document}
  5. \begin{figure}
  6. \begin{asy}
  7. settings.prc=false;
  8. settings.render=0;
  9. import graph3;
  10. currentprojection=orthographic(camera=(150,900,412),up=(-0.4,-0.7,1.4),target=(100,111,1),zoom=0.5);
  11. currentlight=nolight;
  12. size(300);size3(300);
  13. real r1=162;
  14. real r2=100;
  15. triple v1=(0,0,0);
  16. triple v2=(250,0,0);
  17. // from http://mathworld.wolfram.com/Sphere-SphereIntersection.html :
  18. real d=arclength(v1--v2); // distance between v1,v2
  19. real a=1/2/d*sqrt((2*d*r1)^2-(d^2-r2^2+r1^2)^2);
  20. triple P=(sqrt(r1^2-a^2),0,-a);
  21. triple fs1(pair t){
  22. return v1+r1*(cos(t.x)*sin(t.y),sin(t.x)*sin(t.y),cos(t.y));
  23. }
  24. triple fs2(pair t){
  25. return v2+r2*(cos(t.x)*sin(t.y),sin(t.x)*sin(t.y),cos(t.y));
  26. }
  27. surface s1=surface(fs1,(0,0),(2pi,pi),16,Spline);
  28. surface s2=surface(fs2,(0,0),(2pi,pi),16,Spline);
  29. draw(s1
  30. ,darkgreen+opacity(0.2)
  31. ,render(compression=Low,merge=true)
  32. );
  33. draw(s2
  34. ,darkblue+opacity(0.2)
  35. ,render(compression=Low,merge=true)
  36. );
  37. dot(v1); label("$V_1$",v1,-X+Z);
  38. dot(v2); label("$V_2$",v2,-X+Z);
  39. dot(P); label("$P$",P,-X-Z);
  40. \end{asy}
  41. \end{figure}
  42. \end{document}