[Math] Find the point of intersection between a line segment $AC$ and a perpendicular line going through a point $B$ not on $AC$

euclidean-geometrygeometry

I've asked this question first on Stack Overflow (How to find position in pixels of intersection of two lines?) but it's actually a math question so I'm asking it here and I'll delete the SO one.

enter image description here

I have $3$ points $A$, $B$ and $C$ and I need to calculate point $D$ in the picture above, so I can draw that shorter line segment. We should have $AC\perp BD$.

It should be simple (high school difficulty), but I don't know how to solve it. Do I need to calculate the line equations that go through two point and then perpendicular line equation that go through a point and then intersection of two lines, or is there easiest way?

It seems that when the ratio is $4:3$ the point is in golden point but if ratio is different the point is in other place.

Best Answer

Say $\vert AD\vert=a, \vert AB\vert =b, \vert DC\vert =c$ and $\vert BC\vert =d$. Now, by Pythagoras' theorem $$\vert DB\vert^2=b^2-a^2=d^2-c^2.$$ This implies that $$b^2-d^2=a^2-c^2\\\frac{b^2-d^2}{a+c}=a-c.$$ Now add $a+c$ to both sides and divide by two:$$\frac{b^2-d^2}{2(a+c)}+\frac{a+c}{2}=a.$$ So now we know that $\vert AD\vert = a=\frac{b^2-d^2}{2(a+c)}+\frac{a+c}{2}$. Note that $b$, $d$ and $a+c$ can be derived from the coordinates of $A$, $B$ and $C$.

Can you take it from here?