...Perpendicular from Point to Segment in 2D?
Author: Arash Partow
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 *)
// trouve la perpendiculaire entre un point et une droite (2D)
printed from
www.swissdelphicenter.ch
developers knowledge base