I am trying to draw 3d shapes and I am stuck on how to draw an ell shape (3d). The shape is basically an L but in 3d
Asked
Active
Viewed 1,504 times
4
-
1Welcome! Can you provide more details? There are even fonts that look 3d-like. – Mar 10 '20 at 22:51
-
I wanted something I could draw onto – Leafy Mar 10 '20 at 22:51
-
3It would be great if you could show us what you have tried. Posting a minimal working example that indicates what you are trying to do makes it easier for people to understand what you want. It also makes it easier for people to help you, since they have some code to start from, and hence much more likely that some one will try to help you. – Mar 10 '20 at 23:49
-
I will keep that in mind next time I ask a question thank you for the advice. – Leafy Mar 11 '20 at 02:31
2 Answers
6
To give you a start.
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view={30}{15},line cap=round,
declare function={ax=2;ay=1.5;az=2.5;bx=0.5;bz=0.5;}]
\draw (0,0,0) -- (ax,0,0) -- (ax,0,bz) -- (bx,0,bz) -- (bx,0,az)
-- (0,0,az) -- cycle
(0,0,az) -- (0,ay,az) -- (bx,ay,az) edge ++ (0,-ay,0)
-- (bx,ay,az) edge ++ (0,-ay,0)
-- (bx,ay,bz) edge ++ (0,-ay,0)
-- (ax,ay,bz) edge ++ (0,-ay,0)
-- (ax,ay,0) -- (ax,0,0);
\end{tikzpicture}
\end{document}
The perspective library allows us to change the view angles, and declare function is used to define parameters that can be changed, too.
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view={40}{35},line cap=round,
declare function={ax=3;ay=2;az=2.5;bx=0.8;bz=0.8;}]
\draw (0,0,0) -- (ax,0,0) -- (ax,0,bz) -- (bx,0,bz) -- (bx,0,az)
-- (0,0,az) -- cycle
(0,0,az) -- (0,ay,az) -- (bx,ay,az) edge ++ (0,-ay,0)
-- (bx,ay,az) edge ++ (0,-ay,0)
-- (bx,ay,bz) edge ++ (0,-ay,0)
-- (ax,ay,bz) edge ++ (0,-ay,0)
-- (ax,ay,0) -- (ax,0,0);
\end{tikzpicture}
\end{document}
3
I would suggest something along the lines of the code below. This because I like the readability and also because it can be written fast...
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,3d}
\begin{document}
\begin{tikzpicture}[x = {(0.95cm,-0.3cm)},
y = {(0.707cm,0.707cm)},
z = {(0cm,1cm)}]
\begin{scope}[canvas is zx plane at y=0]
\draw (0,0) -- ++(3,0) -- ++(0,1) --++(-2,0) -- ++(0,5) -- ++(-1,0) -- (0,0);
\end{scope}
\begin{scope}[canvas is zy plane at x=0]
\draw (3,0) -- ++(0,3);
\end{scope}
\begin{scope}[canvas is zy plane at x=1]
\draw (3,0) -- ++(0,3);
\draw (1,0) -- ++(0,3);
\end{scope}
\begin{scope}[canvas is zy plane at x=6]
\draw (0,0) -- ++(0,3);
\draw (1,0) -- ++(0,3);
\end{scope}
\begin{scope}[canvas is zx plane at y=3]
\draw (0,0) ++(3,0) -- ++(0,1) --++(-2,0) -- ++(0,5) -- ++(-1,0);
\end{scope}
\end{tikzpicture}
\end{document}
DrJay
- 1,162



