改变 tikz-3dplot 图片中的轴

改变 tikz-3dplot 图片中的轴

如下图所示

在此处输入图片描述

\documentclass{article}
\usepackage{tikz,tikz-3dplot} 
\begin{document}
\begin{tikzpicture}[scale=3]
    \draw[thick,->,black] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north east]{$y$};
    \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=east]{$z$};
\end{tikzpicture}
\end{document}

如下面所述:

  • x 轴:向右
  • y 轴:向上
  • z 轴:朝向您

我需要做什么才能实现以下目标:

  • x 轴:朝向您
  • y 轴:向右
  • z 轴:向上

不言而喻,输入的任何坐标都必须遵守改变的轴。

答案1

尝试坐标矩阵变换选项cm=...

\documentclass{article}
\usepackage{tikz,tikz-3dplot} 
\begin{document}
\begin{tikzpicture}[scale=3]
    \draw[thick,->,black] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north east]{$y$};
    \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=east]{$z$};
\end{tikzpicture}
\begin{tikzpicture}[scale=3,cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm]
    \draw[thick,->,black] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (0,0,0) -- (0,2,0) node[anchor=north east]{$y$};
    \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=east]{$z$};
\end{tikzpicture}
\end{document}

编辑:TikZ 提供了一个坐标变换矩阵 cm = (a,b;c,d),可用于将坐标 (x,y) 转换为一组新坐标 (X,Y) = (a,b;c,d)*(x,y) = (ax+by;cx+dy)。在 OP 的例子中,我们希望 X 的方向“朝向您”,即 X = -x - y。Y 坐标必须“向右”,即 Y = x。解 a、b、c 和 d 我们发现 a = -1,b = -1,c = 1 d = 0 这就是选项 cm={a,b,c,d,(0,0)} 中给出的,其中 (0,0) 是原点的 x 和 y 偏移量。新的 Z 坐标是 Z = X + Y = -y。

在绘制之前,坐标会与 TikZ 单位向量相乘。默认值为 x=1cm、y=1cm 和 z=-3.85mm。因此,为了在新方向上获得相同的轴长度和方向,我们需要将其更改为 x=3.85mm、y=1cm 和 z=-1cm。由于 y=1cm 是默认值,因此省略。

我不确定上面的内容是否清楚...请随意改进解释。

答案2

事实上你所要做的就是改变前两行:

默认轴方向正如您所述。

在此处输入图片描述

所以:

\tdplotsetmaincoords{60}{105} % rotate 60 degrees around x axis, then 105 degrees about z
\begin{tikzpicture}[tdplot_main_coords]

来自的命令手动的如下(另见此例)

句法:\tdplotsetmaincoords{ theta }{ phi }

参数:

  • theta:坐标系绕 x 轴旋转的角度(以度为单位)。
  • phi:坐标系绕 z 轴旋转的角度(以度为单位)。

在此处输入图片描述

相关内容