Detailed description

Right-angled triangle AYB. Right angle at Y. A(x1, y1), B(x2, y2). P is the midpoint of AB. Line segment PX is drawn perpendicular to AY with X on AY.