[Tex/LaTex] Specifying the transformation matrix TikZ uses manually

3dtikz-pgf

I'm creating some 3D graphics using TikZ, and I need to apply a transformation matrix to some coordinates I'm specifying in 2D so they end up in 3D. I am going to draw graphics on all three visible sides of a cube, and I have defined macros that work in 2D that I want to be able to use on those sides. Is there any way to do this? I saw that there are some primitive transformations in PGF, but they all work in 2D.

Best Answer

How about this:

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

\begin{document}

\tikzset{xzplane/.style={canvas is xz plane at y=#1,very thin}}
\tikzset{yzplane/.style={canvas is yz plane at x=#1,very thin}}
\tikzset{xyplane/.style={canvas is xy plane at z=#1,very thin}}

\begin{tikzpicture}[x={(0.985cm,-0.174cm)},y={(-0.906cm,-0.423cm)},z={(0cm,1cm)}]
    \draw[xzplane=5] (0,0) -- (5,0) -- (5,5) -- (0,5) -- cycle;
    \draw[yzplane=5] (0,0) -- (5,0) -- (5,5) -- (0,5) -- cycle;
    \draw[xyplane=5] (0,0) -- (5,0) -- (5,5) -- (0,5) -- cycle;
    \foreach \x in {xzplane,yzplane,xyplane}
    {   \draw[\x=5] (1,1) -- (4,1) -- (2.5,4) -- cycle;
        \filldraw[\x=5,red,fill opacity=0.2,draw=black] (1.5,1.5) circle (0.5);
        \filldraw[\x=5,green,fill opacity=0.2,draw=black] (3.5,1.5) circle (0.5);
        \filldraw[\x=5,blue,fill opacity=0.2,draw=black] (1.5,3.5) circle (0.5);
        \filldraw[\x=5,yellow,fill opacity=0.2,draw=black] (3.5,3.5) circle (0.5);
    }
\end{tikzpicture}

\end{document}

enter image description here

Related Question