Tikz 3d 三角视图坐标计算错误

Tikz 3d 三角视图坐标计算错误

我试图在 xy 平面上画一条线,并在 yz 平面上以恒定的 x 位置画几个圆。

问题在于,圆偏离了位置(圆心的 x 坐标恰好是从原点绘制的线的末端的 x 坐标,但圆却绘制在其他地方)。

梅威瑟:

\documentclass{standalone}
\usepackage{tikz}
%\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,3d}


% see http://tex.stackexchange.com/a/48776/70600
 \makeatletter
 \tikzoption{canvas is xy plane at z}[]{%
     \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
     \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
     \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
     \tikz@canvas@is@plane
 }
 \makeatother 

% Drawing Views
\tikzstyle{trimetric}=[x={(0.926cm,-0.207cm)},y={(0cm,0.837cm)},z={(-0.378cm,-0.507cm)}]


\begin{document}
    \begin{tikzpicture}[trimetric, scale=0.1]

        \draw[dashed] (-1, 0,  0) -- (1, 0,  0);
        \draw[dashed] (0, -1,  0) -- (0, 1,  0);
        \draw[dashed] (0, 0,  -1) -- (0, 0,  1);

        \coordinate (O) at (0, 0, 0);
        \draw[-latex] (O) -- +(10, 0,  0) node [right] {$x$};
        \draw[-latex] (O) -- +(0,  10, 0) node [left] {$y$};
        \draw[-latex] (O) -- +(0,  0, 10 ) node [above] {$z$};  


        \begin{scope}[canvas is yz plane at x=120.0pt]
            \filldraw circle (.01); % center point
            \draw circle (91.62pt); % radius
        \end{scope}


        \begin{scope}[canvas is xy plane at z=0]
            \draw[] (0.0pt, 0.0pt) -- (120.0pt, 120.0pt);
        \end{scope}

    \end{tikzpicture}

\end{document}

结果:

tex 编译的结果

答案1

使用canvas ... at内部的\pgfpointxyz

后一个函数只取数字而不是维度;\pgfpointxyz{a}{b}{c}给出a乘以x-向量加上b乘以y-向量加上c乘以z-向量。

特别是单位被忽略(而不是抛出错误)。
如果你写,canvas is yz plane at x=120.0你会得到相同的结果。

您需要xxyz系统中指定。由于您的x-vector 有长度,因此.949cm您应该写

x = 120.0*.949/28.4

获取对应于120ptsince的位置1cm=28.4pt

示例输出

\documentclass{standalone}
\usepackage{tikz}
%\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,3d}


% see http://tex.stackexchange.com/a/48776/70600
 \makeatletter
 \tikzoption{canvas is xy plane at z}[]{%
     \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
     \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
     \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
     \tikz@canvas@is@plane
 }
 \makeatother 

% Drawing Views
\tikzstyle{trimetric}=[x={(0.926cm,-0.207cm)},y={(0cm,0.837cm)},z={(-0.378cm,-0.507cm)}]


\begin{document}
    \begin{tikzpicture}[trimetric, scale=0.1]

        \draw[dashed] (-1, 0,  0) -- (1, 0,  0);
        \draw[dashed] (0, -1,  0) -- (0, 1,  0);
        \draw[dashed] (0, 0,  -1) -- (0, 0,  1);

        \coordinate (O) at (0, 0, 0);
        \draw[-latex] (O) -- +(10, 0,  0) node [right] {$x$};
        \draw[-latex] (O) -- +(0,  10, 0) node [left] {$y$};
        \draw[-latex] (O) -- +(0,  0, 10 ) node [above] {$z$};  

        \begin{scope}[canvas is yz plane at x=120.0*.949/28.4]
            \filldraw circle (.01); % center point
            \draw circle (91.62pt); % radius
        \end{scope}

        \begin{scope}[canvas is xy plane at z=0]
            \draw[red,->] (0.0pt, 0.0pt) -- (120.0pt,0);
        \end{scope}

    \end{tikzpicture}

\end{document}

相关内容