I've made the following code:




\shade[ball color=red] (0,0,0) circle (2cm);
\fill[opacity=0.5,blue] (-3,0,1) -- (-1,2,1) -- (5,2,1) -- (3,0,1) -- cycle;



Which I've adapted from this post (thank you very much!). And which produces:

enter image description here

But I want to do is this:

enter image description here

Question: How could I do the intersection of the sphere with the plane?

  • Does it need to be "true" 3D? Or is it sufficient to look like it? The former is more difficult (especially with TikZ), the latter is way less flexible. – Tom Bombadil Dec 5 '15 at 2:32
  • It doesn't need to be true 3D. I just want it to look like if it was. ;) – francolino Dec 5 '15 at 2:34
  • it helps if the ellipse has the same aspect ration (width to height) at the parallelogram. – John Kormylo Dec 5 '15 at 4:13

Here's a solution with Asymptote:

plane and sphere

The code to produce it:



settings.outformat = "png";
settings.render = 8;
size(10cm, 0);  // Final image will be 10cm wide, unlimited height.
import three;   // Enable three-dimensional functionality.
currentprojection = orthographic(2,5,1);

draw(unitsphere, red);
draw(surface((-2,-2,0) -- (-2,2,0) -- (2,2,0) -- (2,-2,0) -- cycle), blue + opacity(0.5));



% file: foo.tex
% to compile: pdflatex --shell-escape foo
% For MikTeX users: Asymptote requires a separate program that cannot be installed
% by the package manager. You can get the installation file from
% https://sourceforge.net/projects/asymptote/files/2.35/
% (specifically, the file ending in setup.exe).

If you are using a relatively recent version of MacTeX (or, I assume, TeX Live), with a full installation, this should just work. If you are using MikTeX, you will need to install the Asymptote program as described in the comments after \end{document}.

  • Nice! Sorry I forgot to mention Asymptote. Probably one day I'll have a look at it. – Tom Bombadil Dec 5 '15 at 9:21
  • +1 for asypictureB – alfC Dec 5 '15 at 9:43

Here you have an idea for both: the "fake" 3D draws two planes, one "behind" the ball, and one "in front of". The 3D effect is achieved by cutting out a half ellipse. The "less fake" 3D approach uses pgfplots to first draw the lower hemisphere, then the surface, and then the upper hemisphere. Probably someone will upload a pstricks solution, as it is vastly superior at 3D stuff.


\documentclass[tikz, border=2mm]{standalone}


    \fill[blue!50!gray, opacity=0.7] (0,0) -- (5,0) -- (4,2) -- (1,2) -- cycle;
    \shade[ball color=red] (2.5,0) circle (1);
    \fill[blue!50!gray, opacity=0.7] (0,0) -- (1.5,0) arc (180:360:1 and 0.5) -- (5,0) -- (6,-2) -- (-1,-2) -- cycle;

    [   axis equal,
        hide axis,
        z buffer=sort,
        [   domain=0:360,
            y domain=0:180,
        ] ({sin(y)*cos(x)},{sin(y)*sin(x)},{cos(y)});
        [   domain=-2:2,
            y domain=-2:2,
        ] (x,y,0);
        [   domain=0:360,
            y domain=0:90,
        ] ({sin(y)*cos(x)},{sin(y)*sin(x)},{cos(y)});



enter image description here


Run with xelatex


\psset{viewpoint=50 0 10 rtp2xyz,Decran=70,lightsrc=80 20 70,
\psSolid[object=plan,definition=equation,args={[0 0 1 0]},
base=-3 3 -2 2,ngrid=20 20,fillcolor=red!30,name=B1]
\psSolid[object=sphere,r=1,fillcolor=cyan,ngrid=18 36,
\psSolid[object=fusion,base=B1_s C1,action=draw**]


enter image description here

  • I knew I could count on you to provide a pstricks solution :-) – Tom Bombadil Dec 5 '15 at 9:20

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.