我有两个坐标系,它们之间有偏移和旋转。
我尝试使用以下示例将其形象化:
\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}
一旦我改变
\begin{scope}[rotate=0,draw=red]
到
\begin{scope}[rotate=20,draw=red]
我怎样才能将 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}