C# Class Accord.Math.Matrix3x3

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

Public Properties

Property Type Description
V00 float
V01 float
V02 float
V10 float
V11 float
V12 float
V20 float
V21 float
V22 float

Public Methods

Method Description
Add ( Matrix3x3 matrix1, Matrix3x3 matrix2 ) : Matrix3x3

Adds corresponding components of two matrices.

Add ( Matrix3x3 matrix, float value ) : Matrix3x3

Adds specified value to all components of the specified matrix.

Adjugate ( ) : Matrix3x3

Calculate adjugate of the matrix, adj(A).

CreateDiagonal ( Vector3 vector ) : Matrix3x3

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

CreateFromColumns ( Vector3 column0, Vector3 column1, Vector3 column2 ) : Matrix3x3

Creates a matrix from 3 columns specified as vectors.

CreateFromRows ( Vector3 row0, Vector3 row1, Vector3 row2 ) : Matrix3x3

Creates a matrix from 3 rows specified as vectors.

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

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.

CreateRotationX ( float radians ) : Matrix3x3

Creates rotation matrix around X axis.

CreateRotationY ( float radians ) : Matrix3x3

Creates rotation matrix around Y axis.

CreateRotationZ ( float radians ) : Matrix3x3

Creates rotation matrix around Z axis.

Equals ( Matrix3x3 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; Matrix3x3 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 ) : Vector3

Get column of the matrix.

GetHashCode ( ) : int

Returns the hashcode for this instance.

GetRow ( int index ) : Vector3

Get row of the matrix.

Inverse ( ) : Matrix3x3

Calculate inverse of the matrix, A-1.

Multiply ( Matrix3x3 matrix1, Matrix3x3 matrix2 ) : Matrix3x3

Multiplies two specified matrices.

Multiply ( Matrix3x3 matrix, float factor ) : Matrix3x3

Multiplies matrix by the specified factor.

Multiply ( Matrix3x3 matrix, Vector3 vector ) : Vector3

Multiplies specified matrix by the specified vector.

MultiplySelfByTranspose ( ) : Matrix3x3

Multiply the matrix by its transposition, A*AT.

MultiplyTransposeBySelf ( ) : Matrix3x3

Multiply transposition of this matrix by itself, AT*A.

PseudoInverse ( ) : Matrix3x3

Calculate pseudo inverse of the matrix, A+.

The pseudo inverse of the matrix is calculate through its SVD as V*E+*UT.

SVD ( Matrix3x3 &u, Vector3 &e, Matrix3x3 &v ) : void

Calculate Singular Value Decomposition (SVD) of the matrix, such as A=U*E*VT.

Having components U, E and V the source matrix can be reproduced using below code: Matrix3x3 source = u * Matrix3x3.Diagonal( e ) * v.Transpose( );

Subtract ( Matrix3x3 matrix1, Matrix3x3 matrix2 ) : Matrix3x3

Subtracts corresponding components of two matrices.

ToArray ( ) : float[]

Returns array representation of the matrix.

Transpose ( ) : Matrix3x3

Transpose the matrix, AT.

operator ( ) : Matrix3x3

Multiplies two specified matrices.

operator ( ) : Vector3

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 ( Matrix3x3 matrix1, Matrix3x3 matrix2 ) : Matrix3x3
matrix1 Matrix3x3 The matrix to add to.
matrix2 Matrix3x3 The matrix to add to the first matrix.
return Matrix3x3

Add() public static method

Adds specified value to all components of the specified matrix.
public static Add ( Matrix3x3 matrix, float value ) : Matrix3x3
matrix Matrix3x3 Matrix to add value to.
value float Value to add to all components of the specified matrix.
return Matrix3x3

Adjugate() public method

Calculate adjugate of the matrix, adj(A).
public Adjugate ( ) : Matrix3x3
return Matrix3x3

CreateDiagonal() public static method

