In drawing sets of planes like the figure below
one frequently see solutions that involve drawing each visual piece of each plane in the order from the back to the front, like the code included here, and for another example see here (intersecting planes).
Question: Is it possible to draw the planes using 3D-coordinates and choose a viewpoint within TikZ, without having to calculate the view before hand?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{intersections}
\begin{document}
\pagecolor{blue!30}
\pagestyle{empty}
\begin{tikzpicture}[scale=1.6]
\definecolor{bg}{RGB}{246,202,203}
\coordinate (A) at (0.95,3.41);
\coordinate (B) at (1.95,0.23);
\coordinate (C) at (3.95,1.23);
\coordinate (D) at (2.95,4.41);
\coordinate (E) at (1.90,3.30);
\coordinate (F) at (0.25,0.45);
\coordinate (G) at (2.25,1.45);
\coordinate (H) at (3.90,4.30);
\coordinate (I) at (-0.2,1.80);
\coordinate (J) at (2.78,1.00);
\coordinate (K) at (4.78,2.00);
\coordinate (L) at (1.80,2.80);
\path[name path=AB] (A) -- (B);
\path[name path=CD] (C) -- (D);
\path[name path=EF] (E) -- (F);
\path[name path=IJ] (I) -- (J);
\path[name path=KL] (K) -- (L);
\path[name path=HG] (H) -- (G);
\path[name path=IL] (I) -- (L);
\path [name intersections={of=AB and EF,by=M}];
\path [name intersections={of=EF and IJ,by=N}];
\path [name intersections={of=AB and IJ,by=O}];
\path [name intersections={of=AB and IL,by=P}];
\path [name intersections={of=CD and KL,by=Q}];
\path [name intersections={of=CD and HG,by=R}];
\path [name intersections={of=KL and HG,by=S}];
\path[name path=NS] (N) -- (S);
\path[name path=FG] (F) -- (G);
\path [name intersections={of=NS and AB,by=T}];
\path [name intersections={of=FG and AB,by=U}];
\draw[thick, color=white, fill=bg] (A) -- (B) -- (C) -- (D) -- cycle;
%\draw[thick, color=white, fill=bg] (E) -- (F) -- (G) -- (H) -- cycle;
%\draw[thick, color=white, fill=bg] (I) -- (J) -- (K) -- (L) -- cycle;
\draw[thick, color=white, fill=gray!80] (P) -- (O) -- (I) -- cycle;
\draw[thick, color=white, fill=gray!80] (O) -- (J) -- (K) -- (Q) -- cycle;
\draw[thick, color=white, fill=gray!40] (H) -- (E) -- (M) -- (R) -- cycle;
\draw[thick, color=white, fill=gray!40] (M) -- (N) -- (T) -- cycle;
\draw[thick, color=white, fill=gray!40] (N) -- (F) -- (U) -- (O) -- cycle;
\end{tikzpicture}
\end{document}
tikz-3dplot
that highly simplifies drawings in 3D, but tikz essentially always draws the projection to the 2D paper. In your case, you can easily calculate the planes' lines of intersection and draw parts of the planes after each other.z buffer = sort
. It is an option fortikz
that may help put front faces on top. I use it withpfgplots
a lot.pgfplots
option - it is not part of standard PGF/TikZ. At least, unless there's an extension package or library which you're aware provides it? @ OP My understanding is Dux's understanding. You are asking about really handling 3D as 3D and PGF/TikZ doesn't do that. The best you can do is fake it - and, yes, that means that if you change perspective etc., you need to recalculate everything.z buffer=sort
is only part ofpgfplots
, not part oftikz
. Also, even withinpgfplots
, that option only helps graph individual functions, not sets of functions. So it helps draw an ellipsoid, keeping the "back" faces in the back, but it won't help draw the intersection of an ellipsoid and a plane, nor the intersections of three planes. (I tried, and fail.)Asymptote
is a viable option - very powerful and worth the learning curve.