TVector3DLength (Delphi)
Description
This example illustrates how to use the Length method to return the length of a 3D vector. The length is computed as the square root of the normalized vector.
Code
uses
System.SysUtils,
System.Types;
var
aVector1: TVector3D;
aValue: 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.
aValue:=aVector1.Length();
writeln(Format('%2.2f', [aValue]));
// The console will output: 4.58, representing the length of aVector1.
end.