交点 -| 命名坐标和计算坐标

交点 -| 命名坐标和计算坐标

我想使用命名坐标和计算坐标的交点,换句话说,命名坐标的 y 坐标,但计算坐标的 x 坐标,例如下面的点 Z,它具有

  • X 的 y 坐标
  • x 坐标($(A)!0.5!(B)$)

(X -| $(A)!0.5!(B)$)没有用...还有其他选择吗?

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, positioning}
\begin{document}
\begin{tikzpicture}[dot/.style={circle, fill=black, inner sep=0, minimum width=1mm}]
\node [dot] (A) at (0.5,0) {} node[below=0.1mm of A]{A};
\node [dot] (B) at (2,3) {} node[below=0.1mm of B]{B};
\node [dot] (X) at (0,5) {} node[below=0.1mm of X]{X};
\draw (A) -- (B);
\draw (X) -| ($(A)!0.5!(B)$);
\node [dot] (Y) at (X -| B){} node[above=0.1mm of Y]{Y};
\coordinate(AB) at ($(A)!0.5!(B)$);
\node [dot] (Z) at (X -| AB){} node[above=0.1mm of Z]{Z};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

这可以通过用大括号括起来来实现$(A)!0.5!(B)$

X在原始代码中,在、A和处的点和线之间有一个小空格B。使用选项 可以删除此空格outer sep=0pt

在此处输入图片描述

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, positioning}
\begin{document}
\begin{tikzpicture}[dot/.style={circle, fill=black, inner sep=0, minimum width=1mm, outer sep=0pt}]
\node [dot] (A) at (0.5,0) {} node[below=0.1mm of A]{A};
\node [dot] (B) at (2,3) {} node[below=0.1mm of B]{B};
\node [dot] (X) at (0,5) {} node[below=0.1mm of X]{X};
\draw (A) -- (B);
\draw (X) -| ($(A)!0.5!(B)$);
\node [dot] (Y) at (X -| B){} node[above=0.1mm of Y]{Y};
\node [dot] (Z) at (X -| {$(A)!0.5!(B)$}){} node[above=0.1mm of Z]{Z};
\end{tikzpicture}
\end{document}

答案2

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[dot/.style={circle, fill=black, inner sep=0, minimum width=1mm, outer sep=0pt}]
\coordinate[dot, label=below:{A}] (A) at (0.5,0);
\coordinate[dot, label=below:{B}] (B) at (2,3);
\coordinate[dot, label=below:{X}] (X) at (0,5);
\draw (A) -- (B);
\draw (X) -| ($(A)!0.5!(B)$);
\coordinate[dot, label=below:{Y}] (Y) at (X-|B);
\path let \p1=($(A)!0.5!(B)$), \p2=(X) in coordinate[dot, label=above:{Z}] (Z) at (\x1,\y2);
\end{tikzpicture}
\end{document}

点线图

相关内容