TikZ 角度库与 3d 库不兼容吗?

TikZ 角度库与 3d 库不兼容吗?

我最近发现了anglesTikZ 库,当需要注释角度时它非常方便。

当我尝试将其与库一起使用时,我遇到了一个问题3d,因为绘制圆弧时没有使用定义的画布平面。以下是一个例子(alpha 角应绘制为绿色圆弧):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes,3d}

\begin{document}
\begin{tikzpicture}
    \draw[blue,->] (0,0)coordinate(O) --  (1,0,0)node[below right]{$\vec{x}$};
    \draw[blue,->] (O) --  (0,1)node[above]{$\vec{y}$};    
    \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C);
    \draw[red] pic ["$\alpha$", draw, ->] {angle};
\end{tikzpicture}

\def\w{40} \def\aa{30}
\begin{tikzpicture}[x={({cos(\w)*1cm},{-sin(\w)*sin(\aa)*1cm})},
        y={({sin(\w)*1cm},{cos(\w)*sin(\aa)*1cm})},
        z={(0,{cos(\aa)*1cm})}]
    \draw[blue,->] (0,0,0)coordinate(O) --  (1,0,0)node[below right]{$\vec{x}$};
    \draw[blue,->] (O) --  (0,1,0)node[above]{$\vec{y}$};    
    \draw[blue,->] (O) --  (0,0,1)node[above]{$\vec{z}$};

    \begin{scope}[canvas is xy plane at z=0]
        \draw[dashed] (0,0) circle (1);
        \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C);
        \draw[red] pic ["$\alpha$", draw, ->] {angle}; % incorrect
        \draw[green] (0:0.6) arc (0:45:0.6); % correct 
    \end{scope}

\end{tikzpicture}
\end{document}

例子 是否有一个简单的办法可以让它正常工作?

请注意,该命令没有问题right angle,因为情节是由平行段组成的。

答案1

使用transform shape

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes,3d}

\begin{document}
\begin{tikzpicture}
    \draw[blue,->] (0,0)coordinate(O) --  (1,0,0)node[below right]{$\vec{x}$};
    \draw[blue,->] (O) --  (0,1)node[above]{$\vec{y}$};    
    \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C);
    \draw[red] pic ["$\alpha$", draw, ->] {angle};
\end{tikzpicture}

\def\w{40} \def\aa{30}
\begin{tikzpicture}[x={({cos(\w)*1cm},{-sin(\w)*sin(\aa)*1cm})},
        y={({sin(\w)*1cm},{cos(\w)*sin(\aa)*1cm})},
        z={(0,{cos(\aa)*1cm})}]
    \draw[blue,->] (0,0,0)coordinate(O) --  (1,0,0)node[below right]{$\vec{x}$};
    \draw[blue,->] (O) --  (0,1,0)node[above]{$\vec{y}$};    
    \draw[blue,->] (O) --  (0,0,1)node[above]{$\vec{z}$};

    \begin{scope}[canvas is xy plane at z=0]
        \draw[dashed] (0,0) circle (1);
        \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C);
        \draw[red] pic ["$\alpha$", draw, ->,transform shape] {angle}; % correct
        \draw[green] (0:0.6) arc (0:45:0.6); % correct 
    \end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

您也可以变换角弧,但不能变换文本。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,quotes,3d}

\begin{document}
\begin{tikzpicture}
    \draw[blue,->] (0,0)coordinate(O) --  (1,0,0)node[below right]{$\vec{x}$};
    \draw[blue,->] (O) --  (0,1)node[above]{$\vec{y}$};    
    \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C);
    \draw[red] pic ["$\alpha$", draw, ->] {angle};
\end{tikzpicture}

\def\w{40} \def\aa{30}
\begin{tikzpicture}[x={({cos(\w)*1cm},{-sin(\w)*sin(\aa)*1cm})},
        y={({sin(\w)*1cm},{cos(\w)*sin(\aa)*1cm})},
        z={(0,{cos(\aa)*1cm})}]
    \draw[blue,->] (0,0,0)coordinate(O) --  (1,0,0)node[below right]{$\vec{x}$};
    \draw[blue,->] (O) --  (0,1,0)node[above]{$\vec{y}$};    
    \draw[blue,->] (O) --  (0,0,1)node[above]{$\vec{z}$};

    \begin{scope}[canvas is xy plane at z=0]
        \draw[dashed] (0,0) circle [radius=1];
        \draw (2,0) coordinate (A) -- (0,0) coordinate (B) -- (1,1) coordinate (C);
        \draw[red] pic ["$\alpha$", draw, ->,transform shape,angle radius=0.8cm,
        pic text options={transform shape=false}] {angle}; % correct
        \draw[green] (0:0.9) arc[start angle=0,end angle=45,radius=0.9]; % correct 
    \end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容