Title: Perpendicular from Point to Segment
Procedure PerpendicularPntToSegment(x1,y1,x2,y2,Px,Py:Double; Var Nx,Ny:Double);
Var R : Double;
Dx : Double;
Dy : Double;
Begin
Dx := x2 - x1;
Dy := y2 - y1;
R := ((Px-x1)*Dx+(Py-y1)*Dy)/Sqr(Dx*Dx+Dy*Dy);
Nx := x1 + R*Dx;
Ny := y1 + R*Dy;
End;
(* End PerpendicularPntSegment *)