tikzpicture を使用して軸を正しく回転させる方法

tikzpicture を使用して軸を正しく回転させる方法

間にオフセットと回転がある 2 つの座標フレームがあります。

次の例を使用して、それを視覚化してみました。

\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' 座標フレームの原点を XY 座標系の (3,2) の位置に配置するにはどうすればよいですか?

さらに、$\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}

ここに画像の説明を入力してください

関連情報