Is there a way in Tikz to translate and rotate a, lets say, rectangle by an arbitrary distance/angle? As an example
- Translation: 3 in x-direction, 5 in y-direction
- Rotation: 45 degree
Now my goal would be drawing a rectangle around the origin and then be able to first translate then rotate the object and vice versa via TikZ commands. So one could visually see, that the translation and the rotation do not commute.
The translate first then rotate is easily done by hand but the other way around I need the help of a calculator.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale = 0.5]
\draw [->](-5,0) -- (5,0); %x-axis
\draw [->](0,-5) -- (0,5); %y-axis
\draw[green] (1,1) -- (1,-1) -- (-1,-1) -- (-1,1) -- (1,1); %square around the origin
\draw[blue] ($ (3,{5+sqrt(2)}) $) -- ($ ({3-sqrt(2)},5) $) -- ($ (3,{5-sqrt(2)}) $) -- ($ ({3+sqrt(2)},5) $) -- ($ (3,{5+sqrt(2)}) $) ; %Rotation first, then translated, values calculated by hand
\draw[green, rotate around={45:(0,0)}] (2,6) rectangle (4,4); %neat solution for the RT case
\end{tikzpicture}
\end{document}