There must be an easy way to compute the required values of xslant
and yslant
to obtain the text in the "correct plane". Below I have guessed at then, but that is a very tedious process. The desired results should be that the following lines should not have any magic numbers:
\tikzset{yz slant style/.style={red, yslant=-0.5, xslant=-0.1}}
\tikzset{xy slant style/.style={blue, yslant=-0.25, xslant=1 }}
\tikzset{xz slant style/.style={orange, yslant=1, xslant=0.05}}
and instead should be based on the values of \xc
,\xs
,\yc
, and \ys
(or \elevation
and \anglerot
). My guessed value produce something which I think are close:
Notes:
- I realize that this is more of a math question, but without fully understanding how
tikz
/pgf
works I don't know how to compute them. - The preamble code is from 3D Arrow Tips for TikZ/pgfplots.
Code:
\documentclass{scrartcl}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
%% https://tex.stackexchange.com/a/51388/4301
\newcommand*\elevation{14}
\newcommand*\anglerot{-50}
\pgfmathsetmacro\xc{cos(\anglerot)}
\pgfmathsetmacro\xs{sin(\anglerot)}
\pgfmathsetmacro\yc{cos(\elevation)}
\pgfmathsetmacro\ys{sin(\elevation)}
\newcommand*\axexthreed{\xs*1cm,-\xc*1cm}
\newcommand*\axeythreed{\yc*1cm,-\ys*1cm}
\newcommand*\axezthreed{0cm,1cm}
\newcommand*{\CoordX}{3}%
\newcommand*{\CoordY}{4}%
\newcommand*{\CoordZ}{5}%
%% How do I compute these:
\tikzset{yz slant style/.style={red, yslant=-0.5, xslant=-0.1}}
\tikzset{xy slant style/.style={blue, yslant=-0.25, xslant=1}}
\tikzset{xz slant style/.style={orange, yslant=1, xslant=0.05}}
\begin{tikzpicture}[x = {(\axexthreed)},
y = {(\axeythreed)},
z = {(\axezthreed)},
]
\draw[black, ultra thick,-latex] (-1,0,0) -- (\CoordX,0,0) node[black,left=6pt] {$x$};
\draw[black, ultra thick,-latex] (0,-1,0) -- (0,\CoordY,0) node[black,right=6pt] {$y$};
\draw[black, ultra thick,-latex] (0,0,-1) -- (0,0,\CoordZ) node[black,above=6pt] {$z$};
\foreach \x in {1,...,\CoordX} {
\draw [thin, draw=gray] (\x,\CoordY,0) -- (\x,0,0)
node [left, yz slant style] at ($(\x,0,0)+(-0.2,0,0)$) {\x};
}
\foreach \x in {1,...,\CoordY} {
\draw [thin, draw=gray] (\CoordX,\x,0) -- (0,\x,0)
node [right, xy slant style] at ($(0,\x,0)+(-0.4,-0.3,0)$) {\x};
}
\foreach \x in {1,...,\CoordZ} {
\draw [thin, draw=gray] (\CoordX,0,\x) -- (0,0,\x)
node [right, xz slant style] at ($(0,0,\x)+(0,-0.0,-0.2)$) {\x};
}
\end{tikzpicture}
\end{document}
Best Answer
Okay, yslant to spin vertical letters, rotate and xslant to lay letters flat, xscale and yscale for forehortening.