TPointF (Delphi)
Description
The following code example illustrates the behavior of the TPointF.Add, TPointF.Subtract and TPointF.Distance methods.
Code
procedure math;
var
P1, P2, P3: TPointF;
begin
P1 := PointF(2.25, 16.35);
P2 := PointF(5.77, 33.12);
P3 := P2 - P1;
writeln('Subtraction Coordinates. X:', Format('%2.2f', [P3.X]), ' Y:', Format('%2.2f', [P3.Y]));
P3 := P1 + P2;
writeln('Addition Coordinates. X:', Format('%2.2f', [P3.X]), ' Y:', Format('%2.2f', [P3.Y]));
writeln('Distance between the two new points:', Format('%2.2f', [(P2 - P1).Distance((P1 + P2))]));
end;