对 3D 坐标系统的困惑

对 3D 坐标系统的困惑

我正在绘制一个 3d 框架。我使用类似(xyz cs:x = 12, y = 6, z = -6)来指定坐标。但是,我制作的图形看起来很丑。
特别是,虚线蓝绿色角落的坐标与 的刻度不一致z-axis(参见顶角点和Quantify的刻度)z-axis笔记:正如@Torbjørn T. 在评论中指出的那样,这是由于一个愚蠢的错误造成的。不过,我仍然对以下更普遍的问题感兴趣。)

我怎样才能改善它更多的3D 吗?

tikz-3d

\documentclass{beamer}
\usepackage{tikz, adjustbox}
\usetikzlibrary{shapes, positioning, calc}

\begin{document}

\begin{frame}
\begin{adjustbox}{max totalsize = {0.9\textwidth}{0.70\textheight}, center}
\begin{tikzpicture}[x = 0.5cm, y = 0.5cm, z = 0.3cm, >=stealth, font = \Large]

\node[fill = brown, circle] at (0,0,0) {};
% The axes
\draw[->, thick] (xyz cs:x=0) -- (xyz cs:x = 18) node[above, font = \Large] {$\textrm{Consistency Models}$};
\draw[->, thick] (xyz cs:y=0) -- (xyz cs:y = 12) node[above, font = \Large] {$\textrm{Assurance Methods}$};
\draw[->, thick] (xyz cs:z=0) -- (xyz cs:z = -18) node[right, font = \Large] {$\textrm{Data Types}$};

% The ticks

% ticks for consistency models
\draw[very thick] (6,-3pt) -- (6,3pt) node[below = 6pt, align = center] {\texttt{Weak}};
\draw[very thick] (12,-3pt) -- (12,3pt) node[below = 6pt, align = center] {\texttt{Strong}};

% ticks for assurance methods
\draw[very thick] (-3pt,5) -- (3pt,5) node[below = 3pt] {\texttt{Maintain}};
\draw[very thick] (-3pt,10) -- (3pt,10) node[below = 3pt] {\texttt{Quantify}};

% ticks for data types
\draw[very thick] (xyz cs:y=-0.3pt,z=-6) -- (xyz cs:y=0.3pt,z=-6) node[align = center] { \texttt{Register}};
\draw[very thick] (xyz cs:y=-0.3pt,z=-12) -- (xyz cs:y=0.3pt,z=-12) node[align = center]
{\texttt{Transaction}};

\begin{scope}[line width = 1, teal]
    \draw[dashed]
      (xyz cs:z = -6) coordinate (z) --
      (xyz cs:y = 6, z = -6) coordinate (yz) --
      (xyz cs:y = 6) coordinate (y) --
      (xyz cs:x = 12, y = 6) coordinate (xy) --
      (xyz cs:x = 12, y = 6, z = -6) coordinate (xyz) --
      (xyz cs:x = 12, z = -6) coordinate (xz) -- cycle;
    \draw[dashed, line width = 1] (yz) -- (xyz);
    \draw[dashed, line width = 1] (xy) -- (12,0) -- (xz);

    \node (case-maintain) [fill = blue, circle, inner sep = 3pt, label = {[blue, font = \Large] -90: $\qquad \qquad$ (\textbf{2.1})}] at (xyz) {};

    \draw[dashed]
      (xyz cs:z = -6) coordinate (z) --
      (xyz cs:y = 12, z = -6) coordinate (yz) --
      (xyz cs:y = 12) coordinate (y) --
      (xyz cs:x = 12, y = 12) coordinate (xy-am) --
      (xyz cs:x = 12, y = 12, z = -6) coordinate (xyz) --
      (xyz cs:x = 12, y = 6, z = -6);
    \draw[dashed, line width = 1] (yz) --  (xyz);
    \draw[dashed, line width = 1] (xy-am) -- (12,0) -- (xz);

    \node (case-quantify) [fill = blue, circle, inner sep = 3pt, label = {[blue, font = \Large] -90: $\qquad \qquad$ (\textbf{2.2})}] at (xyz) {};
\end{scope}
\end{tikzpicture}
\end{adjustbox}
\end{frame}
\end{document}

答案1

这里有一个想法,教你如何做到这一点。另外,\foreach这也是你的朋友 ;)

标题

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

\begin{document}

\begin{tikzpicture}
[   x={(-10:1cm)},
    y={(220:1cm)},
    z={(90:1cm)},
    scale=3,
]
    \draw[-stealth] (0,0,0) -- (2.2,0,0) node[pos=1, above right] {Consistency models};
    \draw[-stealth] (0,0,0) -- (0,2.2,0) node[pos=1, below left] {Data Types};
    \draw[-stealth] (0,0,0) -- (0,0,2.2) node[pos=1, above right] {Assurance Models};

    \foreach \z in {0,...,2}
    {   \draw[teal, densely dashed, very thick] (0,0,\z) -- (2,0,\z) -- (2,1,\z) -- (0,1,\z) -- cycle;
        \node[blue, circle, fill, inner sep=2pt, label=-45:(2.\z)] at (2,1,\z)  {};
    }

    \foreach \x/\y in {0/0, 0/1, 2/0, 2/1}
    {   \draw[teal, densely dashed, thick] (\x,\y,0) -- (\x,\y,2);
    }

    \foreach \c/\x/\y/\z in {1/Weak/Register/Maintain,2/Strong/Transaction/Quantify}
    {   \node[below left, font=\footnotesize] at (\c,0,0) {\x};
        \node[circle, fill, inner sep=1pt] at (\c,0,0) {};
        \node[above left, font=\footnotesize] at (0,\c,0) {\y};
        \node[circle, fill, inner sep=1pt] at (0,\c,0) {};
        \node[left, font=\footnotesize] at (0,0,\c) {\z};
        \node[circle, fill, inner sep=1pt] at (0,0,\c) {};
    }
\end{tikzpicture}

\end{document}

输出

在此处输入图片描述

相关内容