[Tex/LaTex] Drawing a circle on a non xy-plane with TikZ

3dcirclestikz-pgf

Say I'm drawing a 3D picture. Now I would like to draw a circle, perspectively correct, on the yz-plane, but TikZ does not seem to be capable of this. All one can do is drawing circles on the xy-plane. Also ellipses, which take two radii, are drawn on the xy-plane only. I know I can use rotate to rotate ellipses, but this is not really straightforward, as it involves calculating rotation angles and radii.

So is there anyway to tell TikZ to draw on a certain plane? Or is there any other fancy package fo it?

Just for illustration:

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

\begin{document}

\begin{tikzpicture}
\draw (0,0,0) -- (0,4,0) -- (0,4,4) -- (0,0,4) -- cycle;
\draw (0,2,2) circle (2);
\end{tikzpicture}

\end{document}

which produces

enter image description here

Obviousely, I would like to draw the circle in the yz-plane. This would look like an ellipse, fitting perfectly in the yz-plane square (which, due to perspective looks like a parallelogram).

Best Answer

Two examples of what you can draw with the 3d library. The first on has been modified because something was wrong with shade colour.

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{3d}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\begin{document}

\begin{tikzpicture}
     [x={(-0.2cm,-0.4cm)}, y={(1cm,0cm)}, z={(0cm,1cm)}, 
     scale=3,
     fill opacity=0.80,
     color={gray},bottom color=white,top color=black]

 \tikzset{zxplane/.style={canvas is zx plane at y=#1,very thin}}
 \tikzset{yxplane/.style={canvas is yx plane at z=#1,very thin}}

 \begin{scope}[yxplane=-1]
   \shade[draw] (-1,-1) rectangle (1,1);
   \draw (0,0) circle[radius=1cm] ;
 \end{scope}

 \begin{scope}[zxplane=-1]
       \shade[draw] (-1,-1) rectangle (1,1);
 \end{scope}

 \begin{scope}[zxplane=1]
   \shade[draw] (-1,-1) rectangle (1,1);
 \end{scope}

 \begin{scope}[yxplane=1]
       \shade[draw] (-1,-1) rectangle (1,1);
     \end{scope}
 \end{tikzpicture} 



 \begin{tikzpicture}[scale=4]
   \begin{scope}[canvas is zy plane at x=0]
     \draw (0,0) circle (1cm);
     \draw (-1,0) -- (1,0) (0,-1) -- (0,1);
   \end{scope}

   \begin{scope}[canvas is zx plane at y=0]
     \draw (0,0) circle (1cm);
     \draw (-1,0) -- (1,0) (0,-1) -- (0,1);
   \end{scope}

   \begin{scope}[canvas is xy plane at z=0]
     \draw (0,0) circle (1cm);
     \draw (-1,0) -- (1,0) (0,-1) -- (0,1);
   \end{scope}
 \end{tikzpicture}
\end{document}

enter image description here