# 3d Image using tikz?

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 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.

\documentclass{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=0.25]
\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(17,-0.8){R}
\tkzDefPoint(-20,-15){S1}  \tkzDefPoint(-5, 15){S2}
\tkzDefPoint( 12, 20){S3}  \tkzDefPoint(-2,-10){S4}
\tkzInterLL(E,D)(S1,S2) \tkzGetPoint{T1}
\tkzDrawPolygon[color=white,fill=blue!30!white,opacity=0.7](S1,S2,S3,S4)
\tkzDrawCircle[color=red!70!black,ball color=red](M,E)
\begin{scope}[shift=(R)]
\tkzDefPoint(-20,-15){S5}  \tkzDefPoint(-5, 15){S6}
\tkzDefPoint( 12, 20){S7}  \tkzDefPoint(-2,-10){S8}
\end{scope}
\tkzDrawSegment[dashed](T1,E)
\tkzDrawPolygon[color=white,fill=blue!50!white,opacity=0.7](S5,S6,S7,S8)
\tkzDrawPoints[fill=black](P,D,E) \tkzLabelPoints(P,D,E)
\tkzLabelPoint[below left](S3){\Large $\alpha$} \tkzLabelPoint[below left](S7){\Large $\beta$}
\end{tikzpicture}
\end{document}


Which produces 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?

-
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

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

\documentclass{article}
\usepackage[pdf]{pstricks}% delete [pdf]  for xelatex
\usepackage{pst-solides3d}

\begin{document}
\begin{pspicture}[solidmemory](-5,-6)(3,3)
\psset{viewpoint=50 -110 110 rtp2xyz,Decran=50,lightsrc=80 20 50}
\axesIIID(3,3,6)
\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]
\end{pspicture}

\end{document}


and the same with

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


-

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

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}[x={(0.966cm,0.259cm)},y={(-0.966cm,0.259cm)},z={(0.259cm,0.966cm)}]
\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);

\begin{scope}
\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);
\end{scope}

\fill[opacity=0.5,blue] (0,3,0) -- (5,3,0) -- (5,3,5) -- (0,3,5) -- cycle;
\fill[opacity=0.5,blue] (0,0,0) -- (5,0,0) -- (5,0,5) -- (0,0,5) -- cycle;

\begin{scope}
\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);
\end{scope}

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

\end{tikzpicture}

\end{document}


-
This looks very nice! –  mrf Jul 2 '12 at 15:20