# How to compute xslant and yslant

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}

• I avoid yslant. Rotate together with xslant are enough. The rotate angle should be obvious, and the xslant is either the cos or sin. Apr 8, 2014 at 3:42
• @JohnKormylo: Hadn't thought of that. You want to post a complete answer? Apr 8, 2014 at 3:51
• Related Question: Text projection onto plane in 3D pgf plots. Nov 18, 2014 at 3:12

\tikzset{yz slant style/.style={red, yslant=-tan(\elevation), xscale=cos(\elevation)}}
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8028085231781006, "perplexity": 17752.760273694374}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2022-33/segments/1659882571692.3/warc/CC-MAIN-20220812105810-20220812135810-00340.warc.gz"}