1

Maybe you can help me, I try to draw a line from a Point/Coordinate to a straight line. I use Tikz to draw.

      \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

the red line should go from coordinate (S1) to the straight line (A -- B) vertically. I tried it to draw it like this:

     \draw [red!100, thick] (S1) -- node[above]{T} (A -| B );

But then he draw a line to coordinate A

Thank you,

2

You want

\draw [red!100, thick] (S1) -- node[right]{T} (S1 |- S2);

i.e. from S1 to the point that has the x-coordinate of S1, and y-coordinate of S2. (See TikZ: What EXACTLY does the the |- notation for arrows do? for some more explanation of -|/|-.)

output of code

\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[right]{T} (S1 |- S2);
      \end{tikzpicture}
\end{document}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.