C# Класс Accord.Math.Matrix4x4

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
V00 float
V01 float
V02 float
V03 float
V10 float
V11 float
V12 float
V13 float
V20 float
V21 float
V22 float
V23 float
V30 float
V31 float
V32 float
V33 float

Открытые методы

Метод Описание
Add ( Matrix4x4 matrix1, Matrix4x4 matrix2 ) : Matrix4x4

Adds corresponding components of two matrices.

CreateDiagonal ( Vector4 vector ) : Matrix4x4

Creates a diagonal matrix using the specified vector as diagonal elements.

CreateFromColumns ( Vector4 column0, Vector4 column1, Vector4 column2, Vector4 column3 ) : Matrix4x4

Creates a matrix from 4 columns specified as vectors.

CreateFromRotation ( Matrix3x3 rotationMatrix ) : Matrix4x4

Creates 4x4 tranformation matrix from 3x3 rotation matrix.

The source 3x3 rotation matrix is copied into the top left corner of the result 4x4 matrix, i.e. it represents 0th, 1st and 2nd row/column. The V33 element is set to 1 and the rest elements of 3rd row and 3rd column are set to zeros.

CreateFromRows ( Vector4 row0, Vector4 row1, Vector4 row2, Vector4 row3 ) : Matrix4x4

Creates a matrix from 4 rows specified as vectors.

CreateFromYawPitchRoll ( float yaw, float pitch, float roll ) : Matrix4x4

Creates rotation matrix to rotate an object around X, Y and Z axes.

The routine assumes roll-pitch-yaw rotation order, when creating rotation matrix, i.e. an object is first rotated around Z axis, then around X axis and finally around Y axis.

CreateLookAt ( Vector3 cameraPosition, Vector3 cameraTarget ) : Matrix4x4

Creates a view matrix for the specified camera position and target point.

Camera's "up" vector is supposed to be (0, 1, 0).

CreatePerspective ( float width, float height, float nearPlaneDistance, float farPlaneDistance ) : Matrix4x4

Creates a perspective projection matrix.

CreateRotationX ( float radians ) : Matrix4x4

Creates rotation matrix around X axis.

CreateRotationY ( float radians ) : Matrix4x4

Creates rotation matrix around Y axis.

CreateRotationZ ( float radians ) : Matrix4x4

Creates rotation matrix around Z axis.

CreateTranslation ( Vector3 position ) : Matrix4x4

Creates translation matrix for the specified movement amount.

The specified vector is copied to the 3rd column of the result matrix. All diagonal elements are set to 1. The rest of matrix is initialized with zeros.

Equals ( Matrix4x4 matrix ) : bool

Tests whether the matrix equals to the specified one.

Equals ( Object obj ) : bool

Tests whether the matrix equals to the specified object.

ExtractYawPitchRoll ( float &yaw, float &pitch, float &roll ) : void

Extract rotation angles from the rotation matrix.

The routine assumes roll-pitch-yaw rotation order when extracting rotation angle. Using extracted angles with the CreateFromYawPitchRoll should provide same rotation matrix.

The method assumes the provided matrix represent valid rotation matrix.

Sample usage:

// assume we have a rotation matrix created like this float yaw = 10.0f / 180 * Math.PI; float pitch = 30.0f / 180 * Math.PI; float roll = 45.0f / 180 * Math.PI; Matrix4x4 rotationMatrix = Matrix3x3.CreateFromYawPitchRoll( yaw, pitch, roll ); // ... // now somewhere in the code you may want to get rotation // angles back from a matrix assuming same rotation order float extractedYaw; float extractedPitch; float extractedRoll; rotation.ExtractYawPitchRoll( out extractedYaw, out extractedPitch, out extractedRoll );
GetColumn ( int index ) : Vector4

Get column of the matrix.

GetHashCode ( ) : int

Returns the hashcode for this instance.

GetRow ( int index ) : Vector4

Get row of the matrix.

Multiply ( Matrix4x4 matrix1, Matrix4x4 matrix2 ) : Matrix4x4

Multiplies two specified matrices.

Multiply ( Matrix4x4 matrix, Vector4 vector ) : Vector4

Multiplies specified matrix by the specified vector.

Subtract ( Matrix4x4 matrix1, Matrix4x4 matrix2 ) : Matrix4x4

Subtracts corresponding components of two matrices.

ToArray ( ) : float[]

Returns array representation of the matrix.

operator ( ) : Matrix4x4

Multiplies two specified matrices.

operator ( ) : Vector4

Multiplies specified matrix by the specified vector.

operator ( ) : bool

Tests whether two specified matrices are equal.

Описание методов

Add() публичный статический метод