Creates a diagonal matrix using the specified vector as diagonal elements.
public static CreateDiagonal ( Vector3 vector ) : Matrix3x3
vector Vector3 Vector to use for diagonal elements of the matrix.
return Matrix3x3

CreateFromColumns() public static method

Creates a matrix from 3 columns specified as vectors.
public static CreateFromColumns ( Vector3 column0, Vector3 column1, Vector3 column2 ) : Matrix3x3
column0 Vector3 First column of the matrix to create.
column1 Vector3 Second column of the matrix to create.
column2 Vector3 Third column of the matrix to create.
return Matrix3x3

CreateFromRows() public static method

Creates a matrix from 3 rows specified as vectors.
public static CreateFromRows ( Vector3 row0, Vector3 row1, Vector3 row2 ) : Matrix3x3
row0 Vector3 First row of the matrix to create.
row1 Vector3 Second row of the matrix to create.
row2 Vector3 Third row of the matrix to create.
return Matrix3x3

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 ) : Matrix3x3
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 Matrix3x3

CreateRotationX() public static method

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

CreateRotationY() public static method

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

CreateRotationZ() public static method

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

Equals() public method

Tests whether the matrix equals to the specified one.
public Equals ( Matrix3x3 matrix ) : bool
matrix Matrix3x3 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; Matrix3x3 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 ) : Vector3
index int Column index to get, [0, 2].
return Vector3

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 ) : Vector3
index int Row index to get, [0, 2].
return Vector3

Inverse() public method

Calculate inverse of the matrix, A-1.
Cannot calculate inverse of the matrix since it is singular.
public Inverse ( ) : Matrix3x3
return Matrix3x3

Multiply() public static method

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

Multiply() public static method

Multiplies matrix by the specified factor.
public static Multiply ( Matrix3x3 matrix, float factor ) : Matrix3x3
matrix Matrix3x3 Matrix to multiply.
factor float Factor to multiple the specified matrix by.
return Matrix3x3

Multiply() public static method

Multiplies specified matrix by the specified vector.
public static Multiply ( Matrix3x3 matrix, Vector3 vector ) : Vector3
matrix Matrix3x3 Matrix to multiply by vector.
vector Vector3 Vector to multiply matrix by.
return Vector3

MultiplySelfByTranspose() public method

Multiply the matrix by its transposition, A*AT.
public MultiplySelfByTranspose ( ) : Matrix3x3
return Matrix3x3

MultiplyTransposeBySelf() public method

Multiply transposition of this matrix by itself, AT*A.
public MultiplyTransposeBySelf ( ) : Matrix3x3
return Matrix3x3

PseudoInverse() public method

Calculate pseudo inverse of the matrix, A+.

The pseudo inverse of the matrix is calculate through its SVD as V*E+*UT.

public PseudoInverse ( ) : Matrix3x3
return Matrix3x3

SVD() public method

Calculate Singular Value Decomposition (SVD) of the matrix, such as A=U*E*VT.

Having components U, E and V the source matrix can be reproduced using below code: Matrix3x3 source = u * Matrix3x3.Diagonal( e ) * v.Transpose( );

public SVD ( Matrix3x3 &u, Vector3 &e, Matrix3x3 &v ) : void
u Matrix3x3 Output parameter which gets 3x3 U matrix.
e Vector3 Output parameter which gets diagonal elements of the E matrix.
v Matrix3x3 Output parameter which gets 3x3 V matrix.
return void

Subtract() public static method

Subtracts corresponding components of two matrices.
public static Subtract ( Matrix3x3 matrix1, Matrix3x3 matrix2 ) : Matrix3x3
matrix1 Matrix3x3 The matrix to subtract from.
matrix2 Matrix3x3 The matrix to subtract from the first matrix.
return Matrix3x3

ToArray() public method

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

Transpose() public method

Transpose the matrix, AT.
public Transpose ( ) : Matrix3x3
return Matrix3x3

operator() public static method

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

operator() public static method

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

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

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

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