TVector3DNormalize (Object Pascal)

From Appmethod Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the Normalize method to return the normalized 3D vector of Self.

Code

uses
  System.SysUtils,
  System.Types;

var
  aVector1: TVector3D;
  
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.

    aVector1.Normalize();
    writeln(Format('%2.2f %2.2f %2.2f', [aVector1.X, aVector1.Y, aVector1.Z]));
    // The console will output: 0.22 0.44 0.87, representing the coordinates for aVector1 after normalization.
end.

Uses