如何计算 xslant 和 yslant

如何计算 xslant 和 yslant

一定有一种简单的方法来计算所需的和的值xslantyslant从而获得“正确平面”中的文本。下面是我猜到的,但这是一个非常繁琐的过程。理想的结果应该是以下几行不应该有任何神奇的数字:

\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}}

而应该基于\xc\xs\yc\ys(或\elevation\anglerot)的值。我的猜测值产生了一些我认为是 关闭

在此处输入图片描述

笔记:

  • 我意识到这更像是一个数学问题,但如果不完全理解如何tikz工作pgf,我就不知道如何计算它们。
  • 前导码来自TikZ/pgfplots 的 3D 箭头提示

代码:

\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}

答案1

好的,yslant 用于旋转垂直字母,rotate 和 xslant 用于平放字母,xscale 和 yscale 用于缩短字母。

\tikzset{yz slant style/.style={red, yslant=-tan(\elevation), xscale=cos(\elevation)}}
\tikzset{xy slant style/.style={blue, xslant=-tan(\elevation+\anglerot), rotate=-\elevation, yscale=cos(\anglerot)}}
\tikzset{xz slant style/.style={orange, yslant=-cot(\anglerot), xscale=sin(-\anglerot)}}

轴

相关内容