With tikz-pgf
, I can draw a perpendicular from a point to a line. Is there a robust method to draw a perpendicular from a point? For example, in the following code, say I want to raise a perpendicular, from a specific point on line BC
outwards.
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (2,4);
\coordinate (C) at (8,0);
\draw(A)--(B)--(C)--cycle;
\draw[red] (B) -- ($(A)!(B)!(C)$);
\node[label={below left:$A$}] at (A) {};
\node[label={above:$B$}] at (B) {};
\node[label={below right:$C$}] at (C) {};
\end{tikzpicture}
\end{document}
P
onBC
you can use(P) -- ++({2/sqrt(13)},{3/sqrt(13)})
(or to for faster compile(P) -- ++(0.5547001962252291,0.8320502943378437)
), or you can use as I saidcalc
to draw(P) -- ($(P)!1cm!90:(C)$)
.BC
is the midpoint. I can simply define that coordinate as, say,\coordinate (P) at ($(B)!0.5!(C)$)
. Then I can do,\draw (P)--($(P)!0.5!90:(C)$)
.\draw[red, thick] (P) -- ($(A)!(P)!(C)$);
as you already did for your line from B.