1

Is there any way to find out what the current rotation angle is inside the definition of a TikZ pic? I need to define a pic with one component whose positioning is independent of the coordinate transformation of the pic. E.g.,

\tikzset{mypic/.pic = {
\draw[rotate=-\commandwhichfindsouttikzpicangle] (1,0)circle(0.1cm);
}

\pic[rotate=40] (p) at (1,0) {mypic};

should output a small circle at (2,0), and not ($(1,0)+(40:1)$).

Of course I'd also be happy with any other kind of code that defines a TikZ pic behaving like this. Maybe there's also a command to set back the rotation of the current coordinate transformation that would help?

1
  • It's kind of the point that the pic rotates everything in it. Maybe there's a better solution but for that we'd need to know what you're trying to do actually. Dec 1, 2022 at 9:11

1 Answer 1

1

Maybe there's also a command to set back the rotation of the current coordinate transformation that would help?

There is (kinda): the shift only key (or its PGF version \pgftransformresetnontranslations).

This will disable any transformation that rotates, scales or slants by simply setting the transformation matrix to (1 0 0 1 | s t) where s and t is just the shifting that remains.

Code

\documentclass[tikz]{standalone}
\tikzset{
  mypic/.pic = {
    \draw[shift only] (1,0) circle [radius=0.1cm];
  }
}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0, 0) grid (2, 1);
\pic[rotate=40] (p) at (1,0) {mypic};
\end{tikzpicture}
\end{document}

Output

enter image description here

You must log in to answer this question.

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