System.Math.Vectors.TVector3D

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

  TVector3D = record
    class function Create(const AX, AY, AZ: Single; const AW: Single = 1.0): TVector3D; overload; static; inline;
    class function Create(const APoint: TPoint3D; const AW: Single = 1.0): TVector3D; overload; static; inline;
    class operator Add(const AVector1, AVector2: TVector3D): TVector3D;
    class operator Subtract(const AVector1, AVector2: TVector3D): TVector3D;
    class operator Equal(const AVector1, AVector2: TVector3D): Boolean;
    class operator NotEqual(const AVector1, AVector2: TVector3D): Boolean;
    class operator Negative(const AVector: TVector3D): TVector3D;
    class operator Implicit(const APoint: TPoint3D): TVector3D;
    class operator Explicit(const AVector: TVector3D): TPoint3D;
    class operator Implicit(const AVector: TVector3D): TPoint3D; inline; deprecated 'Implicit conversion from TVector3D to TPoint3D requires homogenization';
    class operator Multiply(const AVector1, AVector2: TVector3D): TVector3D;
    class operator Multiply(const AVector: TVector3D; const AFactor: Single): TVector3D; inline;
    class operator Multiply(const AFactor: Single; const AVector: TVector3D): TVector3D; inline;
    class operator Divide(const AVector: TVector3D; const AFactor: Single): TVector3D;
    class function Zero: TVector3D; inline; static;
    procedure Offset(const ADelta: TPoint3D); overload; inline; deprecated 'Use TPoint3D.Offset';
    procedure Offset(const ADeltaX, ADeltaY, ADeltaZ: Single); overload; inline; deprecated 'Use TPoint3D.Offset';
    function CrossProduct(const AVector: TVector3D): TVector3D; deprecated 'Use TPoint3D.CrossProduct';
    function DotProduct(const AVector: TVector3D): Single; deprecated 'Use TPoint3D.DotProduct';
    function EqualsTo(const AVector: TVector3D; const Epsilon: Single = 0): Boolean; inline;
    function Length: Single;
    function Normalize: TVector3D;
    function Distance(const AVector: TVector3D): Single;
    function Rotate(const AAxis: TPoint3D; const AAngle: Single): TVector3D; inline; deprecated 'Use TPoint3D.Rotate';
    function Reflect(const AVector: TVector3D): TVector3D; inline; deprecated 'Use TPoint3D.Reflect';
    function MidVector(const AVector: TVector3D): TVector3D;
    function AngleCosine(const AVector: TVector3D): Single; deprecated 'Use TPoint3D.AngleCosine';
    function ToPoint3D(const ATransform: Boolean = False): TPoint3D; deprecated 'Use explicit typecast instead.';
    case Integer of
      0: (V: TVector3DType;);
      1: (X: Single;
          Y: Single;
          Z: Single;
          W: Single;);
  end;

C++

