明可夫斯基图非正交轴

明可夫斯基图非正交轴

我想画一个两个参考系的闵可夫斯基图,比如在此处输入图片描述

使用 LaTeX,也许是 pgfplots。我使用 pgfplots 绘制了常规图,发现轴可以旋转,但还没有找到使用非正交轴的方法。这可能吗?如果可以,怎么做?

理想情况下,我想定义非正交坐标系,然后仅通过在该坐标系中指定坐标即可绘图。

如果不可能的话,我就必须手动为轴绘制箭头,但是我该如何添加刻度标记和刻度标签呢?

答案1

TikZ 和 PGFPlot 都有自己的单位向量。需要时,最好只更改 PGFPlots 中的向量,如下所示:

\documentclass[tikz, border=1 cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset  {compat=1.17}
\begin{document}
\begin{tikzpicture}

\begin{axis}[
   red,
   anchor=center,
   axis lines=center,
   xmin=-5, xmax=5,
   ymin=-5,ymax=5,
   xtick distance=1,  xticklabel={\empty},
   ytick distance=1,  yticklabel={\empty},
   x={1cm}, y={1cm},
   xlabel={$x$}, ylabel={$ct$},
   thick, every tick/.style={thick},
   ]
   \addplot[mark=*] coordinates {(1,3)};
   \draw (1,3) circle[radius=1];
\end{axis}

\begin{axis}[
   green!50!black,
   anchor=center,
   axis lines=center,
   xmin=-4, xmax=4,
   ymin=-4,ymax=4,
   xtick distance=1,  xticklabel={\empty},
   ytick distance=1,  yticklabel={\empty},
   x={(1.25cm,0.75cm)}, y={(0.75cm,1.25cm)},
   xlabel={$x'$}, ylabel={$ct'$},
   thick, every tick/.style={thick},
   ]
   \addplot[mark=*] coordinates {(1,1)};
   \draw (1,1) circle[radius=1];
\end{axis}

\end{tikzpicture}
\end{document}

图形

答案2

我认为这里更好的方法是scope。在其中您可以定义轴,并且您在其中绘制的所有内容都参考这些轴。例如:

\documentclass[border=2mm]{standalone}
\usepackage   {tikz}

\tikzset%
{%
  red axis/.style={thick,red!50!black},
  green axis/.style={thick,green!50!black},
}

\begin{document}
\begin{tikzpicture}[line cap=round]
% x, ct axes (red)
\begin{scope} % this scope in not really necessary
  \draw[red axis] (-5,0) -- (5,0);
  \draw[red axis] (0,-5) -- (0,5);
  \foreach\i in {1,...,5}
  {% ticks
    \draw[red axis] (-\i,-0.05) -- (-\i,0.05);
    \draw[red axis] ( \i,-0.05) -- ( \i,0.05);
    \draw[red axis] (-0.05,-\i) -- (0.05,-\i);
    \draw[red axis] (-0.05, \i) -- (0.05, \i);
  }
  \draw[gray,dashed] (1,0) -- (1,1) -- (0,1);
  \draw[gray,dashed] (4,0) -- (4,1);
  \draw[gray,dashed] (0,4) -- (1,4);
  \draw[red] (1,1) -- (4,1) -- (4,4) -- (1,4) -- cycle;
  \draw[red] (2.5,2.5) circle (1.5);
  \node at (5,0) [right] {$x$};
  \node at (0,5) [above] {$ct$};
  \node at (1,0) [below] {$u$};
  \node at (0,1) [left]  {$u$};
\end{scope}
% x', ct' axes (green)
\begin{scope}[x={(30:1.5 cm)}, y={(60:1.5 cm)}]
  \draw[green axis] (-5,0) -- (5,0);
  \draw[green axis] (0,-5) -- (0,5);
  \foreach\i in {1,...,5}
  {% ticks
    \draw[green axis] (-\i,-0.05) -- (-\i,0.05);
    \draw[green axis] ( \i,-0.05) -- ( \i,0.05);
    \draw[green axis] (-0.05,-\i) -- (0.05,-\i);
    \draw[green axis] (-0.05, \i) -- (0.05, \i);
  }
  \draw[gray,dashed] (1,0) -- (1,1) -- (0,1);
  \draw[gray,dashed] (4,0) -- (4,1);
  \draw[gray,dashed] (0,4) -- (1,4);
  \draw[green] (1,1) -- (4,1) -- (4,4) -- (1,4) -- cycle;
  \draw[green] (2.5,2.5) circle (1.5);
  \node at (5,0) [right] {$x'$};
  \node at (0,5) [above] {$ct'$};
  \node at (1,0) [below] {$u'$};
  \node at (0,1) [left]  {$u'$};
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

请注意,绿色轴上的刻度并不正交,因为轴也不正交。我更喜欢它们保持原样,但如果您需要它们正交,如您的示例所示,则需要将它们绘制在范围环境之外。

答案3

我不知道原帖者到底想要什么。如果他只是想要那个图形,那么使用简单的 TikZ 加上一些合适的scope几何变换xscaleyscale可以了。

在此处输入图片描述

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\begin{scope}[brown]
\draw (-5,0)--(5,0) node[right]{$X$};       
\draw (0,-5)--(0,5) node[above]{$ct$};
\foreach \i in {-5,...,5}
\draw (\i,.1)--(\i,-.1) (.1,\i)--(-.1,\i)
(1,0) node[below=1mm]{$U$}
(0,1) node[left=1mm]{$U$}
;
\end{scope}

\newcommand\Xpunit{1.2}
\newcommand\Xpangle{55} % angle from the X axe
\begin{scope}[teal,rotate=\Xpangle,xscale=\Xpunit]
\draw (-4,0)--(4,0) node[right]{$X'$};      
\foreach \i in {-4,...,-1,1,2,...,4}
\draw (\i,.1)--(\i,-.1)
(1,0) node[below right=1mm]{$U'$};
\end{scope}

\newcommand\ctpunit{1.2}
\newcommand\ctpangle{35} % angle from the ct axe
\begin{scope}[teal,rotate=\ctpangle,yscale=\Xpunit]
\draw (0,-4)--(0,4) node[above]{$ct'$};     
\foreach \i in {-4,...,-1,1,2,...,4}
\draw (.1,\i)--(-.1,\i)
(0,1) node[left=1mm]{$U'$};
\end{scope}

\fill (0,0) circle(2pt);
\end{tikzpicture}
\end{document}

相关内容