Find a point on segment of triangle that cuts 90 degrees from other triangle point For any triangle, how can I find the point D, knowing A,B and C and that the segment CD must be perpendicular to AB ?
Example : 
 A: As triangles ACD and BCD are right and have one common side according to the Pythagoras theorem we can have:
AC^2 - AD^2 = BC^2 - BD^2
as we know that AB = AD - BD:
AC^2 - (AB - BD)^2 = BC^2 - BD^2
AC^2 - AB^2 + 2*AB*BD - BC^2 = BC^2 - BD^2
from here we can get BD:
BD = (AB^2 + BC^2 - AC^2)/(2*AB)
As AB, BC and AC are known we can evaluate BD and then find the point D
A: Let $\color{blue}{m_{AB}=\frac{y_a-y_b}{x_a-x_b}}$ be the slope of the line $\color{blue}{AB}$. Observe now that we can define the function of $\color{blue}{AB}$ as follows 
$$\color{blue}{g(x)=\frac{y_a-y_b}{x_a-x_b}\cdot x+\frac{-y_a\cdot x_b+y_b\cdot x_a}{x_a-x_b}}$$
Since $CD\perp AB$
$$\color{red}{m_{DC}=\frac{x_a-x_b}{y_b-y_a}}$$ 
Let furthermore $\color{red}{f(x)=m_{DC}\cdot x+n}$ define the line $\color{red}{DC}$. 
Since $C\in f$, we conclude that 
$$y_c=\frac{x_a-x_b}{y_b-y_a}\cdot x_c+n\implies \color{red}{n=\frac{y_c\cdot (y_b-y_a)-x_c\cdot (x_a-x_b)}{y_b-y_a}}$$ 
Since $\{D\}=\color{blue}{AB}\cap\color{red}{CD}$, let 
\begin{align*}\color{blue}{\frac{y_a-y_b}{x_a-x_b}\cdot x+\frac{-y_a\cdot x_b+y_b\cdot x_a}{x_a-x_b}}&=\color{red}{\frac{x_a-x_b}{y_b-y_a}\cdot x+\frac{y_c\cdot (y_b-y_a)-x_c\cdot (x_a-x_b)}{y_b-y_a}}\\
&\underbrace{\iff}_{\cdot(x_a-x_b)(y_b-y_a)}\\
-(y_b-y_a)^2\cdot x+(y_b-y_a) (y_b x_a-y_a x_b)&=(x_a-x_b)^2\cdot  x+(x_a-x_b)\big(y_c (y_b-y_a)-x_c (x_a-x_b)\big)\\
\iff x&=\color{brown}{-\frac{(y_a-y_b) (y_b x_a-y_a x_b)+(x_a-x_b)\big(y_c (y_b-y_a)-x_c (x_a-x_b)\big)}{(x_a-x_b)^2+(y_a-y_b)^2}} 
\end{align*} 

Remark 
This formula might look very complicated but it becomes very simple when you know $x_a, x_b, x_c, y_a...$.
