\coordinate 交点在 TikZ 中无法正常工作

\coordinate 交点在 TikZ 中无法正常工作

我尝试使用 TikZ 绘制一些图形,但发生了一些奇怪的事情。我尝试使用“交点”来获取两条线的交点坐标,但奇怪的是,总有一个点无法获得正确的坐标。

以下是我编写的 TikZ 代码,如输出所示,点 (By) 的坐标是错误的。我改变了定义四个点 Bx、By、Dx、Dy 的顺序,发现这四个点中的第一个总是坐标混乱。

我怀疑这可能是由于在前四个点(CC、CD、DC、DD)上贴标签造成的,但我不知道如何纠正这个问题。

我是 TikZ 的新手,因此非常感谢您的帮助!

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}%[plain]
\begin{tikzpicture}
    \coordinate [label=right:{$(r-1,r-1)$}] (CC) at (2,2);
    \coordinate [label=left:{$(-1,r)$}] (CD) at (-1,3);
    \coordinate [label=right:{$(r,-1)$}] (DC) at (3,-1);
    \coordinate [label=225:{$(0,0)$}] (DD) at (0,0);

    \coordinate (By) at (intersection of (0,-1)--(0,4) and CD--CC);
    \coordinate (Dx) at (intersection of (-1,0)--(4,0) and CD--DC);
    \coordinate (Dy) at (intersection of (0,-1)--(0,4) and CD--DC);
    \coordinate (Bx) at (intersection of (-1,0)--(4,0) and DC--CC);

    \fill (Bx) circle (2pt);
    \fill (By) circle (2pt);
    \fill (Dx) circle (2pt);
    \fill (Dy) circle (2pt);

    \draw [thick] (-1,0) -- (4,0) node [below] {$u_1$};
    \draw [thick] (0,-1) -- (0,4) node [left] {$u_2$};
    \draw [thick] (DD) -- (CD) -- (CC) -- (DC) -- cycle;
    \draw [dashed]  (CD) --  (DC);
    \draw [thick]  (CC) --  (DD);
    \draw [thick]  (Dx) --  (Dy);
\end{tikzpicture}
\end{frame}
\end{document}

在此处输入图片描述

相关内容