record TMatrix2

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TMatrix2 = record

Description

A 2x2 matrix in row-major order (M[Row, Column]). You can access the elements directly using M[0,0]..M[1,1] or m11..m22. You can also access the matrix using its two rows R[0]..R[1] (which map directly to the elements M[]).

When the conditional define FM_COLUMN_MAJOR is set, the matrix is stored in column-major order instead (M[Column, Row]), and the Rows property and R fields are replaced by Columns and C respectively.

Overview

Fields

V: array [0..1] of TVector2
R: array [0..1] of TVector2
M: array [0..1, 0..1] of Single
m11: Single;
m12: Single;
m21: Single
m22: Single

Methods

procedure Init; overload; inline;
procedure Init(const ADiagonal: Single); overload; inline;
procedure Init(const ARow0, ARow1: TVector2); overload; inline;
procedure Init(const A11, A12, A21, A22: Single); overload; inline;
class operator Equal(const A, B: TMatrix2): Boolean; inline;
class operator NotEqual(const A, B: TMatrix2): Boolean; inline;
class operator Negative(const A: TMatrix2): TMatrix2;
class operator Add(const A: TMatrix2; const B: Single): TMatrix2;
class operator Add(const A: Single; const B: TMatrix2): TMatrix2;
class operator Add(const A, B: TMatrix2): TMatrix2;
class operator Subtract(const A: TMatrix2; const B: Single): TMatrix2;
class operator Subtract(const A: Single; const B: TMatrix2): TMatrix2;
class operator Subtract(const A, B: TMatrix2): TMatrix2;
class operator Multiply(const A: TMatrix2; const B: Single): TMatrix2;
class operator Multiply(const A: Single; const B: TMatrix2): TMatrix2;
class operator Multiply(const A: TMatrix2; const B: TVector2): TVector2; inline;
class operator Multiply(const A: TVector2; const B: TMatrix2): TVector2; inline;
class operator Multiply(const A, B: TMatrix2): TMatrix2;
class operator Divide(const A: TMatrix2; const B: Single): TMatrix2;
class operator Divide(const A: Single; const B: TMatrix2): TMatrix2;
class operator Divide(const A: TMatrix2; const B: TVector2): TVector2; inline;
class operator Divide(const A: TVector2; const B: TMatrix2): TVector2; inline;
class operator Divide(const A, B: TMatrix2): TMatrix2; inline;
function CompMult(const AOther: TMatrix2): TMatrix2;
function Transpose: TMatrix2; inline;
procedure SetTransposed; inline;
function Inverse: TMatrix2;
procedure SetInversed;

Properties

property Rows[constAIndex:Integer]: TVector2 read GetRow write SetRow;
property Components[constARow,AColumn:Integer]: Single read GetComponent write SetComponent;
property Determinant: Single read GetDeterminant;

Description

Fields

V: array [0..1] of TVector2

Row or column vectors, depending on FM_COLUMN_MAJOR define

R: array [0..1] of TVector2

The two row vectors making up the matrix

M: array [0..1, 0..1] of Single

The elements of the matrix in row-major order

m11: Single;
 
m12: Single;
 
m21: Single
 
m22: Single
 

Methods

procedure Init; overload; inline;

Initializes the matrix to an identity matrix (filled with 0 and value 1 for the diagonal)

procedure Init(const ADiagonal: Single); overload; inline;

Fills the matrix with zeros and sets the diagonal.

Parameters
ADiagonal
the value to use for the diagonal. Use 1 to set the matrix to an identity matrix.
procedure Init(const ARow0, ARow1: TVector2); overload; inline;

Initializes the matrix using two row vectors.

Parameters
ARow0
the first row of the matrix.
ARow1
the second row of the matrix.
procedure Init(const A11, A12, A21, A22: Single); overload; inline;

Initializes the matrix with explicit values.

Parameters: A11-A12: the values of the matrix elements, in row-major order.

class operator Equal(const A, B: TMatrix2): Boolean; inline;

Checks two matrices for equality.

Returns

True if the two matrices match each other exactly.

class operator NotEqual(const A, B: TMatrix2): Boolean; inline;

Checks two matrices for inequality.

Returns

True if the two matrices are not equal.

class operator Negative(const A: TMatrix2): TMatrix2;

