javax.vecmath

Class Matrix3d

public class Matrix3d extends Object implements Serializable

A double precision floating point 3 by 3 matrix. Primarily to support rotations
Field Summary
doublem00
The first element of the first row.
doublem01
The second element of the first row.
doublem02
third element of the first row.
doublem10
The first element of the second row.
doublem11
The second element of the second row.
doublem12
The third element of the second row.
doublem20
The first element of the third row.
doublem21
The second element of the third row.
doublem22
The third element of the third row.
Constructor Summary
Matrix3d(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Constructs and initializes a Matrix3d from the specified nine values.
Matrix3d(double[] v)
Constructs and initializes a Matrix3d from the specified 9 element array. this.m00 =v[0], this.m01=v[1], etc.
Matrix3d(Matrix3d m1)
Constructs a new matrix with the same values as the Matrix3d parameter.
Matrix3d(Matrix3f m1)
Constructs a new matrix with the same values as the Matrix3f parameter.
Matrix3d()
Constructs and initializes a Matrix3d to all zeros.
Method Summary
voidadd(double scalar)
Adds a scalar to each component of this matrix.
voidadd(double scalar, Matrix3d m1)
Adds a scalar to each component of the matrix m1 and places the result into this.
voidadd(Matrix3d m1, Matrix3d m2)
Sets the value of this matrix to the matrix sum of matrices m1 and m2.
voidadd(Matrix3d m1)
Sets the value of this matrix to sum of itself and matrix m1.
doubledeterminant()
Computes the determinant of this matrix.
booleanepsilonEquals(Matrix3d m1, 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.
booleanequals(Matrix3d m1)
Returns true if all of the data members of Matrix3d m1 are equal to the corresponding data members in this Matrix3d.
booleanequals(Object o1)
Returns true if the Object o1 is of type Matrix3d and all of the data members of t1 are equal to the corresponding data members in this Matrix3d.
voidgetColumn(int column, Vector3d v)
Copies the matrix values in the specified column into the vector parameter.
voidgetColumn(int column, double[] v)
Copies the matrix values in the specified column into the array parameter.
doublegetElement(int row, int column)
Retrieves the value at the specified row and column of this matrix.
voidgetRow(int row, double[] v)
Copies the matrix values in the specified row into the array parameter.
voidgetRow(int row, Vector3d v)
Copies the matrix values in the specified row into the vector parameter.
doublegetScale()
Performs an SVD normalization of this matrix to calculate and return the uniform scale factor.
inthashCode()
Returns a hash number based on the data values in this object.
voidinvert(Matrix3d m1)
Sets the value of this matrix to the matrix inverse of the passed matrix m1.
voidinvert()
Sets the value of this matrix to its inverse.
voidmul(double scalar)
Multiplies each element of this matrix by a scalar.
voidmul(double scalar, Matrix3d m1)
Multiplies each element of matrix m1 by a scalar and places the result into this.
voidmul(Matrix3d m1)
Sets the value of this matrix to the result of multiplying itself with matrix m1.
voidmul(Matrix3d m1, Matrix3d m2)
Sets the value of this matrix to the result of multiplying the two argument matrices together.
voidmulNormalize(Matrix3d m1)
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).
voidmulNormalize(Matrix3d m1, Matrix3d m2)
Multiplies matrix m1 by matrix m2, does an SVD normalization of the result, and places the result into this matrix this = SVDnorm(m1*m2).
voidmulTransposeBoth(Matrix3d m1, Matrix3d m2)
Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this.
voidmulTransposeLeft(Matrix3d m1, Matrix3d m2)
Multiplies the transpose of matrix m1 times matrix m2, and places the result into this.
voidmulTransposeRight(Matrix3d m1, Matrix3d m2)
Multiplies matrix m1 times the transpose of matrix m2, and places the result into this.
voidnegate()
Negates the value of this matrix: this = -this.
voidnegate(Matrix3d m1)
Sets the value of this matrix equal to the negation of of the Matrix3d parameter.
voidnormalize()
Performs singular value decomposition normalization of this matrix.
voidnormalize(Matrix3d m1)
Perform singular value decomposition normalization of matrix m1 and place the normalized values into this.
voidnormalizeCP()
Perform cross product normalization of this matrix.
voidnormalizeCP(Matrix3d m1)
Perform cross product normalization of matrix m1 and place the normalized values into this.
voidrotX(double angle)
Sets the value of this matrix to a rotation matrix about the x axis by the passed angle.
voidrotY(double angle)
Sets the value of this matrix to a rotation matrix about the y axis by the passed angle.
voidrotZ(double angle)
Sets the value of this matrix to a rotation matrix about the z axis by the passed angle.
voidset(Quat4d q1)
Sets the value of this matrix to the matrix conversion of the (double precision) quaternion argument.
voidset(AxisAngle4d a1)
Sets the value of this matrix to the matrix conversion of the double precision axis and angle argument.
voidset(Quat4f q1)
Sets the value of this matrix to the matrix conversion of the single precision quaternion argument.
voidset(AxisAngle4f a1)
Sets the value of this matrix to the matrix conversion of the single precision axis and angle argument.
voidset(Matrix3d m1)
Sets the value of this matrix to the value of the Matrix3d argument.
voidset(Matrix3f m1)
Sets the value of this matrix to the double value of the Matrix3f argument.
voidset(double[] m)
Sets the values in this Matrix3d equal to the row-major array parameter (ie, the first four elements of the array will be copied into the first row of this matrix, etc.).
voidset(double scale)
Sets the value of this matrix to a scale matrix with the passed scale amount.
voidsetColumn(int column, double x, double y, double z)
Sets the specified column of this matrix3d to the three values provided.
voidsetColumn(int column, Vector3d v)
Sets the specified column of this matrix3d to the vector provided.
voidsetColumn(int column, double[] v)
Sets the specified column of this matrix3d to the four values provided.
voidsetElement(int row, int column, double value)
Sets the specified element of this matrix3d to the value provided.
voidsetIdentity()
Sets this Matrix3d to identity.
voidsetRow(int row, double x, double y, double z)
Sets the specified row of this matrix3d to the three values provided.
voidsetRow(int row, Vector3d v)
Sets the specified row of this matrix3d to the Vector provided.
voidsetRow(int row, double[] v)
Sets the specified row of this matrix3d to the four values provided.
voidsetScale(double scale)
Sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) from the rotational component and multiplying by the new scale.
voidsetZero()
Sets this matrix to all zeros.
voidsub(Matrix3d m1, Matrix3d m2)
Sets the value of this matrix to the matrix difference of matrices m1 and m2.
voidsub(Matrix3d m1)
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).
StringtoString()
Returns a string that contains the values of this Matrix3d.
voidtransform(Tuple3d t)
Transform the vector vec using this Matrix3d and place the result back into vec.
voidtransform(Tuple3d t, Tuple3d result)
Transform the vector vec using this Matrix3d and place the result into vecOut.
voidtranspose()
Sets the value of this matrix to its transpose.
voidtranspose(Matrix3d m1)
Sets the value of this matrix to the transpose of the argument matrix