struct DECLSPEC_DRECORD TVector3D
{
public:
    static TVector3D __fastcall Create(const float AX, const float AY, const float AZ, const float AW = 1.000000E+00f)/* overload */;
    static TVector3D __fastcall Create(const TPoint3D &APoint, const float AW = 1.000000E+00f)/* overload */;
    static TVector3D __fastcall _op_Addition(const TVector3D &AVector1, const TVector3D &AVector2);
    static TVector3D __fastcall _op_Subtraction(const TVector3D &AVector1, const TVector3D &AVector2);
    static bool __fastcall _op_Equality(const TVector3D &AVector1, const TVector3D &AVector2);
    static bool __fastcall _op_Inequality(const TVector3D &AVector1, const TVector3D &AVector2);
    static TVector3D __fastcall _op_UnaryNegation(const TVector3D &AVector);
    static TVector3D __fastcall _op_Implicit(const TPoint3D &APoint);
    __fastcall operator TPoint3D() _DEPRECATED_ATTRIBUTE1("Implicit conversion from TVector3D to TPoint3D requires homogenization") ;
    static TVector3D __fastcall _op_Multiply(const TVector3D &AVector1, const TVector3D &AVector2);
    static TVector3D __fastcall _op_Multiply(const TVector3D &AVector, const float AFactor);
    static TVector3D __fastcall _op_Multiply(const float AFactor, const TVector3D &AVector);
    static TVector3D __fastcall _op_Division(const TVector3D &AVector, const float AFactor);
    static TVector3D __fastcall Zero();
    void __fastcall Offset _DEPRECATED_ATTRIBUTE1("Use TPoint3D.Offset") (const TPoint3D &ADelta)/* overload */;
    void __fastcall Offset _DEPRECATED_ATTRIBUTE1("Use TPoint3D.Offset") (const float ADeltaX, const float ADeltaY, const float ADeltaZ)/* overload */;
    TVector3D __fastcall CrossProduct _DEPRECATED_ATTRIBUTE1("Use TPoint3D.CrossProduct") (const TVector3D &AVector);
    float __fastcall DotProduct _DEPRECATED_ATTRIBUTE1("Use TPoint3D.DotProduct") (const TVector3D &AVector);
    bool __fastcall EqualsTo(const TVector3D &AVector, const float Epsilon = 0.000000E+00f);
    float __fastcall Length();
    TVector3D __fastcall Normalize();
    float __fastcall Distance(const TVector3D &AVector);
    TVector3D __fastcall Rotate _DEPRECATED_ATTRIBUTE1("Use TPoint3D.Rotate") (const TPoint3D &AAxis, const float AAngle);
    TVector3D __fastcall Reflect _DEPRECATED_ATTRIBUTE1("Use TPoint3D.Reflect") (const TVector3D &AVector);
    TVector3D __fastcall MidVector(const TVector3D &AVector);
    float __fastcall AngleCosine _DEPRECATED_ATTRIBUTE1("Use TPoint3D.AngleCosine") (const TVector3D &AVector);
    TPoint3D __fastcall ToPoint3D _DEPRECATED_ATTRIBUTE1("Use explicit typecast instead.") (const bool ATransform = false);
    friend TVector3D operator +(const TVector3D &AVector1, const TVector3D &AVector2) { return TVector3D::_op_Addition(AVector1, AVector2); }
    friend TVector3D operator -(const TVector3D &AVector1, const TVector3D &AVector2) { return TVector3D::_op_Subtraction(AVector1, AVector2); }
    friend bool operator ==(const TVector3D &AVector1, const TVector3D &AVector2) { return TVector3D::_op_Equality(AVector1, AVector2); }
    friend bool operator !=(const TVector3D &AVector1, const TVector3D &AVector2) { return TVector3D::_op_Inequality(AVector1, AVector2); }
    TVector3D operator -() { return TVector3D::_op_UnaryNegation(*this); }
    TVector3D& operator =(const TPoint3D &APoint) { *this = TVector3D::_op_Implicit(APoint); return *this; }
    friend TVector3D operator *(const TVector3D &AVector1, const TVector3D &AVector2) { return TVector3D::_op_Multiply(AVector1, AVector2); }
    friend TVector3D operator *(const TVector3D &AVector, const float AFactor) { return TVector3D::_op_Multiply(AVector, AFactor); }
    friend TVector3D operator *(const float AFactor, const TVector3D &AVector) { return TVector3D::_op_Multiply(AFactor, AVector); }
    friend TVector3D operator /(const TVector3D &AVector, const float AFactor) { return TVector3D::_op_Division(AVector, AFactor); }
public:
    union
    {
        struct
        {
            float X;
            float Y;
            float Z;
            float W;
        };
        struct
        {
            TVector3DType V;
        };
    };
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.Math.Vectors.pas
System.Math.Vectors.hpp
System.Math.Vectors System.Math.Vectors

Description

Class for vectors in 3D space. TVector3D describes a vector in 3D space.

Its coordinates are represented by three Single type values, X for width, Y for height, and Z for depth. These coordinates, along with the fourth coordinate, W, are homogeneous coordinates. These are used in computer graphics because they allow operations such as translation, rotation, scaling, and projection to be implemented as matrix operations.

Note: Modern OpenGL and DirectX graphic cards take advantage of this to implement a vertex shader efficiently.

See Also

Code Examples