Negates a matrix.

Returns

The negative value of the matrix (with all elements negated).

class operator Add(const A: TMatrix2; const B: Single): TMatrix2;

Adds a scalar value to each element of a matrix.

class operator Add(const A: Single; const B: TMatrix2): TMatrix2;

Adds a scalar value to each element of a matrix.

class operator Add(const A, B: TMatrix2): TMatrix2;

Adds two matrices component-wise.

class operator Subtract(const A: TMatrix2; const B: Single): TMatrix2;

Subtracts a scalar value from each element of a matrix.

class operator Subtract(const A: Single; const B: TMatrix2): TMatrix2;

Subtracts a matrix from a scalar value.

class operator Subtract(const A, B: TMatrix2): TMatrix2;

Subtracts two matrices component-wise.

class operator Multiply(const A: TMatrix2; const B: Single): TMatrix2;

Multiplies a matrix with a scalar value.

class operator Multiply(const A: Single; const B: TMatrix2): TMatrix2;

Multiplies a matrix with a scalar value.

class operator Multiply(const A: TMatrix2; const B: TVector2): TVector2; inline;

Performs a matrix * row vector linear algebraic multiplication.

class operator Multiply(const A: TVector2; const B: TMatrix2): TVector2; inline;

Performs a column vector * matrix linear algebraic multiplication.

class operator Multiply(const A, B: TMatrix2): TMatrix2;

Multiplies two matrices using linear algebraic multiplication.

class operator Divide(const A: TMatrix2; const B: Single): TMatrix2;

Divides a matrix by a scalar value.

class operator Divide(const A: Single; const B: TMatrix2): TMatrix2;

Divides a scalar value by a matrix.

class operator Divide(const A: TMatrix2; const B: TVector2): TVector2; inline;

Divides a matrix by a vector. This is equivalent to multiplying the inverse of the matrix with a row vector using linear algebraic multiplication.

class operator Divide(const A: TVector2; const B: TMatrix2): TVector2; inline;

Divides a vector by a matrix. This is equivalent to multiplying a column vector with the inverse of the matrix using linear algebraic multiplication.

class operator Divide(const A, B: TMatrix2): TMatrix2; inline;

Divides two matrices. This is equivalent to multiplying the first matrix with the inverse of the second matrix using linear algebraic multiplication.

function CompMult(const AOther: TMatrix2): TMatrix2;

Multiplies this matrix with another matrix component-wise.

Note: For linear algebraic matrix multiplication, use the multiply (*) operator instead.

Parameters
AOther
the other matrix.
Returns

This matrix multiplied by AOther component-wise. That is, Result.M[I,J] := M[I,J] * AOther.M[I,J].

function Transpose: TMatrix2; inline;

Creates a transposed version of this matrix.

Note: Does not change this matrix. To update this itself, use SetTransposed.

Returns

The transposed version of this matrix.

procedure SetTransposed; inline;

Transposes this matrix.

Note: If you do not want to change this matrix, but get a transposed version instead, then use Transpose.

function Inverse: TMatrix2;

Calculates the inverse of this matrix.

Note: Does not change this matrix. To update this itself, use SetInversed.

Note: The values in the returned matrix are undefined if this matrix is singular or poorly conditioned (nearly singular).

Returns

The inverse of this matrix.

procedure SetInversed;

Inverts this matrix.

Note: If you do not want to change this matrix, but get an inversed version instead, then use Inverse.

Note: The values in the inversed matrix are undefined if this matrix is singular or poorly conditioned (nearly singular).

Properties

property Rows[constAIndex:Integer]: TVector2 read GetRow write SetRow;

Returns the rows of the matrix. This is identical to accessing the R-field.

Parameters
AIndex
index of the column to return (0 or 1). Range is checked with an assertion.
property Components[constARow,AColumn:Integer]: Single read GetComponent write SetComponent;

Returns the elements of the matrix (in row-major order). This is identical to accessing the M-field, but this property can be used as a default array property.

Parameters
ARow
the row index (0 or 1). Range is checked with an assertion.
AColumn
the column index (0 or 1). Range is checked with an assertion.
property Determinant: Single read GetDeterminant;

The determinant of this matrix.


Generated by PasDocEx, based on PasDoc 0.14.0.