Catalano.Math
Class Matrix3x3
- java.lang.Object
-
- Catalano.Math.Matrix3x3
-
public class Matrix3x3 extends java.lang.ObjectA class representing 3x3 matrix.The structure incapsulates elements of a 3x3 matrix and provides some operations with it.
-
-
Field Summary
Fields Modifier and Type Field and Description floatV00Row 0 column 0 element of the matrix.floatV01Row 0 column 1 element of the matrix.floatV02Row 0 column 2 element of the matrix.floatV10Row 1 column 0 element of the matrix.floatV11Row 1 column 1 element of the matrix.floatV12Row 1 column 2 element of the matrix.floatV20Row 2 column 0 element of the matrix.floatV21Row 2 column 1 element of the matrix.floatV22Row 2 column 2 element of the matrix.
-
Constructor Summary
Constructors Constructor and Description Matrix3x3()Initializes a new instance of the Matrix3x3 class.Matrix3x3(float V00, float V01, float V02, float V10, float V11, float V12, float V20, float V21, float V22)Initializes a new instance of the Matrix3x3 class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidAdd(Matrix3x3 matrix)static Matrix3x3Add(Matrix3x3 matrix1, Matrix3x3 matrix2)Adds corresponding components of two matrices.static Matrix3x3CreateDiagonal(Vector3 vector)Creates a diagonal matrix using the specified vector as diagonal elements.static Matrix3x3CreateFromColumns(Vector3 column0, Vector3 column1, Vector3 column2)Creates a matrix from 3 columns specified as vectors.static Matrix3x3CreateFromRows(Vector3 row0, Vector3 row1, Vector3 row2)Creates a matrix from 3 rows specified as vectors.static Matrix3x3CreateFromYawPitchRoll(float yaw, float pitch, float roll)Creates rotation matrix to rotate an object around X, Y and Z axes.static Matrix3x3CreateRotationX(float radians)Creates rotation matrix around X axis.static Matrix3x3CreateRotationY(float radians)Creates rotation matrix around Y axis.static Matrix3x3CreateRotationZ(float radians)Creates rotation matrix around Z axis.floatDeterminant()Calculates determinant of the matrix.float[]ExtractYawPitchRoll()Extract rotation angles from the rotation matrix.static Matrix3x3Identity()Provides an identity matrix with all diagonal elements set to 1.voidMultiply(Matrix3x3 matrix)static Matrix3x3Multiply(Matrix3x3 matrix1, Matrix3x3 matrix2)Multiplies two specified matrices.voidSubtract(Matrix3x3 matrix)static Matrix3x3Subtract(Matrix3x3 matrix1, Matrix3x3 matrix2)Subtracts corresponding components of two matrices.float[]toArray()Returns array representation of the matrix.
-
-
-
Field Detail
-
V00
public float V00
Row 0 column 0 element of the matrix.
-
V01
public float V01
Row 0 column 1 element of the matrix.
-
V02
public float V02
Row 0 column 2 element of the matrix.
-
V10
public float V10
Row 1 column 0 element of the matrix.
-
V11
public float V11
Row 1 column 1 element of the matrix.
-
V12
public float V12
Row 1 column 2 element of the matrix.
-
V20
public float V20
Row 2 column 0 element of the matrix.
-
V21
public float V21
Row 2 column 1 element of the matrix.
-
V22
public float V22
Row 2 column 2 element of the matrix.
-
-
Constructor Detail
-
Matrix3x3
public Matrix3x3()
Initializes a new instance of the Matrix3x3 class.
-
Matrix3x3
public Matrix3x3(float V00, float V01, float V02, float V10, float V11, float V12, float V20, float V21, float V22)Initializes a new instance of the Matrix3x3 class.- Parameters:
V00- Row 0 column 0 element of the matrix.V01- Row 0 column 1 element of the matrix.V02- Row 0 column 2 element of the matrix.V10- Row 1 column 0 element of the matrix.V11- Row 1 column 1 element of the matrix.V12- Row 1 column 2 element of the matrix.V20- Row 2 column 0 element of the matrix.V21- Row 2 column 1 element of the matrix.V22- Row 2 column 2 element of the matrix.
-
-
Method Detail
-
Identity
public static Matrix3x3 Identity()
Provides an identity matrix with all diagonal elements set to 1.- Returns:
- Identity matrix.
-
Determinant
public float Determinant()
Calculates determinant of the matrix.- Returns:
- Determinant.
-
toArray
public float[] toArray()
Returns array representation of the matrix.- Returns:
- Returns array which contains all elements of the matrix in the row-major order.
-
CreateRotationY
public static Matrix3x3 CreateRotationY(float radians)
Creates rotation matrix around Y axis.- Parameters:
radians- Rotation angle around Y axis in radians.- Returns:
- Returns rotation matrix to rotate an object around Y axis.
-
CreateRotationX
public static Matrix3x3 CreateRotationX(float radians)
Creates rotation matrix around X axis.- Parameters:
radians- Rotation angle around X axis in radians.- Returns:
- Returns rotation matrix to rotate an object around X axis.
-
CreateRotationZ
public static Matrix3x3 CreateRotationZ(float radians)
Creates rotation matrix around Z axis.- Parameters:
radians- Rotation angle around Z axis in radians.- Returns:
- Returns rotation matrix to rotate an object around Z axis.
-
CreateFromYawPitchRoll
public static Matrix3x3 CreateFromYawPitchRoll(float yaw, float pitch, float roll)
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. - Parameters:
yaw- Rotation angle around Y axis in radians.pitch- Rotation angle around X axis in radians.roll- Rotation angle around Z axis in radians.- Returns:
- Returns rotation matrix to rotate an object around all 3 axes.
-
ExtractYawPitchRoll
public float[] 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 @see CreateFromYawPitchRoll should provide same rotation matrix. The method assumes the provided matrix represent valid rotation matrix. - Returns:
-
CreateFromRows
public static Matrix3x3 CreateFromRows(Vector3 row0, Vector3 row1, Vector3 row2)
Creates a matrix from 3 rows specified as vectors.- Parameters:
row0- First row of the matrix to create.row1- Second row of the matrix to create.row2- Third row of the matrix to create.- Returns:
- Returns a matrix from specified rows.
-
CreateFromColumns
public static Matrix3x3 CreateFromColumns(Vector3 column0, Vector3 column1, Vector3 column2)
Creates a matrix from 3 columns specified as vectors.- Parameters:
column0- First column of the matrix to create.column1- Second column of the matrix to create.column2- Third column of the matrix to create.- Returns:
- Returns a matrix from specified columns.
-
CreateDiagonal
public static Matrix3x3 CreateDiagonal(Vector3 vector)
Creates a diagonal matrix using the specified vector as diagonal elements.- Parameters:
vector- Vector to use for diagonal elements of the matrix.- Returns:
- Returns a diagonal matrix.
-
Multiply
public void Multiply(Matrix3x3 matrix)
-
Multiply
public static Matrix3x3 Multiply(Matrix3x3 matrix1, Matrix3x3 matrix2)
Multiplies two specified matrices.- Parameters:
matrix1- Matrix to multiply.matrix2- Matrix to multiply by.- Returns:
- Return new matrix, which the result of multiplication of the two specified matrices.
-
Add
public void Add(Matrix3x3 matrix)
-
Add
public static Matrix3x3 Add(Matrix3x3 matrix1, Matrix3x3 matrix2)
Adds corresponding components of two matrices.- Parameters:
matrix1- The matrix to add to.matrix2- The matrix to add to the first matrix.- Returns:
- Returns a matrix which components are equal to sum of corresponding components of the two specified matrices.
-
Subtract
public void Subtract(Matrix3x3 matrix)
-
Subtract
public static Matrix3x3 Subtract(Matrix3x3 matrix1, Matrix3x3 matrix2)
Subtracts corresponding components of two matrices.- Parameters:
matrix1- The matrix to subtract from.matrix2- The matrix to subtract from the first matrix.- Returns:
- Returns a matrix which components are equal to difference of corresponding components of the two specified matrices.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG