C# Class Accord.Math.Matrix4x4

ファイルを表示 Open project: accord-net/framework Class Usage Examples

Public Properties

Property Type Description
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

Public Methods

Method Description
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.

Method Details

Add() public static method

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.
return Matrix4x4

CreateDiagonal() public static method

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.
return Matrix4x4

CreateFromColumns() public static method

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.
return Matrix4x4

CreateFromRotation() public static method

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.
return Matrix4x4

CreateFromRows() public static method

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.
return Matrix4x4

CreateFromYawPitchRoll() public static method

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.
return Matrix4x4

CreateLookAt() public static method

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.
return Matrix4x4

CreatePerspective() public static method

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.
return Matrix4x4

CreateRotationX() public static method

Creates rotation matrix around X axis.
public static CreateRotationX ( float radians ) : Matrix4x4
radians float Rotation angle around X axis in radians.
return Matrix4x4

CreateRotationY() public static method

Creates rotation matrix around Y axis.
public static CreateRotationY ( float radians ) : Matrix4x4
radians float Rotation angle around Y axis in radians.
return Matrix4x4

CreateRotationZ() public static method

Creates rotation matrix around Z axis.
public static CreateRotationZ ( float radians ) : Matrix4x4
radians float Rotation angle around Z axis in radians.
return Matrix4x4

CreateTranslation() public static method

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.
return Matrix4x4

Equals() public method

Tests whether the matrix equals to the specified one.
public Equals ( Matrix4x4 matrix ) : bool
matrix Matrix4x4 The matrix to test equality with.
return bool

Equals() public method

Tests whether the matrix equals to the specified object.
public Equals ( Object obj ) : bool
obj Object The object to test equality with.
return bool

ExtractYawPitchRoll() public method

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.
return void

GetColumn() public method

Get column of the matrix.
Invalid column index was specified.
public GetColumn ( int index ) : Vector4
index int Column index to get, [0, 3].
return Vector4

GetHashCode() public method

Returns the hashcode for this instance.
public GetHashCode ( ) : int
return int

GetRow() public method

Get row of the matrix.
Invalid row index was specified.
public GetRow ( int index ) : Vector4
index int Row index to get, [0, 3].
return Vector4

Multiply() public static method

Multiplies two specified matrices.
public static Multiply ( Matrix4x4 matrix1, Matrix4x4 matrix2 ) : Matrix4x4
matrix1 Matrix4x4 Matrix to multiply.
matrix2 Matrix4x4 Matrix to multiply by.
return Matrix4x4

Multiply() public static method

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.
return Vector4

Subtract() public static method

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.
return Matrix4x4

ToArray() public method

Returns array representation of the matrix.
public ToArray ( ) : float[]
return float[]

operator() public static method

Multiplies two specified matrices.
public static operator ( ) : Matrix4x4
return Matrix4x4

operator() public static method

Multiplies specified matrix by the specified vector.
public static operator ( ) : Vector4
return Vector4

operator() public static method

Tests whether two specified matrices are equal.
public static operator ( ) : bool
return bool

Property Details

V00 public_oe property

Row 0 column 0 element of the matrix.
public float V00
return float

V01 public_oe property

Row 0 column 1 element of the matrix.
public float V01
return float

V02 public_oe property

Row 0 column 2 element of the matrix.
public float V02
return float

V03 public_oe property

Row 0 column 3 element of the matrix.
public float V03
return float

V10 public_oe property

Row 1 column 0 element of the matrix.
public float V10
return float

V11 public_oe property

Row 1 column 1 element of the matrix.
public float V11
return float

V12 public_oe property

Row 1 column 2 element of the matrix.
public float V12
return float

V13 public_oe property

Row 1 column 3 element of the matrix.
public float V13
return float

V20 public_oe property

Row 2 column 0 element of the matrix.
public float V20
return float

V21 public_oe property

Row 2 column 1 element of the matrix.
public float V21
return float

V22 public_oe property

Row 2 column 2 element of the matrix.
public float V22
return float

V23 public_oe property

Row 2 column 3 element of the matrix.
public float V23
return float

V30 public_oe property

Row 3 column 0 element of the matrix.
public float V30
return float

V31 public_oe property

Row 3 column 1 element of the matrix.
public float V31
return float

V32 public_oe property

Row 3 column 2 element of the matrix.
public float V32
return float

V33 public_oe property

Row 3 column 3 element of the matrix.
public float V33
return float