Packed Record TGenericVector2

Unit

Declaration

type TGenericVector2 = packed record

Description

Vector of 2 floating-point values.

See also
TGenericVector3
Vector of 3 floating-point values.

Source: src/base/castlevectors_generic_float_record.inc (line 66).

Overview

Nested Types

Public TIndex = 0..Count - 1;

Fields

Public nested const Count = 2;
Public X: TGenericScalar
Public Y: TGenericScalar
Public Data: array [TIndex] of TGenericScalar

Methods

Public class operator + (const A, B: TGenericVector2): TGenericVector2; inline;
Public class operator - (const A, B: TGenericVector2): TGenericVector2; inline;
Public class operator - (const V: TGenericVector2): TGenericVector2; inline;
Public class operator * (const V: TGenericVector2; const Scalar: TGenericScalar): TGenericVector2; inline;
Public class operator * (const Scalar: TGenericScalar; const V: TGenericVector2): TGenericVector2; inline;
Public class operator * (const V1, V2: TGenericVector2): TGenericVector2; inline;
Public class operator / (const V: TGenericVector2; const Scalar: TGenericScalar): TGenericVector2; inline;
Public procedure Init(const AX, AY: TGenericScalar); inline; deprecated 'initialize instead like "V := Vector2(X, Y)"; modifying a temporary record value is a trap, e.g. this is not reliable: "Scene.TranslationXY.Init(X, Y)"';
Public function ToString: string;
Public function ToRawString(const FloatFormat: String = '%g'): string;
Public function Normalize: TGenericVector2; inline;
Public procedure NormalizeMe; inline; deprecated 'normalize instead like "V := V.Normalize"; modifying a temporary record value is a trap, e.g. this is not reliable: "Scene.TranslationXY.NormalizeMe"';
Public function Length: TGenericScalar; inline;
Public function LengthSqr: TGenericScalar; inline;
Public function AdjustToLength(const NewLength: TGenericScalar): TGenericVector2; inline;
Public class function DotProduct(const V1, V2: TGenericVector2): TGenericScalar; static; inline;
Public function Abs: TGenericVector2; inline;
Public function IsZero: boolean; overload; inline;
Public function IsZero(const Epsilon: TGenericScalar): boolean; overload; inline;
Public function IsPerfectlyZero: boolean;
Public class function Equals(const V1, V2: TGenericVector2): boolean; overload; inline; static;
Public class function Equals(const V1, V2: TGenericVector2; const Epsilon: TGenericScalar): boolean; overload; inline; static;
Public class function PerfectlyEquals(const V1, V2: TGenericVector2): boolean; static; inline;
Public class function Lerp(const A: TGenericScalar; const V1, V2: TGenericVector2): TGenericVector2; static; inline;
Public class function Zero: TGenericVector2; static; inline;

Properties

Public property AsArray [const Index: TIndex]: TGenericScalar read GetItems;
Public class property One [const Index: TIndex]: TGenericVector2 read GetOne;

Description

Nested Types

Public TIndex = 0..Count - 1;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 69).

Fields

Public nested const Count = 2;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 69).

Public X: TGenericScalar

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 172).

Public Y: TGenericScalar

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 172).

Public Data: array [TIndex] of TGenericScalar

Access (get, set) vector components by index.

Source: src/base/castlevectors_generic_float_record.inc (line 173).

Methods

Public class operator + (const A, B: TGenericVector2): TGenericVector2; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 96).

Public class operator - (const A, B: TGenericVector2): TGenericVector2; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 97).

Public class operator - (const V: TGenericVector2): TGenericVector2; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 98).

Public class operator * (const V: TGenericVector2; const Scalar: TGenericScalar): TGenericVector2; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 99).

Public class operator * (const Scalar: TGenericScalar; const V: TGenericVector2): TGenericVector2; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 100).

Public class operator * (const V1, V2: TGenericVector2): TGenericVector2; inline;

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

Source: src/base/castlevectors_generic_float_record.inc (line 103).

Public class operator / (const V: TGenericVector2; const Scalar: TGenericScalar): TGenericVector2; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 104).

Public procedure Init(const AX, AY: TGenericScalar); inline; deprecated 'initialize instead like "V := Vector2(X, Y)"; modifying a temporary record value is a trap, e.g. this is not reliable: "Scene.TranslationXY.Init(X, Y)"';

Warning: this symbol is deprecated: initialize instead like "V := Vector2(X, Y)"; modifying a temporary record value is a trap, e.g. this is not reliable: "Scene.TranslationXY.Init(X, Y)"

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 106).

Public function ToString: string;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 109).

Public function ToRawString(const FloatFormat: String = '%g'): 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.

You can pass, as parameter, the format to use. By default it is '%g', "general number format" with maximum precision documented on https://www.freepascal.org/docs-html/rtl/sysutils/format.html .

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

Source: src/base/castlevectors_generic_float_record.inc (line 122).

Public function Normalize: TGenericVector2; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 124).

Public procedure NormalizeMe; inline; deprecated 'normalize instead like "V := V.Normalize"; modifying a temporary record value is a trap, e.g. this is not reliable: "Scene.TranslationXY.NormalizeMe"';

Warning: this symbol is deprecated: normalize instead like "V := V.Normalize"; modifying a temporary record value is a trap, e.g. this is not reliable: "Scene.TranslationXY.NormalizeMe"

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 125).

Public function Length: TGenericScalar; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 128).

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.)

Source: src/base/castlevectors_generic_float_record.inc (line 135).

Public function AdjustToLength(const NewLength: TGenericScalar): TGenericVector2; 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).

Source: src/base/castlevectors_generic_float_record.inc (line 140).

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

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

Source: src/base/castlevectors_generic_float_record.inc (line 144).

Public function Abs: TGenericVector2; inline;

Absolute value on all components.

Source: src/base/castlevectors_generic_float_record.inc (line 147).

Public function IsZero: boolean; overload; inline;

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

Source: src/base/castlevectors_generic_float_record.inc (line 150).

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

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

Source: src/base/castlevectors_generic_float_record.inc (line 153).

Public function IsPerfectlyZero: boolean;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 155).

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

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

Source: src/base/castlevectors_generic_float_record.inc (line 158).

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

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 159).

Public class function PerfectlyEquals(const V1, V2: TGenericVector2): boolean; static; inline;

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

Source: src/base/castlevectors_generic_float_record.inc (line 162).

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

Linear interpolation between two vector values.

See also
TGenericVector3.Lerp
Linear interpolation between two vector values.

Source: src/base/castlevectors_generic_float_record.inc (line 166).

Public class function Zero: TGenericVector2; static; inline;

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 168).

Properties

Public property AsArray [const Index: TIndex]: TGenericScalar read GetItems;

Get vector components by index. This is a default property, so you can write MyVector[0] instead of MyVector.Data[0] or MyVector.AsArray[0].

But note that this is not writeable (because exposing writeable properties on vectors would cause some subtle traps, see https://castle-engine.io/coding_traps ). Use MyVector.Data[0] := 123.456 if you want to set by index, or MyVector.X := 123.456.

Source: src/base/castlevectors_generic_float_record.inc (line 85).

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

This item has no description.

Source: src/base/castlevectors_generic_float_record.inc (line 169).


Generated by PasDoc 0.17.0.snapshot.