This is best done using vectors. Let P be a point on the line , and let be the position vector of P. Let be a unit vector perpendicular to . Given a point X, with position vector , let X' be the foot of the perpendicular from X to . Then the position vector of X' is , where d is the distance XX'. Also, the line PX' is perpendicular to , and so (where the dot represents the inner product). Therefore (because ).

If A, B, C, Z have position vectors , then . Thus , which simplifies to .