Adds corresponding components of two matrices.
public static Add ( Matrix4x4 matrix1, Matrix4x4 matrix2 ) : Matrix4x4
matrix1 Matrix4x4 The matrix to add to.
matrix2 Matrix4x4 The matrix to add to the first matrix.
Результат Matrix4x4

CreateDiagonal() публичный статический метод

Creates a diagonal matrix using the specified vector as diagonal elements.
public static CreateDiagonal ( Vector4 vector ) : Matrix4x4
vector Vector4 Vector to use for diagonal elements of the matrix.
Результат Matrix4x4

CreateFromColumns() публичный статический метод

Creates a matrix from 4 columns specified as vectors.
public static CreateFromColumns ( Vector4 column0, Vector4 column1, Vector4 column2, Vector4 column3 ) : Matrix4x4
column0 Vector4 First column of the matrix to create.
column1 Vector4 Second column of the matrix to create.
column2 Vector4 Third column of the matrix to create.
column3 Vector4 Fourth column of the matrix to create.
Результат Matrix4x4

CreateFromRotation() публичный статический метод

Creates 4x4 tranformation matrix from 3x3 rotation matrix.

The source 3x3 rotation matrix is copied into the top left corner of the result 4x4 matrix, i.e. it represents 0th, 1st and 2nd row/column. The V33 element is set to 1 and the rest elements of 3rd row and 3rd column are set to zeros.

public static CreateFromRotation ( Matrix3x3 rotationMatrix ) : Matrix4x4
rotationMatrix Matrix3x3 Source 3x3 rotation matrix.
Результат Matrix4x4

CreateFromRows() публичный статический метод

Creates a matrix from 4 rows specified as vectors.
public static CreateFromRows ( Vector4 row0, Vector4 row1, Vector4 row2, Vector4 row3 ) : Matrix4x4
row0 Vector4 First row of the matrix to create.
row1 Vector4 Second row of the matrix to create.
row2 Vector4 Third row of the matrix to create.
row3 Vector4 Fourth row of the matrix to create.
Результат Matrix4x4

CreateFromYawPitchRoll() публичный статический метод

Creates rotation matrix to rotate an object around X, Y and Z axes.

The routine assumes roll-pitch-yaw rotation order, when creating rotation matrix, i.e. an object is first rotated around Z axis, then around X axis and finally around Y axis.

public static CreateFromYawPitchRoll ( float yaw, float pitch, float roll ) : Matrix4x4
yaw float Rotation angle around Y axis in radians.
pitch float Rotation angle around X axis in radians.
roll float Rotation angle around Z axis in radians.
Результат Matrix4x4

CreateLookAt() публичный статический метод

Creates a view matrix for the specified camera position and target point.

Camera's "up" vector is supposed to be (0, 1, 0).

public static CreateLookAt ( Vector3 cameraPosition, Vector3 cameraTarget ) : Matrix4x4
cameraPosition Vector3 Position of camera.
cameraTarget Vector3 Target point towards which camera is pointing.
Результат Matrix4x4

CreatePerspective() публичный статический метод

Creates a perspective projection matrix.
Both near and far view planes' distances must be greater than zero. Near plane must be closer than the far plane.
public static CreatePerspective ( float width, float height, float nearPlaneDistance, float farPlaneDistance ) : Matrix4x4
width float Width of the view volume at the near view plane.
height float Height of the view volume at the near view plane.
nearPlaneDistance float Distance to the near view plane.
farPlaneDistance float Distance to the far view plane.
Результат Matrix4x4

CreateRotationX() публичный статический метод

Creates rotation matrix around X axis.
public static CreateRotationX ( float radians ) : Matrix4x4
radians float Rotation angle around X axis in radians.
Результат Matrix4x4

CreateRotationY() публичный статический метод

Creates rotation matrix around Y axis.
public static CreateRotationY ( float radians ) : Matrix4x4
radians float Rotation angle around Y axis in radians.
Результат Matrix4x4

CreateRotationZ() публичный статический метод

Creates rotation matrix around Z axis.
public static CreateRotationZ ( float radians ) : Matrix4x4
radians float Rotation angle around Z axis in radians.
Результат Matrix4x4

CreateTranslation() публичный статический метод

Creates translation matrix for the specified movement amount.

The specified vector is copied to the 3rd column of the result matrix. All diagonal elements are set to 1. The rest of matrix is initialized with zeros.

public static CreateTranslation ( Vector3 position ) : Matrix4x4
position Vector3 Vector which set direction and amount of movement.
Результат Matrix4x4

Equals() публичный метод

Tests whether the matrix equals to the specified one.
public Equals ( Matrix4x4 matrix ) : bool
matrix Matrix4x4 The matrix to test equality with.
Результат bool

Equals() публичный метод

