TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have attempted to draw a sphere between two planes that are defined as follows. a:= 2x - 2y + z + 2 = 0 and b:= 4x - 4y + 2z - 4 = 0 I know that the line is perpendicular to the two planes are l(5+2t,-1-2t,4+t). The sphere can be described like (x - 5/3)^2 + (y-5/3)^2 + (z-7/3)^2 = 1^2. So the image I am trying to create looks somewhat like this enter image description here Now is there any way in tikz to approach this in a good way? I know there is the PsTricks option, but I really need the pdflatex compability. Now I did give this a shoot, but it did not turn out great.

\tkzInit[xmin=-20,xmax=40,ymin=-20,ymax=20] \tkzClip
\tkzDefPoint(8,-2){E}  \tkzDefPoint(-2,2){D} 
\tkzDefMidPoint(E,D) \tkzGetPoint{M}
\tkzInterLC[R](E,D)(M,20 cm) \tkzGetPoints{P1}{P}
\tkzDefPoint(-20,-15){S1}  \tkzDefPoint(-5, 15){S2} 
\tkzDefPoint( 12, 20){S3}  \tkzDefPoint(-2,-10){S4}
\tkzInterLL(E,D)(S1,S2) \tkzGetPoint{T1}
\tkzDrawCircle[color=red!70!black,ball color=red](M,E)
\tkzDefPoint(-20,-15){S5}  \tkzDefPoint(-5, 15){S6} 
\tkzDefPoint( 12, 20){S7}  \tkzDefPoint(-2,-10){S8}
\tkzDrawLine[add=10 and 0](P,T1) 
\tkzDrawLine[add=0 and 10](E,P1) 
\tkzDrawPoints[fill=black](P,D,E) \tkzLabelPoints(P,D,E)
\tkzLabelPoint[below left](S3){\Large $\alpha$} \tkzLabelPoint[below left](S7){\Large $\beta$}

Which produces enter image description here Which is not quite what I want. As well as being a very hacky, and non 3d approach to the problem. Is there any decent way to approach making planes, and spheres in tikz?

share|improve this question
tkz-euclide is not the good tool to work with 3D. – Alain Matthes Jul 2 '12 at 5:11
I know, therefore I am asking for decent alternatives! But the people on this site always need a MWE therefore I included one.. – N3buchadnezzar Jul 2 '12 at 9:41
With the definition of your two planes you do not get parallel ones. Are the equations correct? – Herbert Jul 2 '12 at 9:43
I fixed the planes sorry about that. They should be parallel now. – N3buchadnezzar Jul 2 '12 at 14:25

You could set up your own axes and use scopes to restrict the lines:



\draw[->] (-2,-2,-2) -- node[fill=white] {x} ++ (2,0,0);
\draw[->] (-2,-2,-2) -- node[fill=white] {y} ++ (0,2,0);
\draw[->] (-2,-2,-2) -- node[fill=white] {z} ++ (0,0,2);

    \clip (0,3,0) -- (0,3,5) -- (0,10,5) -- (0,10,0) -- cycle;
    \draw[thick] (2.5,8,2.5) -- (2.5,3,2.5);

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

    \clip (0,0,0) -- (2.5,0,0) -- (2.5,0,5) -- (2.5,3,5) -- (0,3,5) -- (0,3,0) -- cycle;
    \draw[thick, dashed] (2.5,8,2.5) -- (2.5,0,2.5);

\draw[thick] (2.5,0,2.5) -- (2.5,-5,2.5);



enter image description here

share|improve this answer
This looks very nice! – mrf Jul 2 '12 at 15:20

I do not really understand what you exactly want to draw. However, here is an example with pst-solides3d which can handle hidden lines and surfaces. Run it with pdflatex -shell-escape or pdflatex -enable-write18 (for Windows) or with xelatex (in this case delete the [pdf] option of pstricks

\usepackage[pdf]{pstricks}% delete [pdf]  for xelatex

\psset{viewpoint=50 -110 110 rtp2xyz,Decran=50,lightsrc=80 20 50}
\psSolid[object=plan,definition=equation,args={[2 -2 1 -2]},base=-1 5 -3 4,
  ngrid=18 18,fillcolor=red!30,name=B1,action=none]
\psSolid[object=plan,definition=equation,args={[4 -4 2 4]},base=-2 5 0 6,
  ngrid=18 18,fillcolor=green!30,name=B2,action=none]
\psSolid[object=sphere,r=1,fillcolor=cyan,ngrid=18 18,name=C1,action=none](1.67,1.67,2.33)
\psSolid[object=fusion,base=B1_s B2_s C1]


enter image description here

and the same with

\psset{viewpoint=50 -100 110 rtp2xyz,Decran=70,lightsrc=80 20 70}

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.