Как правильно вращать ось с помощью tikzpicture

Как правильно вращать ось с помощью tikzpicture

У меня есть две системы координат, между которыми есть смещение и поворот.

Я попытался визуализировать это на следующем примере:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}[thick]
    \draw[-latex] (0,0) -- (4,0)  node[right, text width=5em] {$X$};
    \draw[-latex] (0,0) -- (0,4)  node[right, text width=5em] {$Y$};

    \begin{scope}[rotate=0,draw=red]
        \draw[->] (3,2) -- (7,2)  node[right, text width=5em] {$X'$};
        \draw[->] (3,2) -- (3,6)  node[right, text width=5em] {$Y'$};
    \end{scope}

    \draw[->, postaction={decorate, decoration={text along path, text align={center},text={${\overrightarrow{R}}{\;}$}}}] (0,0) -- (3,2)  node[right, text width=5em] () {};

\end{tikzpicture}

\end{document}

вращать_0

как только я изменюсь

\begin{scope}[rotate=0,draw=red]

к

\begin{scope}[rotate=20,draw=red]

Я получил: вращать_20

Как мне поместить начало моей системы координат X'Y' в положение (3,2) в моей системе координат XY?

Кроме того, я хотел бы разместить $\overrightarrow{R}$ немного выше. Как мне разместить его над вектором?

решение1

Поворот, по умолчанию использует точку (0,0): Посмотрите на оранжевую стрелку, которая является стрелкой R, повернутой на 20 градусов:

введите описание изображения здесь

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}[thick]
    \draw[-latex] (0,0) -- (4,0)  node[right, text width=5em] {$X$};
    \draw[-latex] (0,0) -- (0,4)  node[right, text width=5em] {$Y$};

    \begin{scope}[rotate=20,draw=red]
        \draw[->] (3,2) -- (7,2)  node[right, text width=5em] {$X'$};
        \draw[->] (3,2) -- (3,6)  node[right, text width=5em] {$Y'$};
    \end{scope}
    \begin{scope}
      \draw[->,orange,rotate=20] (0,0)--(3,2);
    \end{scope}

    \draw[->, postaction={decorate, decoration={text along path, text align={center},text={${\overrightarrow{R}}{\;}$}}}] (0,0) -- (3,2)  node[right, text width=5em] () {};

\end{tikzpicture}

\end{document}

Поэтому вам придется изменить точку по умолчанию (центр ракурса), и это можно сделать с помощью команды rotate around:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}[thick]
    \draw[-latex] (0,0) -- (4,0)  node[right, text width=5em] {$X$};
    \draw[-latex] (0,0) -- (0,4)  node[right, text width=5em] {$Y$};

    \begin{scope}[rotate around={20:(3,2)},draw=red]
        \draw[->] (3,2) -- (7,2)  node[right, text width=5em] {$X'$};
        \draw[->] (3,2) -- (3,6)  node[right, text width=5em] {$Y'$};
    \end{scope}

    \draw[->, postaction={decorate, decoration={text along path, text align={center},text={${\overrightarrow{R}}{\;}$}}}] (0,0) -- (3,2)  node[right, text width=5em] () {};

\end{tikzpicture}

\end{document}

введите описание изображения здесь

Связанный контент