1

the following is a good example. let's say I want to draw an SSD-like box. eight points, not identified by grid coordinates, but by relative angles.

\documentclass[border=3mm,12pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

  \draw[black, thick, fill=gray] (6.5em,7em) -- ++(30:3em) -- ++(-90:0.5em) -- ++(90:0.5em) -- ++(-30:2em)  --
  ++(-90:0.5em) -- ++(90:0.5em) -- ++(-150:3em)  -- ++(-90:0.5em) -- ++(90:0.5em)-- ++(150:2em) --
  ++(-90:0.5em) -- ++(30:3em) -- ++(-30:2em) -- ++(-150:3em) -- ++(150:2em) -- cycle;

  \draw[black] (7.2em,6.2em) -- ++(90:0.2em) -- ++(-30:0.4em) -- ++(-90:0.2em) -- cycle;

\end{tikzpicture}

\end{document}

enter image description here

now I am trying to highlight one of the vertexes, say in red, to remind which is which to help me visualize it. for this simple wireframe, this is easy. if I have 100 points, it is hard.

this is sort of what I want:

\draw (6.5,7em) -- ++(30:3em) -- ++[red](-90:0.5em) -- ++(90:0.5em);

the problems I want to tackle intelligently are ( 1 ) two triangles that are not colored, and ( 2 ) hidden rays. So I think I will need to recode this into rectangular coordinates. I hope that I won't have to overlay a grid and read points off it. Can tikz output its calculated coordinates, or do I need to write a program? or, even better, also where lines cross?

generalizability is better than clever specialized solutions. I am asking because I have a couple of these problems. advice appreciated.

regards,

/iaw

  • 2
    If you want to highlight just a single vertex, mark it with a red dot: \draw (6.5,7em) -- ++(30:3em) -- ++(-90:0.5em) node[shape=circle, fill=red, minimum size=5pt] {} -- ++(90:0.5em); – JMP Apr 30 '16 at 18:51
  • 1
    As for hidden lines and getting rid of surprises, each face should be done with its own \path (\draw or \fill) starting with the farthest and ending with the nearest. – John Kormylo Apr 30 '16 at 19:33
1

My solution would be:

\documentclass[border=3mm,12pt]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \begin{scope}[black, thick, fill=gray, join=bevel]
        \path (6.5em,7em) coordinate (start);
        \filldraw (start) -- ++(30:3em) -- ++(90:0.5em) -- ++(-150:3em) -- cycle;
        \filldraw (start) -- ++(150:2em)  -- ++(90:0.5em) -- ++(-30:2em) -- cycle;
        \filldraw (start) ++(90:0.5em) --  ++(30:3em) -- ++(150:2em) 
            --  ++(-150:3em) -- cycle;
        \draw[black] (start) ++(150:1.2em) ++ (90:0.15em) -- ++(90:0.2em) 
            -- ++(-30:0.4em) -- ++(-90:0.2em) -- cycle;
    \end{scope}
\end{tikzpicture}

\end{document}

I am taking care of the hidden lines by drawing the surfaces one by one. The figure is now movable just changing the starting coordinate in one point.

Output for the snippet

Adding nodes as in @JMP comment can take care of red dots, and naming vertexes with coordinate(name) will let you draw thin hidden lines if you need them.

\documentclass[border=3mm,12pt]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \begin{scope}[black, thick, fill=gray, join=bevel]
        \path (6.5em,7em) coordinate (start);
        \filldraw (start) -- ++(30:3em) coordinate(a) -- ++(90:0.5em) -- ++(-150:3em) -- cycle;
        \filldraw (start) -- ++(150:2em) coordinate (b)  -- ++(90:0.5em) -- ++(-30:2em) -- cycle;
        \filldraw (start) ++(90:0.5em) --  ++(30:3em) -- ++(150:2em) coordinate(c) 
            --  ++(-150:3em) -- cycle;
        \draw[black] (start) ++(150:1.2em) ++ (90:0.15em) -- ++(90:0.2em) 
            -- ++(-30:0.4em) -- ++(-90:0.2em) -- cycle;
        %% hiddens 
        \draw [ultra thin] (c) -- ++(-90:0.5em) coordinate(d);
        \draw [ultra thin] (a) -- (d) (b) -- (d);
    \end{scope}
\end{tikzpicture}

\end{document}

With hidden borders

And finally, adding

 \path (start) node [shape=circle, fill=red, minimum size=2pt, inner sep=0pt]{};

before the \end{scope} you have your starting point highlighted:

With the starting point red

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.