# Drawing 3d circuit diagram

I've started using tikz only few weeks ago and find it utmost useful todraw beautiful picutres.But now i'm a bit stuck on a 3d circuit which should resemble the physical structure and hope the experts here can help me on my little problem. This is what i got so far:

The Problem is that the circuit nodes are not drawn as 3d which looks unplesant. As I understand tikz it only transforms coordinates, therefore nodes will always be drawn as 2d. Is this correct? an if so, is there a way to change this? I also thought about drawing the resistors by hand, however, I don't know how to spezifie planes accept for xy etc. (e.g. canvas is plane xz at z=0).

    \begin{tikzpicture}[scale=0.7,
x={({cos(20)*1cm},{sin(20)*1cm})},y={({cos(160)*1cm},{sin(160)*1cm})}, z={(0cm,1cm)},
point/.style={minimum  size=1pt,inner  sep=2pt, circle, draw, red},
cont/.style={contact, draw, thick},
circuit ee IEC,
thick,
]

%untere Kreise mit intersectionpaths
\draw[name path=CUA,dashed, thin] (0,0,0) circle(6);
\draw[name path=CUI] (0,0,0) circle(1);
\path[name path=L0] (0,0) -- ++(60:6.5);
\path[name path=L1] (0,0) -- ++(-60:6.5);
\path[name path=L2] (0,0) -- ++(-180:6.5);

%obere kreise mit intersection paths
\draw[name path=COA, dashed,thin] (0,0,8) circle(6);
\draw[name path=COI] (0,0,8) circle(1);
\path[name path=L4] (0,0,8) -- ++(60:6.5);
\path[name path=L5] (0,0,8) -- ++(-60:6.5);
\path[name path=L6] (0,0,8) -- ++(-180:6.5);

%untere intersectionpoints
\path[name intersections={of=CUA and L0}] (intersection-1) node[cont, name = IUA0] {};
\path[name intersections={of=CUA and L1}] (intersection-1) node[cont, name = IUA120] {};
\path[name intersections={of=CUA and L2}] (intersection-1) node[cont, name = IUA240] {};
\path[name intersections={of=CUI and L0}] (intersection-1) node[cont, name = IUI0] {};
\path[name intersections={of=CUI and L1}] (intersection-1) node[cont, name = IUI120] {};
\path[name intersections={of=CUI and L2}] (intersection-1) node[cont, name = IUI240] {};

%obere intersectionpoints
\path[name intersections={of=COA and L4}] (intersection-1) node[cont, name = IOA0] {};
\path[name intersections={of=COA and L5}] (intersection-1) node[cont, name = IOA120] {};
\path[name intersections={of=COA and L6}] (intersection-1) node[cont, name = IOA240] {};
\path[name intersections={of=COI and L4}] (intersection-1) node[cont, name = IOI0] {};
\path[name intersections={of=COI and L5}] (intersection-1) node[cont, name = IOI120] {};
\path[name intersections={of=COI and L6}] (intersection-1) node[cont, name = IOI240] {};

\draw[small  circuit  symbols]  (IUA0)  to  [resistor]  (IUI0);
\draw  (IUA120)  to  [resistor]  (IUI120);
\draw  (IUA240)  to  [resistor]  (IUI240);

\draw[small  circuit  symbols]  (IUI0)  to  [resistor={near start, fill=white}, resistor={near end}]  (IOI0);
\draw  (IUI120)  to  [resistor] ++(0,0,4) to [resistor] ++(0,0,2) to (IOI120);
\draw  (IUI240)  to  [resistor={fill=white}] ++(0,0,4) to [resistor] ++(0,0,2) to (IOI240);

\draw[small  circuit  symbols]  (IUA0)  to  [resistor={near start}]  (IOA0);
\draw  (IUA120)  to  [resistor]  (IOA120);
\draw  (IUA240)  to  [resistor={fill=white}]  (IOA240);

