也许你可以帮助我,我尝试从点/坐标绘制直线到直线。我用Tikz画画。
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (-5,-5){};
\coordinate [label=right:$B$] (B) at (5,-5) {};
\coordinate [label=right:$C$] (C) at (5,1) {};
\coordinate [label=left:$D$] (D) at (-5,1) {};
\draw [thick] (A) -- node[midway] {$\parallel$} (B) -- node[sloped]{$\parallel$} (C) -- (D) -- cycle;
\coordinate (S1) at ($(D)!0.66!(C)$);
\coordinate (S2) at ($(A)!0.11!(B)$);
\draw [very thick] (S1) -- node[above]{x} (S2);
\draw [red!100, thick] (S1) -- node[above]{T} (A -| B );
\end{tikzpicture}
This where the red line should go
红线应垂直从坐标(S1)到直线(A - B)。我试着把它画成这样:
\draw [red!100, thick] (S1) -- node[above]{T} (A -| B );
但他画了一条线来协调A.
谢谢,
您不需要定义新坐标,但可以使用calc
库中的投影标识符。
在最后一行你只需要
\draw [red!100, thick] (S1) -- node[left]{T} ($(A)!(S1)!(B)$);
这意味着沿着A-B取S1投射到A-B上的点。
您可以通过为AB上的点定义新坐标(例如S3
)来做到这一点:
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (-5,-5){};
\coordinate [label=right:$B$] (B) at (5,-5) {};
\coordinate [label=right:$C$] (C) at (5,1) {};
\coordinate [label=left:$D$] (D) at (-5,1) {};
\draw [thick] (A) -- node[midway] {$\parallel$} (B) -- node[sloped]{$\parallel$} (C) -- (D) -- cycle;
\coordinate (S1) at ($(D)!0.66!(C)$);
\coordinate (S2) at ($(A)!0.11!(B)$);
\coordinate (S3) at ($(A)!0.66!(B)$);
\draw [very thick] (S1) -- node[above]{x} (S2);
\draw [red!100, thick] (S1) -- node[left]{T} (S3);
\end{tikzpicture}
你的语法几乎是正确的,但是三通操作员|-
和-|
从一侧获取x坐标,从另一侧获取y坐标。当您编写A -| B
时,您将得到A的y坐标和B的x坐标,但在您的代码中,A和B具有相同的x坐标,因此这将再次为您提供A点。相反,你想要A -| S1
,或者等同于S1 |- A
。
\draw [red!100, thick] (S1) -- node[left]{T} (S1 |- A);
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate [label=left:$A$] (A) at (-5,-5){};
\coordinate [label=right:$B$] (B) at (5,-5) {};
\coordinate [label=right:$C$] (C) at (5,1) {};
\coordinate [label=left:$D$] (D) at (-5,1) {};
\draw [thick] (A) -- node[midway] {$\parallel$} (B) -- node[sloped]{$\parallel$} (C) -- (D) -- cycle;
\coordinate (S1) at ($(D)!0.66!(C)$);
\coordinate (S2) at ($(A)!0.11!(B)$);
\draw [very thick] (S1) -- node[above]{x} (S2);
\draw [red!100, thick] (S1) -- node[left]{T} (S1 |- A);
\end{tikzpicture}
\end{document}