20

I have a named path (a triangle). How do I rotate it around point A in various angles without recalculating points B & C?

Here's my code. I want to create the red and green triangles by simply rotating the black triangle in multiples of 60 degrees.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
    \providecommand* \angle {30}
    \coordinate[label=above left:A](A) at (2,3);
    \coordinate[label=below:B](B) at (0,0);
    \coordinate[label=below:C](C) at (6,0);
    \draw
        (A) -- (B) -- (C) -- cycle;

    \coordinate[label=B'](B') at ($(A)!1!60:(B)$);
    \coordinate[label=C'](C') at ($(A)!1!60:(C)$);
    \draw[dashed,red]
        (A) -- (B') -- (C') -- cycle;

    \coordinate[label=B''](B'') at ($(A)!1!60:(B')$);
    \coordinate[label=C''](C'') at ($(A)!1!60:(C')$);
    \draw[dashed,green]
        (A) -- (B'') -- (C'') -- cycle;
\end{tikzpicture}
\end{document}

Rotate triangle

2 Answers 2

23

You are overwriting the nodes so it's a little trickier but essentially you can scope the path and use rotate around transformation.

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}
    \providecommand* \angle {30}
    \coordinate[label=above left:A](A) at (2,3);
    \coordinate[label=below:B](B) at (0,0);
    \coordinate[label=below:C](C) at (6,0);
    \draw
        (A) -- (B) -- (C) -- cycle;

\begin{scope}[rotate around={60:(A)}]
    \coordinate[label=above left:A](A) at (2,3);
    \coordinate[label=below:B](B) at (0,0);
    \coordinate[label=below:C](C) at (6,0);
    \draw[dashed,red]
        (A) -- (B) -- (C) -- cycle;
\end{scope}

\end{tikzpicture}
\end{document}

enter image description here

1
  • Don't worry about the B' and C' nodes. You answer my question perfectly. Thank you! Nov 5, 2013 at 18:09
-1
\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}
    %\providecommand* \angle {30}
    \coordinate[label=above left:A](A) at (2,3);
    \coordinate[label=below:B](B) at (0,0);
    \coordinate[label=below:C](C) at (6,0);
    \draw
        (A) -- (B) -- (C) -- cycle;

\begin{scope}[rotate around={60:(A)}]
    \coordinate[label=above left:A](A) at (2,3);
    \coordinate[label=below:B](B) at (0,0);
    \coordinate[label=below:C](C) at (6,0);
    \draw[dashed,red]
        (A) -- (B) -- (C) -- cycle;
\end{scope}

\end{tikzpicture}
\end{document}
3
  • Welcome to TeX - LaTeX! Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Apr 22, 2020 at 10:23
  • 1
    @nguyenvanthien that's exactly the same code as provided by the accepted answer. Amazing how you implemented and phrased it in exactly the same way. Apr 22, 2020 at 10:25
  • (not exactly the same, he commented out the providecommand line) May 1, 2021 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .