
Ao usar coordenadas 3D no TikZ, existe uma maneira de alterar a direção do vetor Z para que ele não aponte para um ângulo de 45 graus no plano XY? Dado o desenho de um cubo como o seguinte, eu gostaria de uma boa maneira de deslocar a face posterior sem ter que ajustar as coordenadas.
\begin{tikzpicture}
\draw (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
\draw (0,0,1) -- (1,0,1) -- (1,1,1) -- (0,1,1) -- cycle;
\draw (0,0,0) -- (0,0,1); \draw (1,0,0) -- (1,0,1); \draw (0,1,0) -- (0,1,1); \draw (1,1,0) -- (1,1,1);
\end{tikzpicture}
Olhando o manual, só consegui encontrar a capacidade de alterar o comprimento do vetor Z, não sua direção.
Responder1
Você pode especificar o vetor unitário para a direção z com a z
tecla, fazendo com que o vetor z apareça em um determinado ângulo no plano XY.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[z={(60:0.5cm)}]
\draw (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
\draw (0,0,1) -- (1,0,1) -- (1,1,1) -- (0,1,1) -- cycle;
\draw (0,0,0) -- (0,0,1); \draw (1,0,0) -- (1,0,1); \draw (0,1,0) -- (0,1,1); \draw (1,1,0) -- (1,1,1);
\end{tikzpicture}
\begin{tikzpicture}[z={(3cm,1.5cm)}]
\draw (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
\draw (0,0,1) -- (1,0,1) -- (1,1,1) -- (0,1,1) -- cycle;
\draw (0,0,0) -- (0,0,1); \draw (1,0,0) -- (1,0,1); \draw (0,1,0) -- (0,1,1); \draw (1,1,0) -- (1,1,1);
\end{tikzpicture}
\end{document}
Responder2
Você pode usar rotate around y=<angle>
. Da mesma forma, existe rotate around x=<angle>
e rotate around z=<angle>
.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
\draw (0,0,1) -- (1,0,1) -- (1,1,1) -- (0,1,1) -- cycle;
\draw (0,0,0) -- (0,0,1); \draw (1,0,0) -- (1,0,1);
\draw (0,1,0) -- (0,1,1); \draw (1,1,0) -- (1,1,1);
\draw[red] (0,0,0) -- (0,0,2)node {$z$};
\end{tikzpicture}
\begin{tikzpicture}[rotate around y=45]
\draw (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
\draw (0,0,1) -- (1,0,1) -- (1,1,1) -- (0,1,1) -- cycle;
\draw (0,0,0) -- (0,0,1); \draw (1,0,0) -- (1,0,1);
\draw (0,1,0) -- (0,1,1); \draw (1,1,0) -- (1,1,1);
\draw[red] (0,0,0) -- (0,0,2)node {$z$};
\end{tikzpicture}
\begin{tikzpicture}[rotate around x=45]
\draw (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
\draw (0,0,1) -- (1,0,1) -- (1,1,1) -- (0,1,1) -- cycle;
\draw (0,0,0) -- (0,0,1); \draw (1,0,0) -- (1,0,1);
\draw (0,1,0) -- (0,1,1); \draw (1,1,0) -- (1,1,1);
\draw[red] (0,0,0) -- (0,0,2)node {$z$};
\end{tikzpicture}
\begin{tikzpicture}[rotate around z=5]
\draw (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
\draw (0,0,1) -- (1,0,1) -- (1,1,1) -- (0,1,1) -- cycle;
\draw (0,0,0) -- (0,0,1); \draw (1,0,0) -- (1,0,1);
\draw (0,1,0) -- (0,1,1); \draw (1,1,0) -- (1,1,1);
\draw[red] (0,0,0) -- (0,0,2)node {$z$};
\end{tikzpicture}
\end{document}