\draw[small  circuit  symbols]  (IOA0)  to [voltage  source={near start, direction  info={<-}, info=$I_1w$}, resistor={near end}] (IOI0);
\draw  (IOA120)  to  [voltage  source={near start, direction  info={<-}, info=$I_2w$}, resistor={near end}]  (IOI120);
\draw  (IOA240)  to  [voltage  source={near start, direction  info={<-}, info=$I_3w$}, resistor={near end, fill=white}]  (IOI240);

\end{tikzpicture}

-
Welcome to TeX.SX! Questions are not signed nor do we add thanks at the end. We do that to keep things concise and focused, not out of rudeness. I added the picture you provided the link to. – Count Zero Jun 25 '12 at 15:20
I'm very impressed by what you have so far! – Loop Space Jun 25 '12 at 18:25
You should submit this to TeXample once you have it polished. – Alex Hirzel Jun 25 '12 at 20:22
(Please include the preamble when including code, otherwise we have to guess what packages and libraries you are using - as there are several for circuits, that's a non-trivial task and makes it harder for someone to play around with your code.) – Loop Space Jun 26 '12 at 12:03
I've been poking around in the code looking at this one. The problem is about 2D versus 3D and it (or at least, one problem) is from the decoration library. When PGF decorates a path, it transforms the coordinate system so that x points along the path. The y direction is orthogonal to that in the 2D plane of the paper. If you look at your resistors, you'll see that they are orthogonal to the line. What you want is to make the y direction orthogonal to the line in some specified plane. That's tricky, though. – Loop Space Jun 26 '12 at 12:06

Ok maybe not the cleanest solution ever, but I've written all circuit elemts by hand now and applyed some hacking to get the correct planes to draw on. The result:

Drawing the botton and top elemts was not that hard, just performing some coordinate calculations. The top-to-bottom elements R8, R9 and R7 were easy too, as they lie on the xz plane so i could use canvas is xz plane at y=0. For the two other top-bottom planes I drew a helperline perpendicular to the connections and changed manual the x=<> value in a scope environment (with z=(0,1)) so that the x-axis lies on the perpendicular line. When I matched both i could draw on xz plane and got my resisotrs right. It's unexact, but worked. I belive the code is way to hacky to post as an example.

    \begin{tikzpicture}[scale=0.65,
x={({cos(20)*1cm},{sin(20)*1cm})},y={({cos(160)*1cm},{sin(160)*1cm})}, z={(0cm,1cm)},
point/.style={minimum  size=0pt,inner  sep=0pt},
cont/.style={contact, draw, thick},
circuit ee IEC,
thick,]

%mittelpunkte
\path (0,0,0) node[name = U] {};
\path (0,0,8) node[name = O] {};

%untere Kreise mit intersectionpaths
\draw[name path=CUA] (U) circle(6);
\draw[name path=CUI] (U) circle(1.1);
\path[name path=L0] (U) -- ++(90:6.5);
\path[name path=L1] (U) -- ++(-30:6.5);
\path[name path=L2] (U) -- ++(-150:6.5);

%untere Intersections
\path[name intersections={of=CUA and L0}] (intersection-1) node[cont, name = IUA0] {};
\path[name intersections={of=CUA and L1}] (intersection-1) node[cont, name = IUA120] {};
\path[name intersections={of=CUA and L2}] (intersection-1) node[cont, name = IUA240] {};
\path[name intersections={of=CUI and L0}] (intersection-1) node[cont, name = IUI0] {};
\path[name intersections={of=CUI and L1}] (intersection-1) node[cont, name = IUI120] {};
\path[name intersections={of=CUI and L2}] (intersection-1) node[cont, name = IUI240] {};

%obere kreise mit intersection paths
\path[name path=COA, dashed,thin] (O) circle(6);
\draw[name path=COI] (O) circle(1.1);
\path[name path=L4] (O) -- ++(90:6.5);
\path[name path=L5] (O) -- ++(-30:6.5);
\path[name path=L6] (O) -- ++(-150:6.5);

%obere intersectionpoints
\path[name intersections={of=COA and L4}] (intersection-1) node[cont, name = IOA0] {};
\path[name intersections={of=COA and L5}] (intersection-1) node[cont, name = IOA120] {};
\path[name intersections={of=COA and L6}] (intersection-1) node[cont, name = IOA240] {};
\path[name intersections={of=COI and L4}] (intersection-1) node[cont, name = IOI0] {};
\path[name intersections={of=COI and L5}] (intersection-1) node[cont, name = IOI120] {};
\path[name intersections={of=COI and L6}] (intersection-1) node[cont, name = IOI240] {};

%die unteren widerstände
\draw (IUA0)--(IUI0);
\draw let \p1 = (IUA0), \p2=(IUI0) in  ({\x1+0.35*\x2-0.35*\x1}, {\y1+0.35*\y2-0.35*\y1}) node[point, name=n]{};
\draw[fill=white] (n)   ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below right=3mm of n, xshift=-3mm] {$R_4$};

\draw (IUA120)--(IUI120);
\draw[fill=white] let \p1 = (IUA120), \p2=(IUI120) in  ({\x1+0.65*\x2-0.65*\x1}, {\y1+0.65*\y2-0.65*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(60:-0.2)-- ++(60:0.4)-- ++(-30:1.7)-- ++(60:-0.4)--cycle;
\node (tn) [below right=0mm of n, xshift=5mm] {$R_5$};

\draw (IUA240)--(IUI240);
\draw[fill=white] let \p1 = (IUA240), \p2=(IUI240) in  ({\x1+0.35*\x2-0.35*\x1}, {\y1+0.35*\y2-0.35*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(-60:-0.2)-- ++(-60:0.4)-- ++(30:1.7)-- ++(-60:-0.4)--cycle;
\node (tn) [right=3mm of n, yshift=1mm] {$R_6$};

%die verbindungen oben-unten
\draw (IOA0) -- (IUA0);
\draw (IOA120) -- (IUA120);
\draw (IOA240) -- (IUA240);
\draw (IOI0) -- (IUI0);
\draw (IOI120) -- (IUI120);
\draw (IOI240) -- (IUI240);

\begin{scope}[canvas is xz plane  at y=0]
\draw[fill=white] let \p1 = (IUA0), \p2=(IOA0) in  ({\x1+0.5*\x2-0.5*\x1}, {\y1+0.5*\y2-0.5*\y1})  node[point, name=n]{};
\draw[fill=white] (n)   ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below left=3mm of n, xshift=1mm] {$R_7$};

\draw[fill=white] let \p1 = (IUI0), \p2=(IOI0) in  ({\x1+0.3*\x2-0.3*\x1}, {\y1+0.3*\y2-0.3*\y1})  node[point, name=n]{};
\draw[fill=white] (n)   ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below left=3mm of n, xshift=1.5mm] {$R_8$};

\draw[fill=white] let \p1 = (IUI0), \p2=(IOI0) in  ({\x1+0.6*\x2-0.6*\x1}, {\y1+0.6*\y2-0.6*\y1})  node[point, name=n]{};
\draw[fill=white] (n)   ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below left=3mm of n, xshift=1.5mm] {$R_9$};
\end{scope}

%\draw[name path=L7] (U) -- ++(60:8); nur zum manuellen ebenen einstellen
\begin{scope}[x={({cos(126.5)*1cm},{sin(126.5)*1cm})},y={({cos(53.5)*1cm},{sin(53.5)*1cm})}, z={(0cm,1cm)}]
%\draw[->][thick, red] (0,0,0) -- (6,0,0); nur zum manuellen ebeneneinstellen
\begin{scope}[canvas is xz plane at y=0]
\draw[fill=white] let \p1 = (IUA120), \p2=(IOA120) in  ({\x1+0.5*\x2-0.5*\x1}, {\y1+0.5*\y2-0.5*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below left=3mm of n, xshift=1mm] {$R_{10}$};

\draw[fill=white] let \p1 = (IUI120), \p2=(IOI120) in  ({\x1+0.3*\x2-0.3*\x1}, {\y1+0.3*\y2-0.3*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below right=3mm of n, xshift=-1.5mm] {$R_{11}$};

\draw[fill=white] let \p1 = (IUI120), \p2=(IOI120) in  ({\x1+0.6*\x2-0.6*\x1}, {\y1+0.6*\y2-0.6*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below right=3mm of n, xshift=-1.5mm] {$R_{12}$};
\end{scope}
\end{scope}

%\draw[name path=L7] (U) -- ++(120:8); nur zum manuellen ebenen einstellen
\begin{scope}[x={({cos(174.5)*1cm},{sin(174.5)*1cm})},y={({cos(323.5)*1cm},{sin(323.5)*1cm})}, z={(0cm,1cm)}]
%\draw[->][thick, red] (0,0,0) -- (8,0,0); manuelle ebenenfindung
\begin{scope}[canvas is xz plane at y=0]
\draw[fill=white] let \p1 = (IUA240), \p2=(IOA240) in  ({\x1+0.5*\x2-0.5*\x1}, {\y1+0.5*\y2-0.5*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below left=3mm of n, xshift=1.5mm,yshift=-4mm] {$R_{13}$};

\draw[fill=white] let \p1 = (IUI240), \p2=(IOI240) in  ({\x1+0.3*\x2-0.3*\x1}, {\y1+0.3*\y2-0.3*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below right=3mm of n, xshift=-1.5mm] {$R_{14}$};

\draw[fill=white] let \p1 = (IUI240), \p2=(IOI240) in  ({\x1+0.6*\x2-0.6*\x1}, {\y1+0.6*\y2-0.6*\y1}) node[point, name=n]{};
\draw[fill=white] (n)       ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below right=3mm of n, xshift=-1.5mm] {$R_{15}$};
\end{scope}
\end{scope}

%die oberen widerstände und spulen
\draw (IOA0)--(IOI0);
\draw  let \p1 = (IOA0), \p2=(IOI0) in  ({\x1+0.5*\x2-0.5*\x1}, {\y1+0.5*\y2-0.5*\y1}) node[point, name=n] {};
\draw[fill=white] (n) ++(0:-0.2)-- ++(0:0.4)-- ++(-90:1.7)-- ++(0:-0.4)--cycle;
\node (tn) [below right=0.6 of n] {$R_1$};

\draw let \p1 = (IOA0), \p2=(IOI0) in  ({\x1+0.25*\x2-0.25*\x1}, {\y1+0.25*\y2-0.25*\y1}) node[point, name=n] {};
\draw(n)circle(0.4);
\node (tn) [below left=0.2 of n, xshift=3] {$I_1w$};

\draw (IOA120)--(IOI120);
\draw let \p1 = (IOA120), \p2=(IOI120) in  ({\x1+0.8*\x2-0.8*\x1}, {\y1+0.8*\y2-0.8*\y1}) node[point, name=n] {};
\draw[fill=white] (n)   ++(60:-0.2)-- ++(60:0.4)-- ++(-30:1.7)-- ++(60:-0.4)--cycle;
\node (tn) [below right=0.1 of n, xshift=12] {$R_2$};
\draw let \p1 = (IOA120), \p2=(IOI120) in  ({\x1+0.25*\x2-0.25*\x1}, {\y1+0.25*\y2-0.25*\y1}) node[point, name=n] {};
\draw (n) circle(0.4);
\node (tn) [below left=0.3 of n, xshift=15] {$I_2w$};

\draw (IOA240)--(IOI240);
\draw let \p1 = (IOA240), \p2=(IOI240) in  ({\x1+0.5*\x2-0.5*\x1}, {\y1+0.5*\y2-0.5*\y1})  node[point, name=n] {};
\draw[fill=white] (n)   ++(-60:-0.2)-- ++(-60:0.4)-- ++(30:1.7)-- ++(-60:-0.4)--cycle;
\node (tn) [above left=1mm of n] {$R_3$};
\draw let \p1 = (IOA240), \p2=(IOI240) in  ({\x1+0.25*\x2-0.25*\x1}, {\y1+0.25*\y2-0.25*\y1}) node[point, name=n] {};
\draw(n) circle(0.4);
\node (tn) [left=3mm of n, yshift=1mm] {$I_3w$};

\draw[dashed,thin] (O) circle(6);

\end{tikzpicture}

-