2

I would like to be easily draw 3-D shapes. I'm finding it difficult. I've got isometric paper, but it's difficult to see where to put the lines. 3-d Shape here's my MWE. But is the an easier way to draw shapes like the I've attached. All the measurements need to be on the shapes

% !TeX program = xelatex
% !TeX spellcheck = en_GB
\documentclass[12pt,addpoints]{exam}

\usepackage{tikz} \usetikzlibrary{plotmarks}

\usetikzlibrary{quotes,angles}

\usetikzlibrary{quotes,arrows.meta} % needed for tikz pictures

\begin{document}

\begin{tikzpicture}[x={(0.86cm,0.5cm)},y={(-0.86cm,0.5cm)}, color=black] \clip (0,12.5) rectangle (18,12.5); \foreach \x in {0,...,25} \foreach \y in {0,...,25} { \fill (\x,\y) circle (2pt); \draw [red ] (4,11) -- (6,13); \draw [red ] (4,11) -- (4,15); \draw [red ] (4,15) -- (6,17); \draw [red] (6,13) -- (6,17); \draw [red ] (4,11) -- (10,11); \draw [red ] (6,13) -- (12,13); \draw [red ] (10,11) -- (12,13); \draw [red ] (12,13) -- (12,17); \draw [red ] (6,17) -- (12,17); %\draw [red, very thick] (12,17) -- (10,15); \draw (4,15)-- (10,15); \draw (10,15)-- (12,17); \draw (10,15)-- (10,11); }

\end{tikzpicture}

\end{document}

Sandy G
  • 42,558
Jon
  • 525
  • 1
  • 3
  • 11
  • 2
    Use 3D coordinates (x, y, z) and use tikz-3dplot to change the viewing angle. See also https://tex.stackexchange.com/questions/170244/how-to-compute-xslant-and-yslant and https://tex.stackexchange.com/questions/59406/tikz-how-to-draw-an-isometric-drawing-in-tikz – John Kormylo Mar 05 '23 at 20:18
  • Thanks, John, for quick reply. I've read your suggestions too complicated for me. Could you possible write the code for this example? Then I'll go back and re-read your suggestions. – Jon Mar 06 '23 at 05:06
  • Xslant is only needed if you want the text to match the axis planes. The last link is mo longer needed due to [isometric view]. – John Kormylo Mar 06 '23 at 13:17

1 Answers1

4

The solution is more straightforward than those suggested. Just plot it in 3D coordinates as John said i.e. specify (x,y,z). The coordinates frame indicates that (x,y) are the plane of the page and z is "depth". Of course more complex shape will require more work.

If you are working with something more complicated, you may want to check https://tikz.dev/library-perspective#autosec-6021

enter image description here

% !TeX spellcheck = en_GB
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {perspective}

\begin{document}

\begin{tikzpicture} \draw(0,0,0) -- (12,0,0) -- (12,5,0) -- (9,5,0) -- (9,2,0) -- (3,2,0) --(3,5,0) -- (0,5,0) -- cycle; \draw(0,0,10) -- (12,0,10) -- (12,5,10) -- (9,5,10) -- (9,2,10) -- (3,2,10) --(3,5,10) -- (0,5,10) -- cycle;

\draw (0,0,0)-- (0,0,10); \draw (12,0,0)-- (12,0,10); \draw (12,5,0)-- (12,5,10); \draw (9,5,0)-- (9,5,10); \draw (9,2,0)-- (9,2,10); \draw (3,2,0)-- (3,2,10); \draw (3,5,0)-- (3,5,10); \draw (0,5,0)-- (0,5,10); \end{tikzpicture}

\end{document}

As you can see by default it isn't the isometric view. It is perspective.

Just add the option isometric view such as \begin{tikzpicture}[isometric view]. of course that will flip the drawing.

Finally, you can toy around with [3d view = {140}{50}]

anis
  • 1,510
  • 5
  • 13
  • side note: I may not be aware of how to correctly translate "cavalier perspective", I think it is Oblique projection – anis Mar 06 '23 at 07:59
  • 1
    This is what I required a solution that I could play with. Nice and simple to begin with then build up to more advanced things – Jon Mar 09 '23 at 12:23