Record TGenericVector4

Unit

Declaration

type TGenericVector4 = record

Description

Vector of 4 floating-point values.

See also
TGenericVector3
Vector of 3 floating-point values.

Overview

Nested Types

Public TIndex = 0..3;

Fields

Public var Data: array [TIndex] of TGenericScalar;

Methods

Public class operator + (const A, B: TGenericVector4): TGenericVector4; inline;
Public class operator - (const A, B: TGenericVector4): TGenericVector4; inline;
Public class operator - (const V: TGenericVector4): TGenericVector4; inline;
Public class operator * (const V: TGenericVector4; const Scalar: TGenericScalar): TGenericVector4; inline;
Public class operator * (const Scalar: TGenericScalar; const V: TGenericVector4): TGenericVector4; inline;
Public class operator * (const V1, V2: TGenericVector4): TGenericVector4; inline;
Public class operator / (const V: TGenericVector4; const Scalar: TGenericScalar): TGenericVector4; inline;
Public procedure Init(const X, Y, Z, W: TGenericScalar); inline;
Public function ToString: string;
Public function ToRawString: string;
Public function Length: TGenericScalar; inline;
Public function LengthSqr: TGenericScalar; inline;
Public function AdjustToLength(const NewLength: TGenericScalar): TGenericVector4; inline;
Public class function DotProduct(const V1, V2: TGenericVector4): TGenericScalar; static; inline;
Public function Abs: TGenericVector4; inline;
Public function IsZero: boolean; overload; inline;
Public function IsZero(const Epsilon: TGenericScalar): boolean; overload; inline;
Public function IsPerfectlyZero: boolean; inline;
Public class function Equals(const V1, V2: TGenericVector4): boolean; overload; inline; static;
Public class function Equals(const V1, V2: TGenericVector4; const Epsilon: TGenericScalar): boolean; overload; inline; static;
Public class function PerfectlyEquals(const V1, V2: TGenericVector4): boolean; static; inline;
Public function ToPosition: TGenericVector3; inline;
Public class function Lerp(const A: TGenericScalar; const V1, V2: TGenericVector4): TGenericVector4; static; inline;
Public class function Zero: TGenericVector4; static; inline;

Properties

Public property Items [const Index: TIndex]: TGenericScalar read GetItems write SetItems;
Public property X: TGenericScalar index 0 read GetItemsInt write SetItemsInt;
Public property Y: TGenericScalar index 1 read GetItemsInt write SetItemsInt;
Public property Z: TGenericScalar index 2 read GetItemsInt write SetItemsInt;
Public property W: TGenericScalar index 3 read GetItemsInt write SetItemsInt;
Public property XYZ: TGenericVector3 read GetXYZ write SetXYZ;
Public property XY: TGenericVector2 read GetXY write SetXY;
Public class property One [const Index: TIndex]: TGenericVector4 read GetOne;

Description

Nested Types

Public TIndex = 0..3;
 

Fields

Public var Data: array [TIndex] of TGenericScalar;
 

Methods

Public class operator + (const A, B: TGenericVector4): TGenericVector4; inline;
 
Public class operator - (const A, B: TGenericVector4): TGenericVector4; inline;
 
Public class operator - (const V: TGenericVector4): TGenericVector4; inline;
 
Public class operator * (const V: TGenericVector4; const Scalar: TGenericScalar): TGenericVector4; inline;
 
Public class operator * (const Scalar: TGenericScalar; const V: TGenericVector4): TGenericVector4; inline;
 
Public class operator * (const V1, V2: TGenericVector4): TGenericVector4; inline;

Vector * vector makes a component-wise multiplication. This is consistent with GLSL and other vector APIs.

Public class operator / (const V: TGenericVector4; const Scalar: TGenericScalar): TGenericVector4; inline;
 
Public procedure Init(const X, Y, Z, W: TGenericScalar); inline;
 
Public function ToString: string;
 
Public function ToRawString: string;

Convert to string using the most precise (not always easily readable by humans) float format. This may use the exponential (scientific) notation to represent the floating-point value, if needed.

This is suitable for storing the value in a file, with a best precision possible.

Public function Length: TGenericScalar; inline;
 
Public function LengthSqr: TGenericScalar; inline;

Vector length squared. This is slightly faster than Length as it avoids calculating a square root along the way. (But, please remember to not optimize your code without a need. Optimize only parts that are proven bottlenecks, otherwise don't make the code less readable for the sake of speed.)

Public function AdjustToLength(const NewLength: TGenericScalar): TGenericVector4; inline;

Calculate a new vector scaled so that it has length equal to NewLength. NewLength may be negative, in which case we'll negate the vector and then adjust it's length to Abs(NewLength).

Public class function DotProduct(const V1, V2: TGenericVector4): TGenericScalar; static; inline;

Dot product of two vectors. See https://en.wikipedia.org/wiki/Dot_product .

Public function Abs: TGenericVector4; inline;

Absolute value on all components.

Public function IsZero: boolean; overload; inline;

Are all components equal to zero (within some epsilon margin).

Public function IsZero(const Epsilon: TGenericScalar): boolean; overload; inline;

Are all components equal to zero (within Epsilon margin).

Public function IsPerfectlyZero: boolean; inline;
 
Public class function Equals(const V1, V2: TGenericVector4): boolean; overload; inline; static;

Compare two vectors, with epsilon to tolerate slightly different floats.

Public class function Equals(const V1, V2: TGenericVector4; const Epsilon: TGenericScalar): boolean; overload; inline; static;
 
Public class function PerfectlyEquals(const V1, V2: TGenericVector4): boolean; static; inline;

Compare two vectors using exact comparison (like the "=" operator to compare floats).

Public function ToPosition: TGenericVector3; inline;

Convert a 4D homogeneous coordinate to 3D position.

Public class function Lerp(const A: TGenericScalar; const V1, V2: TGenericVector4): TGenericVector4; static; inline;

Linear interpolation between two vector values. Works analogous to TVector3.Lerp

Public class function Zero: TGenericVector4; static; inline;
 

Properties

Public property Items [const Index: TIndex]: TGenericScalar read GetItems write SetItems;
 
Public property X: TGenericScalar index 0 read GetItemsInt write SetItemsInt;
 
Public property Y: TGenericScalar index 1 read GetItemsInt write SetItemsInt;
 
Public property Z: TGenericScalar index 2 read GetItemsInt write SetItemsInt;
 
Public property W: TGenericScalar index 3 read GetItemsInt write SetItemsInt;
 
Public property XYZ: TGenericVector3 read GetXYZ write SetXYZ;

Get first 3 components as a 3D vector. This simply rejects the 4th component.

Public property XY: TGenericVector2 read GetXY write SetXY;

Get first 2 components as a 2D vector. This simply rejects the remaining vector components.

Public class property One [const Index: TIndex]: TGenericVector4 read GetOne;
 

Generated by PasDoc 0.16.0.