TikZ,节点和表达式不一致

TikZ,节点和表达式不一致

在此代码中,与上一个问题

\documentclass[border=2mm,tikz]{standalone}
\usetikzlibrary{arrows.meta,calc}

\begin{document}

\begin{tikzpicture}

\draw[->] (-3,0,0) -- (3,0,0) node[below right] {$x$};
\draw[->] (0,-3,0) -- (0,3,0) node[above right] {$y$};
\draw[->] (0,0,-3) -- (0,0,3) node[below right] {$z$};

\coordinate (o) at (0,0,0);
\coordinate (a) at (3.1,0,1.2);

\draw[dashed] (a) -- (o);

\path (a) -- coordinate[pos=0.32] (b) (o);

\draw [thick,-{Straight Barb},orange] (a) -- ($(a)!1.2cm!90:(o)$) node[black,above left] (c) {c};
\draw[thick,-{Straight Barb},gray] (a) -- node[pos=0.7, below=0.35em] {b} (b);
\draw [thick,-{Straight Barb},red] (a) -- ([shift={(0,1.5,0)}]a) node[black,below right] (d) {d};

\draw[thick] ($(a)!1.2cm!90:(o)$) -- (a);
\draw[thick] (c) -- (a);

\draw ([shift={(0,0,-2.1)}]a) -- ([shift={(0,0,2.1)}]a);

\coordinate (newd) at (d);

\draw ([shift={(0,0,-2.1)}]newd) -- ([shift={(0,0,2.1)}]newd);

\end{tikzpicture}

\end{document}

产生了两个意外的输出:

在此处输入图片描述

1) 点c与 点 不重合($(a)!1.2cm!90:(o)$),因此绘制了两条不同的线段:为什么? 表达式 究竟是如何实现的($(a)!1.2cm!90:(o)$)? 我想获取 (x,z) 平面中与a和之间的线正交的点o

2)线条

\draw ([shift={(0,0,-2.1)}]newd) -- ([shift={(0,0,2.1)}]newd);

没有到达红色箭头的尖端。为什么?

在这两种情况下,节点位置似乎与其定义不一致。

答案1

只是阐明我的评论:使用坐标而不是节点,因为后者具有有限的大小。

在此处输入图片描述

\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}

\draw[->] (-3,0,0) -- (3,0,0) node[below right] {$x$};
\draw[->] (0,-3,0) -- (0,3,0) node[above right] {$y$};
\draw[->] (0,0,-3) -- (0,0,3) node[below right] {$z$};

\coordinate (o) at (0,0,0);
\coordinate (a) at (3.1,0,1.2);

\draw[dashed] (a) -- (o);

\path (a) -- coordinate[pos=0.32] (b) (o);

\draw [thick,-{Straight Barb},orange] (a) -- ($(a)!1.2cm!90:(o)$)
coordinate[label={[black]above left:c}] (c);
\draw[thick,-{Straight Barb},gray] (a) -- node[pos=0.7, below=0.35em] {b} (b);
\draw [thick,-{Straight Barb},red] (a) -- ([shift={(0,1.5,0)}]a) 
coordinate[black,label={[black]below right:d}] (d);

\draw[thick] ($(a)!1.2cm!90:(o)$) -- (a);
\draw[thick] (c) -- (a);

\draw ([shift={(0,0,-2.1)}]a) -- ([shift={(0,0,2.1)}]a);

\coordinate (newd) at (d);

\draw ([shift={(0,0,-2.1)}]newd) -- ([shift={(0,0,2.1)}]newd);

\end{tikzpicture}

\end{document}

相关内容