Field Detail

m00

public double m00
The first element of the first row.

m01

public double m01
The second element of the first row.

m02

public double m02
third element of the first row.

m10

public double m10
The first element of the second row.

m11

public double m11
The second element of the second row.

m12

public double m12
The third element of the second row.

m20

public double m20
The first element of the third row.

m21

public double m21
The second element of the third row.

m22

public double m22
The third element of the third row.

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 Matrix3d from the specified nine values.

Parameters: m00 the [0][0] element m01 the [0][1] element m02 the [0][2] element m10 the [1][0] element m11 the [1][1] element m12 the [1][2] element m20 the [2][0] element m21 the [2][1] element m22 the [2][2] element

Matrix3d

public Matrix3d(double[] v)
Constructs and initializes a Matrix3d from the specified 9 element array. this.m00 =v[0], this.m01=v[1], etc.

Parameters: v the array of length 9 containing in order

Matrix3d

public Matrix3d(Matrix3d m1)
Constructs a new matrix with the same values as the Matrix3d parameter.

Parameters: m1 The source matrix.

Matrix3d

public Matrix3d(Matrix3f m1)
Constructs a new matrix with the same values as the Matrix3f parameter.

Parameters: m1 The source matrix.

Matrix3d

public Matrix3d()
Constructs and initializes a Matrix3d to all zeros.

Method Detail

add

public final void add(double scalar)
Adds a scalar to each component of this matrix.

Parameters: scalar The scalar adder.

add

public final void add(double scalar, Matrix3d m1)
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 adder.

UNKNOWN: m1 The original matrix values.

add

public final void add(Matrix3d m1, Matrix3d m2)
Sets the value of this matrix to the matrix sum of matrices m1 and m2.

Parameters: m1 the first matrix m2 the second matrix

add

public final void add(Matrix3d m1)
Sets the value of this matrix to sum of itself and matrix m1.

Parameters: m1 the other matrix

determinant

