2 个正交坐标旋转系统中的点坐标

2 个正交坐标旋转系统中的点坐标

我正在尝试使用 在 2 个正交坐标系中绘制一个按一定角度旋转的点pgfplots

我设法创建了两个带有一个点的坐标系统:

\documentclass[a4paper,11pt]{article}
\usepackage[latin1]{inputenc}
\usepackage[italian]{babel}
\usepackage{amsmath}
\usepackage{bbold}
\usepackage{pgfplots}
\pgfplotsset{compat=newest, width=10cm}

\begin{figure}[htbp]
  \begin{center}
    \begin{tikzpicture}
      \begin{axis}[
        anchor=origin,
      ticks=none,
      nodes near coords,
      xmin=-0.3, xmax=2, ymin=-0.3, ymax=2,
      axis lines=middle,
      xlabel=$x$,
      ylabel=$y$,
      ]
      \addplot+ [only marks, point meta=explicit symbolic] coordinates {(1,1.5) [$P$]};
      \draw [dashed] (0,1.5) -| (1,0);
      \draw [thick, ->] (axis cs:0.5,0) arc [radius=0.56, start angle=0, end angle=20];
      \node at (axis cs:0.5, 0.1) [anchor=west] {$\vartheta$};
      \end{axis}

      \begin{axis}[
      anchor=origin,
        rotate around={20:(current axis.origin)},
      red,
      ticks=none,
      xmin=-0.3, xmax=2, ymin=-0.3, ymax=2,
      axis lines=middle,
      xlabel=$v_1$,
      ylabel=$v_2$,
      ]
      \draw [red, dashed] (0,1.5) -| (1,0);
      \end{axis}
    \end{tikzpicture}
  \end{center}
  \caption{Rotated coordinate system.}
  \label{fig:coord_systems}
\end{figure}

\end{document}

但我不知道如何为旋转系统的同一点绘制虚线。

在此处输入图片描述

有没有更好的方法可以做到这一点,而不是尝试多次直到重叠?

答案1

纯 Ti 溶液Z,没有,pgfplots但是你明白了。

两个坐标系中的同一点

您只需通过旋转来计算新坐标系中 P 的位置。

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[scale=3]
        \newcommand{\xmax}{2}
        \newcommand{\ymax}{2}
        \newcommand{\xP}{1}
        \newcommand{\yP}{1.5}
        \newcommand{\ang}{-20}
        \pgfmathsetmacro{\dist}{sqrt(\xP*\xP+\yP*\yP)}
        
        
        \draw[<->] (0,\ymax) node[below right] {$y$} |- (\xmax,0) node[above left] {$x$};
        \coordinate (P) at (\xP,\yP);
        \draw[dashed] (0,\yP) -| (\xP,0) node[fill=blue,midway, circle,inner sep=0pt, minimum width=5pt,label={[above right,blue] $P$}] {};
        
        \begin{scope}[rotate=-\ang]
            \draw[<->,red] (0,\ymax) node[below right] {$v_2$} |- (\xmax,0) node[above left] {$v_1$};
            \pgfmathsetmacro{\xQ}{\xP*cos(\ang)-\yP*sin(\ang)}
            \pgfmathsetmacro{\yQ}{\yP*cos(\ang)+\xP*sin(\ang)}
            \draw[dashed] (0,\yQ) -| (\xQ,0);
        \end{scope}
        
        \draw [thick, ->] (0.8,0) arc [radius=0.8, start angle=0, end angle=-\ang] node[midway,right] {$\vartheta$};
    
    \end{tikzpicture}
\end{document}

答案2

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis equal,
anchor=origin,
ticks=none,
nodes near coords,
xmin=-0.3, xmax=2, ymin=-0.3, ymax=2,
axis lines=middle,
xlabel=$x$, ylabel=$y$,
]
\draw[dashed] (0,1.5) -| (1,0);
\addplot+[only marks, point meta=explicit symbolic] coordinates {(1,1.5) [$P$]};
\draw[thick, ->] (0.5,0) arc[radius=0.5, start angle=0, end angle=20];
\node[anchor=west] at (0.5, 0.1) {$\vartheta$};
\end{axis}
\begin{axis}[
red,
axis equal,
anchor=origin,
rotate around={20:(current axis.origin)},
ticks=none,
xmin=-0.3, xmax=2, ymin=-0.3, ymax=2,
axis lines=middle,
xlabel=$v_1$, ylabel=$v_2$,
transform shape,
]
\draw[dashed] let \p1=([rotate around={-20:(0,0)}]1,1.5) in (\p1-|0,0) -- (\p1) -- (\p1|-0,0);
\end{axis}
\end{tikzpicture}
\end{document}

两张图,其中一张经过旋转

相关内容