如何使用 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' 座標系的原點放置在 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}

在此輸入影像描述

相關內容