TVector3DCrossProduct (Object Pascal)

From Appmethod Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the CrossProduct method to obtain the cross product of Self and a given TVector3D value.

Code

uses
  System.SysUtils,
  System.Types;

var
  aVector1,aVector2: 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.
		
      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.

      aVector1:=aVector1.CrossProduct(aVector2);
      writeln(Format('%2.2f %2.2f %2.2f',[aVector1.X,aVector1.Y,aVector1.Z]));
      // The console will output: -4.00 4.00 -1.00, representing the coordinates for aVector1 as the cross product of Self and aVector2.	
end.

Uses