Tests whether the matrix equals to the specified object.
public Equals ( Object obj ) : bool
obj Object The object to test equality with.
Результат bool

ExtractYawPitchRoll() публичный метод

Extract rotation angles from the rotation matrix.

The routine assumes roll-pitch-yaw rotation order when extracting rotation angle. Using extracted angles with the CreateFromYawPitchRoll should provide same rotation matrix.

The method assumes the provided matrix represent valid rotation matrix.

Sample usage:

// assume we have a rotation matrix created like this float yaw = 10.0f / 180 * Math.PI; float pitch = 30.0f / 180 * Math.PI; float roll = 45.0f / 180 * Math.PI; Matrix4x4 rotationMatrix = Matrix3x3.CreateFromYawPitchRoll( yaw, pitch, roll ); // ... // now somewhere in the code you may want to get rotation // angles back from a matrix assuming same rotation order float extractedYaw; float extractedPitch; float extractedRoll; rotation.ExtractYawPitchRoll( out extractedYaw, out extractedPitch, out extractedRoll );
public ExtractYawPitchRoll ( float &yaw, float &pitch, float &roll ) : void
yaw float Extracted rotation angle around Y axis in radians.
pitch float Extracted rotation angle around X axis in radians.
roll float Extracted rotation angle around Z axis in radians.
Результат void

GetColumn() публичный метод

Get column of the matrix.
Invalid column index was specified.
public GetColumn ( int index ) : Vector4
index int Column index to get, [0, 3].
Результат Vector4

GetHashCode() публичный метод

Returns the hashcode for this instance.
public GetHashCode ( ) : int
Результат int

GetRow() публичный метод

Get row of the matrix.
Invalid row index was specified.
public GetRow ( int index ) : Vector4
index int Row index to get, [0, 3].
Результат Vector4

Multiply() публичный статический метод

Multiplies two specified matrices.
public static Multiply ( Matrix4x4 matrix1, Matrix4x4 matrix2 ) : Matrix4x4
matrix1 Matrix4x4 Matrix to multiply.
matrix2 Matrix4x4 Matrix to multiply by.
Результат Matrix4x4

Multiply() публичный статический метод

Multiplies specified matrix by the specified vector.
public static Multiply ( Matrix4x4 matrix, Vector4 vector ) : Vector4
matrix Matrix4x4 Matrix to multiply by vector.
vector Vector4 Vector to multiply matrix by.
Результат Vector4

Subtract() публичный статический метод

Subtracts corresponding components of two matrices.
public static Subtract ( Matrix4x4 matrix1, Matrix4x4 matrix2 ) : Matrix4x4
matrix1 Matrix4x4 The matrix to subtract from.
matrix2 Matrix4x4 The matrix to subtract from the first matrix.
Результат Matrix4x4

ToArray() публичный метод

Returns array representation of the matrix.
public ToArray ( ) : float[]
Результат float[]

operator() публичный статический метод

Multiplies two specified matrices.
public static operator ( ) : Matrix4x4
Результат Matrix4x4

operator() публичный статический метод

Multiplies specified matrix by the specified vector.
public static operator ( ) : Vector4
Результат Vector4

operator() публичный статический метод

Tests whether two specified matrices are equal.
public static operator ( ) : bool
Результат bool

Описание свойств

V00 публичное свойство

Row 0 column 0 element of the matrix.
public float V00
Результат float

V01 публичное свойство

Row 0 column 1 element of the matrix.
public float V01
Результат float

V02 публичное свойство

Row 0 column 2 element of the matrix.
public float V02
Результат float

V03 публичное свойство

Row 0 column 3 element of the matrix.
public float V03
Результат float

V10 публичное свойство

Row 1 column 0 element of the matrix.
public float V10
Результат float

V11 публичное свойство

Row 1 column 1 element of the matrix.
public float V11
Результат float

V12 публичное свойство

Row 1 column 2 element of the matrix.
public float V12
Результат float

V13 публичное свойство

Row 1 column 3 element of the matrix.
public float V13
Результат float

V20 публичное свойство

Row 2 column 0 element of the matrix.
public float V20
Результат float

V21 публичное свойство

Row 2 column 1 element of the matrix.
public float V21
Результат float

V22 публичное свойство

Row 2 column 2 element of the matrix.
public float V22
Результат float

V23 публичное свойство

Row 2 column 3 element of the matrix.
public float V23
Результат float

V30 публичное свойство

Row 3 column 0 element of the matrix.
public float V30
Результат float

V31 публичное свойство

Row 3 column 1 element of the matrix.
public float V31
Результат float

V32 публичное свойство

Row 3 column 2 element of the matrix.
public float V32
Результат float

V33 публичное свойство

Row 3 column 3 element of the matrix.
public float V33
Результат float