public final double determinant()
Computes the determinant of this matrix.

Returns: the determinant of the matrix

epsilonEquals

public boolean epsilonEquals(Matrix3d m1, 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,3 ; j=0,1,2,3 ; abs(this.m(i,j) - m1.m(i,j)]

Parameters: m1 The matrix to be compared to this matrix epsilon the threshold value

equals

public boolean equals(Matrix3d m1)
Returns true if all of the data members of Matrix3d m1 are equal to the corresponding data members in this Matrix3d.

Parameters: m1 The matrix with which the comparison is made.

Returns: true or false

equals

public boolean equals(Object o1)
Returns true if the Object o1 is of type Matrix3d and all of the data members of t1 are equal to the corresponding data members in this Matrix3d.

Parameters: o1 the object with which the comparison is made.

getColumn

public final void getColumn(int column, Vector3d v)
Copies the matrix values in the specified column into the vector parameter.

Parameters: column the matrix column v The vector into which the matrix row values will be copied

getColumn

public final void getColumn(int column, double[] v)
Copies the matrix values in the specified column into the array parameter.

Parameters: column the matrix column v The array into which the matrix row values will be copied

getElement

public final double getElement(int row, int column)
Retrieves the value at the specified row and column of this 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 final void getRow(int row, double[] v)
Copies the matrix values in the specified row into the array parameter.

Parameters: row the matrix row v The array into which the matrix row values will be copied

getRow

public final void getRow(int row, Vector3d v)
Copies the matrix values in the specified row into the vector parameter.

Parameters: row the matrix row v The vector into which the matrix row values will be copied

getScale

public final double getScale()
Performs an SVD normalization of this matrix to calculate and return the uniform scale factor. This matrix is not modified.

Returns: the scale factor of this matrix

hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Matrix3d objects with identical data values (ie, returns true for equals(Matrix3d) ) will return the same hash number. Two objects with different data members may return the same hash value, although this is not likely.

Returns: the integer hash value

invert

public final void invert(Matrix3d m1)
Sets the value of this matrix to the matrix inverse of the passed matrix m1.

Parameters: m1 the matrix to be inverted

invert

public final void invert()
Sets the value of this matrix to its inverse.

mul

public final void mul(double scalar)
Multiplies each element of this matrix by a scalar.

Parameters: scalar The scalar multiplier.

mul

public final void mul(double scalar, Matrix3d m1)
Multiplies each element of matrix m1 by a scalar and places the result into this. Matrix m1 is not modified.

Parameters: scalar The scalar multiplier. m1 The original matrix.

mul

public final void mul(Matrix3d m1)
Sets the value of this matrix to the result of multiplying itself with matrix m1.

Parameters: m1 the other matrix

mul

public final void mul(Matrix3d m1, Matrix3d m2)
Sets the value of this matrix to the result of multiplying the two argument matrices together.

Parameters: m1 the first matrix m2 the second matrix

mulNormalize

public final void mulNormalize(Matrix3d m1)
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: m1 the matrix on the right hand side of the multiplication

mulNormalize

public final void mulNormalize(Matrix3d m1, Matrix3d m2)
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: m1 the matrix on the left hand side of the multiplication m2 the matrix on the right hand side of the multiplication

mulTransposeBoth

public final void mulTransposeBoth(Matrix3d m1, Matrix3d m2)
Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this.

Parameters: m1 The matrix on the left hand side of the multiplication m2 The matrix on the right hand side of the multiplication

mulTransposeLeft

public final void mulTransposeLeft(Matrix3d m1, Matrix3d m2)
Multiplies the transpose of matrix m1 times matrix m2, and places the result into this.

Parameters: m1 The matrix on the left hand side of the multiplication m2 The matrix on the right hand side of the multiplication

mulTransposeRight

public final void mulTransposeRight(Matrix3d m1, Matrix3d m2)
Multiplies matrix m1 times the transpose of matrix m2, and places the result into this.

Parameters: m1 The matrix on the left hand side of the multiplication m2 The matrix on the right hand side of the multiplication

negate

public final void negate()
Negates the value of this matrix: this = -this.

negate

public final void negate(Matrix3d m1)
Sets the value of this matrix equal to the negation of of the Matrix3d parameter.

Parameters: m1 The source matrix

normalize

public final void normalize()
Performs singular value decomposition normalization of this matrix.

normalize

public final void normalize(Matrix3d m1)
Perform singular value decomposition normalization of matrix m1 and place the normalized values into this.

Parameters: m1 Provides the matrix values to be normalized

normalizeCP

public final void normalizeCP()
Perform cross product normalization of this matrix.

normalizeCP

public final void normalizeCP(Matrix3d m1)
Perform cross product normalization of matrix m1 and place the normalized values into this.

Parameters: m1 Provides the matrix values to be normalized

rotX

public final void rotX(double angle)
Sets the value of this matrix to a rotation matrix about the x axis by the passed angle.

Parameters: angle the angle to rotate about the X axis in radians

rotY

public final void rotY(double angle)
Sets the value of this matrix to a rotation matrix about the y axis by the passed angle.

Parameters: angle the angle to rotate about the Y axis in radians

rotZ

public final void rotZ(double angle)
Sets the value of this matrix to a rotation matrix about the z axis by the passed angle.

Parameters: angle the angle to rotate about the Z axis in radians

set

public final void set(Quat4d q1)
Sets the value of this matrix to the matrix conversion of the (double precision) quaternion argument.

Parameters: q1 the quaternion to be converted

set

public final void set(AxisAngle4d a1)
Sets the value of this matrix to the matrix conversion of the double precision axis and angle argument.

Parameters: a1 the axis and angle to be converted

set

public final void set(Quat4f q1)
Sets the value of this matrix to the matrix conversion of the single precision quaternion argument.

Parameters: q1 the quaternion to be converted

set

public final void set(AxisAngle4f a1)
Sets the value of this matrix to the matrix conversion of the single precision axis and angle argument.

Parameters: a1 the axis and angle to be converted

set

public final void set(Matrix3d m1)
Sets the value of this matrix to the value of the Matrix3d argument.

set

public final void set(Matrix3f m1)
Sets the value of this matrix to the double value of the Matrix3f argument.

Parameters: m1 the matrix3f to be converted to double

set

public final void set(double[] m)
Sets the values in this Matrix3d equal to the row-major array parameter (ie, the first four elements of the array will be copied into the first row of this matrix, etc.).

set

public final void set(double scale)
Sets the value of this matrix to a scale matrix with the passed scale amount.

Parameters: scale the scale factor for the matrix

setColumn

public final void setColumn(int column, double x, double y, double z)
Sets the specified column of this matrix3d to the three values provided.

Parameters: column the column number to be modified (zero indexed) x the first row element y the second row element z the third row element

setColumn

public final void setColumn(int column, Vector3d v)
Sets the specified column of this matrix3d to the vector provided.

Parameters: column the column number to be modified (zero indexed) v the replacement column

setColumn

public final void setColumn(int column, double[] v)
Sets the specified column of this matrix3d to the four values provided.

Parameters: column the column number to be modified (zero indexed) v the replacement column

setElement

public final void setElement(int row, int column, double value)
Sets the specified element of this matrix3d 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

setIdentity

public final void setIdentity()
Sets this Matrix3d to identity.

setRow

public final void setRow(int row, double x, double y, double z)
Sets the specified row of this matrix3d to the three values provided.

Parameters: row the row number to be modified (zero indexed) x the first column element y the second column element z the third column element

setRow

public final void setRow(int row, Vector3d v)
Sets the specified row of this matrix3d to the Vector provided.

Parameters: row the row number to be modified (zero indexed) v the replacement row

setRow

public final void setRow(int row, double[] v)
Sets the specified row of this matrix3d to the four values provided.

Parameters: row the row number to be modified (zero indexed) v the replacement row

setScale

public final void setScale(double scale)
Sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) from the rotational component and multiplying by the new scale.

Parameters: scale the new scale amount

setZero

public final void setZero()
Sets this matrix to all zeros.

sub

public final void sub(Matrix3d m1, Matrix3d m2)
Sets the value of this matrix to the matrix difference of matrices m1 and m2.

Parameters: m1 the first matrix m2 the second matrix

sub

public final void sub(Matrix3d m1)
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).

Parameters: m1 the other matrix

toString

public String toString()
Returns a string that contains the values of this Matrix3d.

Returns: the String representation

transform

public final void transform(Tuple3d t)
Transform the vector vec using this Matrix3d and place the result back into vec.

Parameters: vec the double precision vector to be transformed

transform

public final void transform(Tuple3d t, Tuple3d result)
Transform the vector vec using this Matrix3d and place the result into vecOut.

Parameters: result the vector into which the transformed values are placed

UNKNOWN: the double precision vector to be transformed

transpose

public final void transpose()
Sets the value of this matrix to its transpose.

transpose

public final void transpose(Matrix3d m1)
Sets the value of this matrix to the transpose of the argument matrix

Parameters: m1 the matrix to be transposed