TVector3DDistance (Delphi)
Description
This example illustrates how to use the Distance method to obtain the distance between two 3D vectors.
Code
uses
System.SysUtils,
System.Types;
var
aVector1,aVector2: TVector3D;
aDistance: Single;
begin
aVector1.Create(1,2,4);
writeln(Format('%2.2f %2.2f %2.2f',[aVector1.X,aVector1.Y,aVector1.Z]));
// The console will output: 1.00 2.00 4.00, representing the coordinates for aVector1.
aVector2.Create(2,3,4);
writeln(Format('%2.2f %2.2f %2.2f',[aVector2.X,aVector2.Y,aVector2.Z]));
// The console will output: 2.00 3.00 4.00, representing the coordinates for aVector2.
aDistance:=aVector1.Distance(aVector2);
writeln(Format('%2.2f ',[aDistance]));
// The console will output: 2.00, representing the distance between aVector1 and aVector2.
end.