3

I'm learning to use asymptote. I'm trying to draw an intersection between a sphere and a plane. Below I post the code. There do not seem to be any errors in the concept: I draw the sphere, the back and front equator and the horizontal plane. Why does the equator in not on the horizontal plane?

The code:

import solids;
import graph3;
import three;
size(5cm);

currentprojection=orthographic(10,5,2);
currentlight=Headlamp;
real t = 1;
triple p0 =(t,t,0), p1=(-t,t,0), p2 = (-t,t,0), p3 = (t,-t,0);
nslice=4*nslice;
revolution b=sphere(O,1);
draw(surface(b),paleblue+opacity(.5));
skeleton s;
b.transverse(s,reltime(b.g,0.5),P=currentprojection);
draw(s.transverse.back,yellow);
draw(s.transverse.front,yellow);
draw(surface(p0--p1--p2--p3--cycle),brown);
3

You are doing everything right except that you forgot to flip a sign in p2.

\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=AsyPlot}
import solids;
import graph3;
import three;
size(5cm);

currentprojection=orthographic(10,5,2);
currentlight=Headlamp;
real t = 1;
triple p0 =(t,t,0), p1=(-t,t,0), p2 = (-t,-t,0), p3 = (t,-t,0); //adjusted p2
nslice=4*nslice;
revolution b=sphere(O,1);
draw(surface(b),paleblue+opacity(.5));
skeleton s;
b.transverse(s,reltime(b.g,0.5),P=currentprojection);
draw(s.transverse.back,yellow);
draw(s.transverse.front,yellow);
draw(surface(p0--p1--p2--p3--cycle),brown);
\end{asypicture}
\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.