TVectorLength (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the Length method to obtain the length of a vector.

Code

uses
  System.SysUtils,
  System.Types;

var
  aVector: TVector;
  aPoint: TPointF;
  aLength: Single;
begin
        aPoint.Create(2,3);
        aVector.Create(aPoint);
        writeln(Format('%2.2f %2.2f',[aVector.X,aVector.Y]));
        // The console will output: 2.00 3.00, representing the coordinates for aVector.

        aLength:=aVector.Length;
        writeln(Format('%2.2f',[aLength]));
        // The console will output: 3.61, representing the length of a aVector.
end.

Uses