Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{standalone}
- \usepackage{tikz}
- \usepackage{tikz-3dplot}
- \begin{document}
- % Set azimuth and elevation for the 3D view
- \def\az{110}
- \def\elev{70}
- \tdplotsetmaincoords{\elev}{\az}
- \begin{tikzpicture}[tdplot_main_coords, line join=round]
- % Cylinder parameters
- \def\r{0.5}
- \def\h{2}
- % Base plate (cuboid)
- \draw (-4,-1,-0.5) -- (4,-1,-0.5);
- \draw (4,-1,-0.5) -- (4,1,-0.5);
- \draw (4,1,-0.5) -- (-4,1,-0.5);
- \draw[fill=white] (-4,-1,0) -- (4,-1,0) -- (4,1,0) -- (-4,1,0) -- cycle;
- \draw (4,1,0) -- (4,1,-0.5);
- \draw (4,-1,0) -- (4,-1,-0.5);
- \draw (-4,1,0) -- (-4,1,-0.5);
- % Coordinate axes
- \draw[->] (-6,0,0) -- (6,0,0) node[anchor=north east] {$z$};
- \draw[->] (0,-2,0) -- (0,2,0) node[anchor=south west] {$x$};
- \draw[->] (0,0,\h) -- (0,0,3) node[anchor=south] {$y$};
- % Vertical cylinder
- \draw[fill=white]
- ({cos(\az+180)*\r},{sin(\az+180)*\r},\h) -- ({cos(\az+180)*\r},{sin(\az+180)*\r},0) --
- ({cos(\az+180)*\r},{sin(\az+180)*\r},0) arc[start angle=\az+180, end angle=470, x radius=\r, y radius=\r] --
- ({cos(\az)*\r},{sin(\az)*\r},0) -- ({cos(\az)*\r},{sin(\az)*\r},\h);
- % Top ellipse of the cylinder
- \draw (0,\r,\h) arc[start angle=90, end angle=450, x radius=\r, y radius=\r];
- % Hidden coordinate lines (dashed)
- \draw[densely dashed] (-4,0,0) -- (\r,0,0);
- \draw[densely dashed] (0,-\r,0) -- (0,\r,0);
- \draw[densely dashed] (0,0,-0.5) -- (0,0,\h);
- % Origin marker
- \node[fill, circle, inner sep=1pt, label=above left:$O$] (O) at (0,0,0) {};
- % Top center of the cylinder
- \fill (0,0,\h) circle (0.7pt);
- \end{tikzpicture}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment