How to calculate coordinates of the intersection between the altitude and the base in a triangle. Given a triangle with vertices $A, B \;\text{and}\; C.$ The coordinates of these points are known upfront. Suppose we construct an altitude through $C$ and perpendicular to the line $AB.$ We will call the intersection point $D.$
Is there a formula with which I can calculate the coordinates of this point $D?$
EDIT: I need to program this somehow, so it would be handy if the formula only involved coordinates if possible.
Thanks in advance.

The slope of the altitude is opposite reciprocal of the slope of $AB$ 
You can find the equation of $CD$ using point slope formula and find the intersection of $AB$ and $CD$ 
