I'm just learning TikZ, I've done a few 2D images and I wanted to make a 3D wire frame of the Hubble telescope. The body of the telescope is basically a pair of tubes, the front one slightly narrower than the other. I had thought to draw a series of circles and then put lines along them to create a cylinder.
The problem is, my lines don't fall on the perimeter of the circles. I the circle command to draw the circles on the (y,z)
plane while x
varies along the length of the telescope. I had thought to calculate end points for the lines use the equations y = radius * cos(\theta)
and z = radius * sin(\theta)
but the lines turn out to be slightly off the surface of the cylinder. I've tried a bunch of different things. One really strange thing ( to me) is that if I specify the radius in centimetres for the line calculations the lines are Way off the cylinder. Even though the radius is specified in cm
for the circles.
\tikzset{
MyPersp/.style={scale=1.8,x={(-0.8cm,-0.4cm)},y={(0.8cm,-0.4cm)},z={(0cm,1cm)}}
}
\newcommand{\hubble}[0] {%
\foreach \x in {0,0.25,...,1.0} {
\draw[very thick] (\x,0,0) circle (0.75cm);
}
\draw[very thick] (1.25,0,0) circle ({1.25cm / 2});
\foreach \x in {1.5,1.75,...,2.25} {
\draw[very thick] (\x,0,0) circle (0.5cm);
}
\foreach \r/\x/\xx in {0.75/0/1,0.5/1.5/2.25}{
\foreach \theta in {0,30,...,360}{
\def\y{{\r*cos(\theta)}}
\def\z{{\r*sin(\theta)}}
\draw[very thick](\x,\y,\z) -- (\xx,\y,\z);
}
}
}
\begin{tikzpicture}[MyPersp]
\hubble
\end{tikzpicture}
TikZ
will assume that you want to draw in the xy-plane if You usecircle
. For using the xz-plane or the yz-plane, have a look here and here.