- java.lang.Object
-
- org.arakhne.afc.math.matrix.Matrix3d
-
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
Transform2D
public class Matrix3d extends Object implements Serializable, Cloneable
Is represented internally as a 3x3 floating point matrix. The mathematical representation is row major, as in traditional matrix mathematics.- Version:
- 17.0 2020-01-04 14:41:43
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgeom
-
-
Field Summary
Fields Modifier and Type Field Description protected Boolean
isIdentity
Indicates if the matrix is identity.protected double
m00
The first matrix element in the first row.protected double
m01
The second matrix element in the first row.protected double
m02
The third matrix element in the first row.protected double
m10
The first matrix element in the second row.protected double
m11
The second matrix element in the second row.protected double
m12
The third matrix element in the second row.protected double
m20
The first matrix element in the third row.protected double
m21
The second matrix element in the third row.protected double
m22
The third matrix element in the third row.
-
Constructor Summary
Constructors Constructor Description Matrix3d()
Constructs and initializes a Matrix3f to all zeros.Matrix3d(double[] values)
Constructs and initializes a Matrix3f from the specified nine- element array.Matrix3d(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Constructs and initializes a Matrix3f from the specified nine values.Matrix3d(Matrix3d matrix)
Constructs a new matrix with the same values as the Matrix3f parameter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Matrix3d
$bang()
Replies the transposition of this matrix:!this
.Matrix3d
$div(double scalar)
Replies the division of this matrix by the given scalar:this / scalar
.Matrix3d
$minus()
Replies the negation of this matrix:-this
.Matrix3d
$minus(double scalar)
Replies the substraction of the given scalar to this matrix:this - scalar
.Matrix3d
$minus(Matrix3d matrix)
Replies the substraction of the given matrix to this matrix:this - matrix
.Matrix3d
$plus(double scalar)
Replies the addition of the given scalar to this matrix:this + scalar
.Matrix3d
$plus(Matrix3d matrix)
Replies the addition of the given matrix to this matrix:this + matrix
.Matrix3d
$times(double scalar)
Replies the multiplication of the given scalar and this matrix:this * scalar
.Matrix3d
$times(Matrix3d matrix)
Replies the multiplication of the given matrix and this matrix:this * matrix
.void
add(double scalar)
Adds a scalar to each component of this matrix.void
add(double scalar, Matrix3d matrix)
Adds a scalar to each component of the matrix m1 and places the result into this.void
add(Matrix3d matrix)
Sets the value of this matrix to the sum of itself and matrix m1.void
add(Matrix3d matrix1, Matrix3d matrix2)
Sets the value of this matrix to the matrix sum of matrices m1 and m2.Matrix3d
clone()
Creates a new object of the same class as this object.protected static void
computeSVD(double[] matrix, double[] outScale, double[] outRot)
Compute the SVD of a matrix m.boolean
cov(Vector3D<?,?> result, Iterable<? extends Tuple3D<?>> tuples)
Set this matrix with the covariance matrix's elements for the given set of tuples.boolean
cov(Vector3D<?,?> result, Point3D<?,?>... tuples)
Set this matrix with the covariance matrix's elements for the given set of tuples.boolean
cov(Vector3D<?,?> result, Vector3D<?,?>... tuples)
Set this matrix with the covariance matrix's elements for the given set of tuples.double
determinant()
Computes the determinant of this matrix.double[]
eigenVectorsOfSymmetricMatrix(Matrix3d eigenVectors)
Compute the eigenvectors of the given symmetric matrix according to the Jacobi Cyclic Method.boolean
epsilonEquals(Matrix3d matrix, double epsilon)
Returns true if the L-infinite distance between this matrix and matrix m1 is less than or equal to the epsilon parameter, otherwise returns false.boolean
equals(Object object)
Returns true if the Object t1 is of type Matrix3f and all of the data members of t1 are equal to the corresponding data members in this Matrix3f.boolean
equals(Matrix3d matrix)
Returns true if all of the data members of Matrix3f m1 are equal to the corresponding data members in this Matrix3f.void
getColumn(int column, double[] vector)
Copies the matrix values in the specified column into the array parameter.void
getColumn(int column, Vector3D<?,?> vector)
Copies the matrix values in the specified column into the vector parameter.double
getElement(int row, int column)
Retrieves the value at the specified row and column of the specified matrix.double
getM00()
Get the first matrix element in the first row.double
getM01()
Get the second matrix element in the first row.double
getM02()
Get the third matrix element in the first row.double
getM10()
Get first matrix element in the second row.double
getM11()
Get second matrix element in the second row.double
getM12()
Get the third matrix element in the second row.double
getM20()
Get the first matrix element in the third row.double
getM21()
Get the second matrix element in the third row.double
getM22()
Get the third matrix element in the third row .void
getRow(int row, double[] vector)
Copies the matrix values in the specified row into the array parameter.void
getRow(int row, Vector3D<?,?> vector)
Copies the matrix values in the specified row into the vector parameter.int
hashCode()
Returns a hash code value based on the data values in this object.void
invert()
Inverts this matrix in place.void
invert(Matrix3d matrix)
Sets the value of this matrix to the matrix inverse of the passed matrix m1.boolean
isIdentity()
Replies if the matrix is identity.boolean
isSymmetric()
Replies if the matrix is symmetric.void
mul(double scalar)
Multiplies each element of this matrix by a scalar.void
mul(double scalar, Matrix3d matrix)
Multiplies each element of matrix m1 by a scalar and places the result into this.void
mul(Vector3D<?,?> vector, Vector3D<?,?> result)
Multiply this matrix by the given vector v and set the result..void
mul(Matrix3d matrix)
Sets the value of this matrix to the result of multiplying itself with matrix m1.void
mul(Matrix3d matrix1, Matrix3d matrix2)
Sets the value of this matrix to the result of multiplying the two argument matrices together.void
mulNormalize(Matrix3d matrix)
Multiplies this matrix by matrix m1, does an SVD normalization of the result, and places the result back into this matrix this = SVDnorm(this*m1).void
mulNormalize(Matrix3d matrix1, Matrix3d matrix2)
Multiplies matrix m1 by matrix m2, does an SVD normalization of the result, and places the result into this matrix this = SVDnorm(m1*m2).void
mulTransposeBoth(Matrix3d matrix1, Matrix3d matrix2)
Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this.void
mulTransposeLeft(Vector3D<?,?> vector, Vector3D<?,?> result)
Multiply the transposing of this matrix by the given vector.void
mulTransposeLeft(Matrix3d matrix1, Matrix3d matrix2)
Multiplies the transpose of matrix m1 times matrix m2, and places the result into this.void
mulTransposeRight(Matrix3d matrix1, Matrix3d matrix2)
Multiplies matrix m1 times the transpose of matrix m2, and places the result into this.void
negate()
Negates the value of this matrix: this = -this.void
negate(Matrix3d matrix)
Sets the value of this matrix equal to the negation of of the Matrix3f parameter.void
normalize()
Performs singular value decomposition normalization of this matrix.void
normalize(Matrix3d matrix)
Perform singular value decomposition normalization of matrix m1 and place the normalized values into this.void
normalizeCP()
Perform cross product normalization of this matrix.void
normalizeCP(Matrix3d matrix)
Perform cross product normalization of matrix m1 and place the normalized values into this.void
operator_add(double scalar)
Add the given scalar to this matrix:this += scalar
.void
operator_add(Matrix3d matrix)
Add the given matrix to this matrix:this += matrix
.Matrix3d
operator_divide(double scalar)
Replies the division of this matrix by the given scalar:this / scalar
.Matrix3d
operator_minus()
Replies the negation of this matrix:-this
.Matrix3d
operator_minus(double scalar)
Replies the substraction of the given scalar to this matrix:this - scalar
.Matrix3d
operator_minus(Matrix3d matrix)
Replies the substraction of the given matrix to this matrix:this - matrix
.void
operator_moinsMoins()
Increment this matrix:this--
.Matrix3d
operator_multiply(double scalar)
Replies the multiplication of the given scalar and this matrix:this * scalar
.Matrix3d
operator_multiply(Matrix3d matrix)
Replies the multiplication of the given matrix and this matrix:this * matrix
.Matrix3d
operator_not()
Replies the transposition of this matrix:!this
.Matrix3d
operator_plus(double scalar)
Replies the addition of the given scalar to this matrix:this + scalar
.Matrix3d
operator_plus(Matrix3d matrix)
Replies the addition of the given matrix to this matrix:this + matrix
.void
operator_plusPlus()
Increment this matrix:this++
.void
operator_remove(double scalar)
Substract the given scalar to this matrix:this -= scalar
.void
operator_remove(Matrix3d matrix)
Substract the given matrix to this matrix:this -= matrix
.void
set(double[] matrix)
Sets the values in this Matrix3f equal to the row-major array parameter (ie, the first three elements of the array will be copied into the first row of this matrix, etc.).void
set(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Set the components of the matrix.void
set(Matrix3d matrix)
Sets the value of this matrix to the double value of the Matrix3f argument.void
setColumn(int column, double[] vector)
Sets the specified column of this Matrix3f to the three values provided.void
setColumn(int column, double x, double y, double z)
Sets the specified column of this Matrix3f to the three values provided.void
setColumn(int column, Vector3D<?,?> vector)
Sets the specified column of this Matrix3f to the vector provided.void
setDiagonal(double m00, double m11, double m22)
Sets this matrix as diagonal.void
setElement(int row, int column, double value)
Sets the specified element of this matrix3f to the value provided.void
setIdentity()
Sets this Matrix3f to identity.void
setM00(double m00)
Set the first matrix element in the first row.void
setM01(double m01)
Set the second matrix element in the first row.void
setM02(double m02)
Set the third matrix element in the first row.void
setM10(double m10)
Set first matrix element in the second row.void
setM11(double m11)
Set the second matrix element in the second row.void
setM12(double m11)
Set the third matrix element in the second row.void
setM20(double m20)
Set the first matrix element in the third row.void
setM21(double m21)
Set the second matrix element in the third row.void
setM22(double m22)
Set the third matrix element in the third row.void
setRow(int row, double[] vector)
Sets the specified row of this Matrix3f to the three values provided.void
setRow(int row, double x, double y, double z)
Sets the specified row of this Matrix3f to the 3 values provided.void
setRow(int row, Vector3D<?,?> vector)
Sets the specified row of this Matrix3f to the Vector provided.void
setZero()
Sets this matrix to all zeros.void
sub(Matrix3d matrix)
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).void
sub(Matrix3d matrix1, Matrix3d matrix2)
Sets the value of this matrix to the matrix difference of matrices m1 and m2.String
toString()
Returns a string that contains the values of this Matrix3f.void
transpose()
Sets the value of this matrix to its transpose.void
transpose(Matrix3d matrix)
Sets the value of this matrix to the transpose of the argument matrix.
-
-
-
Field Detail
-
m00
protected double m00
The first matrix element in the first row.
-
m01
protected double m01
The second matrix element in the first row.
-
m02
protected double m02
The third matrix element in the first row.
-
m10
protected double m10
The first matrix element in the second row.
-
m11
protected double m11
The second matrix element in the second row.
-
m12
protected double m12
The third matrix element in the second row.
-
m20
protected double m20
The first matrix element in the third row.
-
m21
protected double m21
The second matrix element in the third row.
-
m22
protected double m22
The third matrix element in the third row.
-
isIdentity
protected Boolean isIdentity
Indicates if the matrix is identity. Ifnull
the identity flag must be determined.
-
-
Constructor Detail
-
Matrix3d
public Matrix3d(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Constructs and initializes a Matrix3f from the specified nine values.- Parameters:
m00
- the [0][0] elementm01
- the [0][1] elementm02
- the [0][2] elementm10
- the [1][0] elementm11
- the [1][1] elementm12
- the [1][2] elementm20
- the [2][0] elementm21
- the [2][1] elementm22
- the [2][2] element
-
Matrix3d
public Matrix3d(double[] values)
Constructs and initializes a Matrix3f from the specified nine- element array.- Parameters:
values
- the array of length 9 containing in order
-
Matrix3d
public Matrix3d(Matrix3d matrix)
Constructs a new matrix with the same values as the Matrix3f parameter.- Parameters:
matrix
- the source matrix
-
Matrix3d
public Matrix3d()
Constructs and initializes a Matrix3f to all zeros.
-
-
Method Detail
-
toString
@Pure public String toString()
Returns a string that contains the values of this Matrix3f.
-
setIdentity
public void setIdentity()
Sets this Matrix3f to identity.
-
setElement
public void setElement(int row, int column, double value)
Sets the specified element of this matrix3f to the value provided.- Parameters:
row
- the row number to be modified (zero indexed)column
- the column number to be modified (zero indexed)value
- the new value
-
getElement
@Pure public double getElement(int row, int column)
Retrieves the value at the specified row and column of the specified matrix.- Parameters:
row
- the row number to be retrieved (zero indexed)column
- the column number to be retrieved (zero indexed)- Returns:
- the value at the indexed element.
-
getRow
public void getRow(int row, Vector3D<?,?> vector)
Copies the matrix values in the specified row into the vector parameter.- Parameters:
row
- the matrix rowvector
- the vector into which the matrix row values will be copied
-
getRow
public void getRow(int row, double[] vector)
Copies the matrix values in the specified row into the array parameter.- Parameters:
row
- the matrix rowvector
- the array into which the matrix row values will be copied
-
getColumn
public void getColumn(int column, Vector3D<?,?> vector)
Copies the matrix values in the specified column into the vector parameter.- Parameters:
column
- the matrix columnvector
- the vector into which the matrix row values will be copied
-
getColumn
public void getColumn(int column, double[] vector)
Copies the matrix values in the specified column into the array parameter.- Parameters:
column
- the matrix columnvector
- the array into which the matrix row values will be copied
-
setRow
public void setRow(int row, double x, double y, double z)
Sets the specified row of this Matrix3f to the 3 values provided.- Parameters:
row
- the row number to be modified (zero indexed)x
- the first column elementy
- the second column elementz
- the third column element
-
setRow
public void setRow(int row, Vector3D<?,?> vector)
Sets the specified row of this Matrix3f to the Vector provided.- Parameters:
row
- the row number to be modified (zero indexed)vector
- the replacement row
-
setRow
public void setRow(int row, double[] vector)
Sets the specified row of this Matrix3f to the three values provided.- Parameters:
row
- the row number to be modified (zero indexed)vector
- the replacement row
-
setColumn
public void setColumn(int column, double x, double y, double z)
Sets the specified column of this Matrix3f to the three values provided.- Parameters:
column
- the column number to be modified (zero indexed)x
- the first row elementy
- the second row elementz
- the third row element
-
setColumn
public void setColumn(int column, Vector3D<?,?> vector)
Sets the specified column of this Matrix3f to the vector provided.- Parameters:
column
- the column number to be modified (zero indexed)vector
- the replacement column
-
setColumn
public void setColumn(int column, double[] vector)
Sets the specified column of this Matrix3f to the three values provided.- Parameters:
column
- the column number to be modified (zero indexed)vector
- the replacement column
-
add
public void add(double scalar)
Adds a scalar to each component of this matrix.- Parameters:
scalar
- the scalar adder
-
add
public void add(double scalar, Matrix3d matrix)
Adds a scalar to each component of the matrix m1 and places the result into this. Matrix m1 is not modified.- Parameters:
scalar
- the scalar addermatrix
- the original matrix values
-
add
public void add(Matrix3d matrix1, Matrix3d matrix2)
Sets the value of this matrix to the matrix sum of matrices m1 and m2.- Parameters:
matrix1
- the first matrixmatrix2
- the second matrix
-
add
public void add(Matrix3d matrix)
Sets the value of this matrix to the sum of itself and matrix m1.- Parameters:
matrix
- the other matrix
-
sub
public void sub(Matrix3d matrix1, Matrix3d matrix2)
Sets the value of this matrix to the matrix difference of matrices m1 and m2.- Parameters:
matrix1
- the first matrixmatrix2
- the second matrix
-
sub
public void sub(Matrix3d matrix)
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).- Parameters:
matrix
- the other matrix
-
transpose
public void transpose()
Sets the value of this matrix to its transpose.
-
transpose
public void transpose(Matrix3d matrix)
Sets the value of this matrix to the transpose of the argument matrix.- Parameters:
matrix
- the matrix to be transposed
-
set
public void set(Matrix3d matrix)
Sets the value of this matrix to the double value of the Matrix3f argument.- Parameters:
matrix
- the Matrix3f to be converted to double
-
set
public void set(double[] matrix)
Sets the values in this Matrix3f equal to the row-major array parameter (ie, the first three elements of the array will be copied into the first row of this matrix, etc.).- Parameters:
matrix
- the double precision array of length 9
-
set
public void set(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Set the components of the matrix.- Parameters:
m00
- the [0][0] elementm01
- the [0][1] elementm02
- the [0][2] elementm10
- the [1][0] elementm11
- the [1][1] elementm12
- the [1][2] elementm20
- the [2][0] elementm21
- the [2][1] elementm22
- the [2][2] element
-
invert
public void invert(Matrix3d matrix)
Sets the value of this matrix to the matrix inverse of the passed matrix m1.- Parameters:
matrix
- the matrix to be inverted
-
invert
public void invert()
Inverts this matrix in place.
-
determinant
@Pure public double determinant()
Computes the determinant of this matrix.- Returns:
- the determinant of the matrix
-
mul
public void mul(double scalar)
Multiplies each element of this matrix by a scalar.- Parameters:
scalar
- The scalar multiplier.
-
mul
public void mul(double scalar, Matrix3d matrix)
Multiplies each element of matrix m1 by a scalar and places the result into this. Matrix m1 is not modified.- Parameters:
scalar
- the scalar multipliermatrix
- the original matrix
-
mul
public void mul(Matrix3d matrix)
Sets the value of this matrix to the result of multiplying itself with matrix m1.- Parameters:
matrix
- the other matrix
-
mul
public void mul(Matrix3d matrix1, Matrix3d matrix2)
Sets the value of this matrix to the result of multiplying the two argument matrices together.- Parameters:
matrix1
- the first matrixmatrix2
- the second matrix
-
mul
@Pure public void mul(Vector3D<?,?> vector, Vector3D<?,?> result)
Multiply this matrix by the given vector v and set the result..- Parameters:
vector
- the vector.result
- the vector resulting ofthis * v
.
-
mulTransposeLeft
@Pure public void mulTransposeLeft(Vector3D<?,?> vector, Vector3D<?,?> result)
Multiply the transposing of this matrix by the given vector.- Parameters:
vector
- the vector.result
- the vector resulting oftranspose(this) * v
.
-
mulTransposeLeft
public void mulTransposeLeft(Matrix3d matrix1, Matrix3d matrix2)
Multiplies the transpose of matrix m1 times matrix m2, and places the result into this.- Parameters:
matrix1
- the matrix on the left hand side of the multiplicationmatrix2
- the matrix on the right hand side of the multiplication
-
mulNormalize
public void mulNormalize(Matrix3d matrix)
Multiplies this matrix by matrix m1, does an SVD normalization of the result, and places the result back into this matrix this = SVDnorm(this*m1).- Parameters:
matrix
- the matrix on the right hand side of the multiplication
-
mulNormalize
public void mulNormalize(Matrix3d matrix1, Matrix3d matrix2)
Multiplies matrix m1 by matrix m2, does an SVD normalization of the result, and places the result into this matrix this = SVDnorm(m1*m2).- Parameters:
matrix1
- the matrix on the left hand side of the multiplicationmatrix2
- the matrix on the right hand side of the multiplication
-
mulTransposeBoth
public void mulTransposeBoth(Matrix3d matrix1, Matrix3d matrix2)
Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this.- Parameters:
matrix1
- the matrix on the left hand side of the multiplicationmatrix2
- the matrix on the right hand side of the multiplication
-
mulTransposeRight
public void mulTransposeRight(Matrix3d matrix1, Matrix3d matrix2)
Multiplies matrix m1 times the transpose of matrix m2, and places the result into this.- Parameters:
matrix1
- the matrix on the left hand side of the multiplicationmatrix2
- the matrix on the right hand side of the multiplication
-
normalize
public void normalize(Matrix3d matrix)
Perform singular value decomposition normalization of matrix m1 and place the normalized values into this.- Parameters:
matrix
- Provides the matrix values to be normalized
-
normalize
public void normalize()
Performs singular value decomposition normalization of this matrix.
-
normalizeCP
public void normalizeCP()
Perform cross product normalization of this matrix.
-
normalizeCP
public void normalizeCP(Matrix3d matrix)
Perform cross product normalization of matrix m1 and place the normalized values into this.- Parameters:
matrix
- Provides the matrix values to be normalized
-
equals
@Pure public boolean equals(Matrix3d matrix)
Returns true if all of the data members of Matrix3f m1 are equal to the corresponding data members in this Matrix3f.- Parameters:
matrix
- the matrix with which the comparison is made- Returns:
- true or false
-
equals
@Pure public boolean equals(Object object)
Returns true if the Object t1 is of type Matrix3f and all of the data members of t1 are equal to the corresponding data members in this Matrix3f.
-
epsilonEquals
@Pure public boolean epsilonEquals(Matrix3d matrix, double epsilon)
Returns true if the L-infinite distance between this matrix and matrix m1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[i=0, 1, 2 ; j=0, 1, 2 ; abs(this.m(i, j) - m1.m(i, j)]- Parameters:
matrix
- the matrix to be compared to this matrixepsilon
- the threshold value- Returns:
true
if this matrix is equals to the specified matrix at epsilon.
-
hashCode
@Pure public int hashCode()
Returns a hash code value based on the data values in this object. Two different Matrix3f objects with identical data values (i.e., Matrix3f.equals returns true) will return the same hash code value. Two objects with different data members may return the same hash value, although this is not likely.
-
setZero
public void setZero()
Sets this matrix to all zeros.
-
setDiagonal
public void setDiagonal(double m00, double m11, double m22)
Sets this matrix as diagonal.- Parameters:
m00
- the first element of the diagonalm11
- the second element of the diagonalm22
- the third element of the diagonal
-
negate
public void negate()
Negates the value of this matrix: this = -this.
-
negate
public void negate(Matrix3d matrix)
Sets the value of this matrix equal to the negation of of the Matrix3f parameter.- Parameters:
matrix
- the source matrix
-
computeSVD
protected static void computeSVD(double[] matrix, double[] outScale, double[] outRot)
Compute the SVD of a matrix m.- Parameters:
matrix
- the matrix.outScale
- is set with the scaling factors.outRot
- is set with the rotation factors.
-
clone
@Pure public Matrix3d clone()
Creates a new object of the same class as this object.- Overrides:
clone
in classObject
- Returns:
- a clone of this instance.
- Throws:
OutOfMemoryError
- if there is not enough memory.- See Also:
Cloneable
-
getM00
@Pure public double getM00()
Get the first matrix element in the first row.- Returns:
- Returns the m00.
-
setM00
public void setM00(double m00)
Set the first matrix element in the first row.- Parameters:
m00
- The m00 to set.
-
getM01
@Pure public double getM01()
Get the second matrix element in the first row.- Returns:
- Returns the m01.
-
setM01
public void setM01(double m01)
Set the second matrix element in the first row.- Parameters:
m01
- The m01 to set.
-
getM02
@Pure public double getM02()
Get the third matrix element in the first row.- Returns:
- Returns the m02.
-
setM02
public void setM02(double m02)
Set the third matrix element in the first row.- Parameters:
m02
- The m02 to set.
-
getM10
@Pure public double getM10()
Get first matrix element in the second row.- Returns:
- Returns the m10.
-
setM10
public void setM10(double m10)
Set first matrix element in the second row.- Parameters:
m10
- The m10 to set.
-
getM11
@Pure public double getM11()
Get second matrix element in the second row.- Returns:
- Returns the m11.
-
setM11
public void setM11(double m11)
Set the second matrix element in the second row.- Parameters:
m11
- The m11 to set.
-
getM12
@Pure public double getM12()
Get the third matrix element in the second row.- Returns:
- Returns the m12.
-
setM12
public void setM12(double m11)
Set the third matrix element in the second row.- Parameters:
m11
- The m12 to set.
-
getM20
@Pure public double getM20()
Get the first matrix element in the third row.- Returns:
- Returns the m20
-
setM20
public void setM20(double m20)
Set the first matrix element in the third row.- Parameters:
m20
- The m20 to set.
-
getM21
@Pure public double getM21()
Get the second matrix element in the third row.- Returns:
- Returns the m21.
-
setM21
public void setM21(double m21)
Set the second matrix element in the third row.- Parameters:
m21
- The m21 to set.
-
getM22
@Pure public double getM22()
Get the third matrix element in the third row .- Returns:
- Returns the m22.
-
setM22
public void setM22(double m22)
Set the third matrix element in the third row.- Parameters:
m22
- The m22 to set.
-
cov
public boolean cov(Vector3D<?,?> result, Vector3D<?,?>... tuples)
Set this matrix with the covariance matrix's elements for the given set of tuples.- Parameters:
result
- the mean of the tuples.tuples
- the input tuples.- Returns:
true
if the cov matrix is computed.
-
cov
public boolean cov(Vector3D<?,?> result, Point3D<?,?>... tuples)
Set this matrix with the covariance matrix's elements for the given set of tuples.- Parameters:
result
- the mean of the tuples.tuples
- the input tuples.- Returns:
true
if the cov matrix is computed.
-
cov
public boolean cov(Vector3D<?,?> result, Iterable<? extends Tuple3D<?>> tuples)
Set this matrix with the covariance matrix's elements for the given set of tuples.- Parameters:
result
- the mean of the tuples.tuples
- the input tuples.- Returns:
true
if the cov matrix is computed.
-
isSymmetric
@Pure public boolean isSymmetric()
Replies if the matrix is symmetric.- Returns:
true
if the matrix is symmetric, otherwisefalse
-
eigenVectorsOfSymmetricMatrix
public double[] eigenVectorsOfSymmetricMatrix(Matrix3d eigenVectors)
Compute the eigenvectors of the given symmetric matrix according to the Jacobi Cyclic Method.Given the n x n real symmetric matrix A, the routine Jacobi_Cyclic_Method calculates the eigenvalues and eigenvectors of A by successively sweeping through the matrix A annihilating off-diagonal non-zero elements by a rotation of the row and column in which the non-zero element occurs.
The Jacobi procedure for finding the eigenvalues and eigenvectors of a symmetric matrix A is based on finding a similarity transformation which diagonalizes A. The similarity transformation is given by a product of a sequence of orthogonal (rotation) matrices each of which annihilates an off-diagonal element and its transpose. The rotation effects only the rows and columns containing the off-diagonal element and its transpose, i.e. if a[i][j] is an off-diagonal element, then the orthogonal transformation rotates rows a[i][] and a[j][], and equivalently it rotates columns a[][i] and a[][j], so that a[i][j] = 0 and a[j][i] = 0. The cyclic Jacobi method considers the off-diagonal elements in the following order: (0, 1),(0, 2),...,(0, n-1),(1, 2),...,(n-2, n-1). If the the magnitude of the off-diagonal element is greater than a treshold, then a rotation is performed to annihilate that off-diagnonal element. The process described above is called a sweep. After a sweep has been completed, the threshold is lowered and another sweep is performed with the new threshold. This process is completed until the final sweep is performed with the final threshold. The orthogonal transformation which annihilates the matrix element a[k][m], k != m, is Q = q[i][j], where q[i][j] = 0 if i != j, i, j != k i, j != m and q[i][j] = 1 if i = j, i, j != k, i, j != m, q[k][k] = q[m][m] = cos(phi), q[k][m] = -sin(phi), and q[m][k] = sin(phi), where the angle phi is determined by requiring a[k][m] -> 0. This condition on the angle phi is equivalent to
cot(2 phi) = 0.5 * (a[k][k] - a[m][m]) / a[k][m]
Since tan(2 phi) = 2 tan(phi) / (1.0 - tan(phi)^2),
tan(phi)^2 + 2cot(2 phi) * tan(phi) - 1 = 0.
Solving for tan(phi), choosing the solution with smallest magnitude, tan(phi) = - cot(2 phi) + sgn(cot(2 phi)) sqrt(cot(2phi)^2 + 1). Then cos(phi)^2 = 1 / (1 + tan(phi)^2) and sin(phi)^2 = 1 - cos(phi)^2. Finally by taking the sqrts and assigning the sign to the sin the same as that of the tan, the orthogonal transformation Q is determined. Let A" be the matrix obtained from the matrix A by applying the similarity transformation Q, since Q is orthogonal, A" = Q'AQ, where Q' is the transpose of Q (which is the same as the inverse of Q). Then a"[i][j] = Q'[i][p] a[p][q] Q[q][j] = Q[p][i] a[p][q] Q[q][j], where repeated indices are summed over. If i is not equal to either k or m, then Q[i][j] is the Kronecker delta. So if both i and j are not equal to either k or m, a"[i][j] = a[i][j]. If i = k, j = k,
a"[k][k] = a[k][k]*cos(phi)^2 + a[k][m]*sin(2 phi) + a[m][m]*sin(phi)^2
If i = k, j = m,
a"[k][m] = a"[m][k] = 0 = a[k][m]*cos(2 phi) + 0.5 * (a[m][m] - a[k][k])*sin(2 phi)
If i = k, j != k or m,
a"[k][j] = a"[j][k] = a[k][j] * cos(phi) + a[m][j] * sin(phi)
If i = m, j = k, a"[m][k] = 0
If i = m, j = m,
a"[m][m] = a[m][m]*cos(phi)^2 - a[k][m]*sin(2 phi) + a[k][k]*sin(phi)^2
If i= m, j != k or m,
a"[m][j] = a"[j][m] = a[m][j] * cos(phi) - a[k][j] * sin(phi)If X is the matrix of normalized eigenvectors stored so that the ith column corresponds to the ith eigenvalue, then AX = X Lamda, where Lambda is the diagonal matrix with the ith eigenvalue stored at Lambda[i][i], i.e. X'AX = Lambda and X is orthogonal, the eigenvectors are normalized and orthogonal. So, X = Q1 Q2 ... Qs, where Qi is the ith orthogonal matrix, i.e. X can be recursively approximated by the recursion relation X" = X Q, where Q is the orthogonal matrix and the initial estimate for X is the identity matrix.
If j = k, then x"[i][k] = x[i][k] * cos(phi) + x[i][m] * sin(phi),
if j = m, then x"[i][m] = x[i][m] * cos(phi) - x[i][k] * sin(phi), and
if j != k and j != m, then x"[i][j] = x[i][j].- Parameters:
eigenVectors
- are the matrix of vectors to fill. Eigen vectors are the columns of the matrix.- Returns:
- the eigenvalues which are corresponding to the
eigenVectors
columns. - See Also:
- "Mathematics for 3D Game Programming and Computer Graphics, 2nd edition; pp.437."
-
isIdentity
@Pure public boolean isIdentity()
Replies if the matrix is identity.This function uses the equal-to-zero test with the error
Math.ulp(double)
.- Returns:
true
if the matrix is identity;false
otherwise.- See Also:
MathUtil.isEpsilonZero(double)
,MathUtil.isEpsilonEqual(double, double)
-
operator_add
public void operator_add(Matrix3d matrix)
Add the given matrix to this matrix:this += matrix
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
matrix
- the matrix.- See Also:
add(Matrix3d)
-
operator_add
public void operator_add(double scalar)
Add the given scalar to this matrix:this += scalar
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
scalar
- the scalar.- See Also:
add(double)
-
operator_remove
public void operator_remove(Matrix3d matrix)
Substract the given matrix to this matrix:this -= matrix
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
matrix
- the matrix.- See Also:
sub(Matrix3d)
-
operator_remove
public void operator_remove(double scalar)
Substract the given scalar to this matrix:this -= scalar
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
scalar
- the scalar.- See Also:
add(double)
-
operator_plus
@Pure public Matrix3d operator_plus(Matrix3d matrix)
Replies the addition of the given matrix to this matrix:this + matrix
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
matrix
- the matrix.- Returns:
- the sum of the matrices.
- See Also:
add(Matrix3d)
-
operator_plus
@Pure public Matrix3d operator_plus(double scalar)
Replies the addition of the given scalar to this matrix:this + scalar
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
The operation
scalar + this
is supported byMatrixExtensions.operator_plus(double, Matrix3d)
.- Parameters:
scalar
- the scalar.- Returns:
- the sum of the matrix and the scalar.
- See Also:
add(double)
,MatrixExtensions.operator_plus(double, Matrix3d)
-
operator_minus
@Pure public Matrix3d operator_minus(Matrix3d matrix)
Replies the substraction of the given matrix to this matrix:this - matrix
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
matrix
- the matrix.- Returns:
- the result of the substraction.
- See Also:
sub(Matrix3d)
-
operator_minus
@Pure public Matrix3d operator_minus(double scalar)
Replies the substraction of the given scalar to this matrix:this - scalar
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
The operation
scalar - this
is supported byMatrixExtensions.operator_minus(double, Matrix3d)
.- Parameters:
scalar
- the scalar.- Returns:
- the result of the substraction.
- See Also:
add(double)
,MatrixExtensions.operator_minus(double, Matrix3d)
-
operator_minus
@Pure public Matrix3d operator_minus()
Replies the negation of this matrix:-this
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Returns:
- the negation of this matrix.
- See Also:
negate()
-
operator_multiply
@Pure public Matrix3d operator_multiply(Matrix3d matrix)
Replies the multiplication of the given matrix and this matrix:this * matrix
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
matrix
- the matrix.- Returns:
- the multiplication of the matrices.
- See Also:
mul(Matrix3d)
-
operator_multiply
@Pure public Matrix3d operator_multiply(double scalar)
Replies the multiplication of the given scalar and this matrix:this * scalar
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
The operation
scalar * this
is supported byMatrixExtensions.operator_multiply(double, Matrix2d)
.- Parameters:
scalar
- the scalar.- Returns:
- the multiplication of the scalar and the matrix.
- See Also:
mul(Matrix3d)
,MatrixExtensions.operator_multiply(double, Matrix3d)
-
operator_divide
@Pure public Matrix3d operator_divide(double scalar)
Replies the division of this matrix by the given scalar:this / scalar
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
The operation
scalar / this
is supported byMatrixExtensions.operator_divide(double, Matrix2d)
.- Parameters:
scalar
- the scalar.- Returns:
- the division of the matrix by the scalar.
- See Also:
mul(double)
,MatrixExtensions.operator_divide(double, Matrix3d)
-
operator_plusPlus
public void operator_plusPlus()
Increment this matrix:this++
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- See Also:
add(double)
-
operator_moinsMoins
public void operator_moinsMoins()
Increment this matrix:this--
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- See Also:
add(double)
-
operator_not
public Matrix3d operator_not()
Replies the transposition of this matrix:!this
.This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Returns:
- the transpose
- See Also:
add(double)
-
$plus
@Pure public Matrix3d $plus(Matrix3d matrix)
Replies the addition of the given matrix to this matrix:this + matrix
.This function is an implementation of the operator for the Scala Language.
- Parameters:
matrix
- the matrix.- Returns:
- the sum of the matrices.
- See Also:
add(Matrix3d)
-
$plus
@Pure public Matrix3d $plus(double scalar)
Replies the addition of the given scalar to this matrix:this + scalar
.This function is an implementation of the operator for the Scala Language.
The operation
scalar + this
is supported byMatrixExtensions.$plus(double, Matrix3d)
.- Parameters:
scalar
- the scalar.- Returns:
- the sum of the matrix and the scalar.
- See Also:
add(double)
,MatrixExtensions.$plus(double, Matrix3d)
-
$minus
@Pure public Matrix3d $minus(Matrix3d matrix)
Replies the substraction of the given matrix to this matrix:this - matrix
.This function is an implementation of the operator for the Scala Language.
- Parameters:
matrix
- the matrix.- Returns:
- the result of the substraction.
- See Also:
sub(Matrix3d)
-
$minus
@Pure public Matrix3d $minus(double scalar)
Replies the substraction of the given scalar to this matrix:this - scalar
.This function is an implementation of the operator for the Scala Language.
The operation
scalar - this
is supported byMatrixExtensions.$minus(double, Matrix3d)
.- Parameters:
scalar
- the scalar.- Returns:
- the result of the substraction.
- See Also:
add(double)
,MatrixExtensions.$minus(double, Matrix3d)
-
$minus
@Pure public Matrix3d $minus()
Replies the negation of this matrix:-this
.This function is an implementation of the operator for the Scala Language.
- Returns:
- the negation of this matrix.
- See Also:
negate()
-
$times
@Pure public Matrix3d $times(Matrix3d matrix)
Replies the multiplication of the given matrix and this matrix:this * matrix
.This function is an implementation of the operator for the Scala Language.
- Parameters:
matrix
- the matrix.- Returns:
- the multiplication of the matrices.
- See Also:
mul(Matrix3d)
-
$times
@Pure public Matrix3d $times(double scalar)
Replies the multiplication of the given scalar and this matrix:this * scalar
.This function is an implementation of the operator for the Scala Language.
The operation
scalar * this
is supported byMatrixExtensions.$times(double, Matrix2d)
.- Parameters:
scalar
- the scalar.- Returns:
- the multiplication of the scalar and the matrix.
- See Also:
mul(Matrix3d)
,MatrixExtensions.$times(double, Matrix3d)
-
$div
@Pure public Matrix3d $div(double scalar)
Replies the division of this matrix by the given scalar:this / scalar
.This function is an implementation of the operator for the Scala Language.
The operation
scalar / this
is supported byMatrixExtensions.$div(double, Matrix2d)
.- Parameters:
scalar
- the scalar.- Returns:
- the division of the matrix by the scalar.
- See Also:
mul(double)
,MatrixExtensions.$div(double, Matrix3d)
-
$bang
public Matrix3d $bang()
Replies the transposition of this matrix:!this
.This function is an implementation of the operator for the Scala Language.
- Returns:
- the transpose
- See Also:
add(double)
-
-