I am trying to create a drawing of part of a circuit with 3D perspective like so:
How can this be done?
The main body of the capacitors has now been created in latex, all that remains is to create the line from either side of the shaded circle.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI am trying to create a drawing of part of a circuit with 3D perspective like so:
How can this be done?
The main body of the capacitors has now been created in latex, all that remains is to create the line from either side of the shaded circle.
The following should get you started.
Edit: you can control the opacity of draw
and fill
elements independently, using the draw opacity
and fill opacity
keys, respectively. See Tikz: use opacity for fill, yet leave draw (lines) untouched for more details.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,arrows,patterns,shapes}
\tikzset{
->-/.style={decoration={
markings,
mark=at position .3 with {\arrow{triangle 90}}},postaction={decorate}},
}
\begin{document}
\begin{tikzpicture}
\def\Cplanesep{3} % <--- adjust the distance between the planes here
\def\Cwirelen{4} % <--- adjust the wire length here
\path[use as bounding box]
({3-\Cwirelen}, -3) rectangle ({3.2+\Cplanesep+\Cwirelen}, 3.5);
% necessary for cropping the picture
% because control points lie way out
% (dimensions adjusted manually...)
\newcommand\Cplane[1][0]
{%
\begin{scope}[xshift=#1 cm]
\filldraw[thick,draw=black,fill=gray,fill opacity=.3]
(2.5,-2.5) --
(2.5,1) --
(4,3) --
(4,-0.5) --
cycle;
\end{scope}
}
\node
[
draw,
thick,
ellipse,
minimum height = 1.5cm,
minimum width = 1cm,
decorate,
pattern = north east lines,
fill opacity = .7,
rotate = -20
] (hc) at (1.5,0) {};
\draw[thick,->-]
({3-\Cwirelen},0) -- ++(\Cwirelen,0)
node[pos=.3,anchor=north] {$I$};
\Cplane
\Cplane[\Cplanesep]
\draw[thick] ({3.2+\Cplanesep},0) -- ++(\Cwirelen,0) ;
\draw
(hc.north)
.. controls (6,10) and (5, -9) ..
(hc.south);
\end{tikzpicture}
\end{document}
This code uses hobby
tikz library to draw the envelope:
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.markings, arrows,calc,patterns,shapes,hobby,backgrounds}
\tikzset{
single/.style={draw,
decoration={markings, mark=at position .5 with {\arrow{triangle 45}}},
postaction={decorate},
},
}
\begin{document}
\begin{tikzpicture}[font=\tiny]
\coordinate (a) at (0,0);
\coordinate (b) at (2,0);
\coordinate (c) at (2,2);
\coordinate (d) at (0,2);
%
\coordinate (a1) at (0.65,0.5);
\coordinate (b1) at (2.65,0.5);
\coordinate (c1) at (2.65,2.5);
\coordinate (d1) at (0.65,2.5);
%
\draw[thick,fill=gray!30] (d) -- coordinate(da) (a) -- (a1) -- (d1) -- cycle;
\draw[thick,fill=gray!30] (b) -- (b1) -- (c1) -- (c) -- cycle;
\draw[single] (-2,1) -- (da)node[midway,above] {I};
\draw(2.3,1) -- (4,1);
\node
[
draw,
%thick,
ellipse,
minimum height = 1cm,
minimum width = 0.5cm,
pattern = north east lines,
fill opacity = .5,
rotate = -10
] (el) at (-0.5,1) {};
\begin{scope}[on background layer]
\draw (el.north)
to[curve through={(-0.3,1.7) .. (0.5,2.6) .. (0.6,2.6) ..
(0.9,1) .. (0.75,0) ..
(0.1,-0.3)
}
]
(el.south);
\end{scope}
\end{tikzpicture}
\end{document}
With PSTricks.
\documentclass[pstricks,border=30pt,12pt]{standalone}
\usepackage{pstricks-add}
\def\plate{\pspolygon(-1,-2)(1,-1)(1,3)(-1,2)}
\begin{document}
\begin{pspicture}[fillstyle=solid,fillcolor=gray,arrowscale=2,opacity=.3](9,5)
\rput(3,2){\pcline[ArrowInside=->](-3,0)(0,0)\nbput{$I$}\plate}
\rput(6,2){\plate\psline[ArrowInside=->](3,0)}
\end{pspicture}
\end{document}