Lemma: If A = (x1, y1), B = (x2, y2) and C = (x3, y3) are the vertices of a right triangle

then
Proof: For AC and BC to be perpendicular, their slopes have to be negative reciprocals of each other. That is
We can assume that the denominators are not zero, because if they are then we are in the case where the lines are horizontal and vertical, and in that case, the Pythagorean Theorem follows simply from the distance fromula. We are interested in the case where the perpendicular sides are neither horizontal nor vertical.
Cross multiply
Transpose
Remove parentheses
Transpose
Multiply both sides by 2