TVector3DReflect (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the Reflect method to return the reflection of the given 3D vector.

Code

uses
  System.SysUtils,
  System.Types;

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

    aVector2:=aVector2.Reflect(aVector1) ;
    writeln(Format('%2.2f %2.2f %2.2f', [aVector2.X, aVector2.Y, aVector2.Z]));
    // The console will output: -46.00 -93.00 -188.00, representing the coordinates for aVector2 as the reflection of aVector1.

end.

Uses