Class M4
java.lang.Object
javajs.util.M34
javajs.util.M4
- Direct Known Subclasses:
SymmetryOperation
A single precision floating point 4 by 4 matrix.
- Author:
- Kenji hiranabe additions by Bob Hanson hansonr@stolaf.edu 9/30/2012 for unique constructor and method names for the optimization of compiled JavaScript using Java2Script
-
Field Summary
FieldsModifier and TypeFieldDescriptionfloatThe fourth element of the first row.floatThe fourth element of the second row.floatThe fourth element of the third row.floatThe first element of the fourth row.floatThe second element of the fourth row.floatThe third element of the fourth row.floatThe fourth element of the fourth row. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd to translationfloatComputes the determinant of this matrix.booleanReturns true if the Object o is of type Matrix4f and all of the data members of t1 are equal to the corresponding data members in this Matrix4f.voidgetColumn(int column, float[] v) Copies the matrix values in the specified column into the array parameter.floatgetElement(int row, int col) Retrieves the value at the specified row and column of this matrix.voidgetRotationScale(M3 m1) Gets the upper 3x3 values of this matrix and places them into the matrix m1.voidgetRow(int row, float[] v) Copies the matrix values in the specified row into the array parameter.voidgetTranslation(T3 trans) Retrieves the translational components of this matrix.inthashCode()Returns a hash number based on the data values in this object.invert()Sets the value of this matrix to its inverse.voidSets the value of this matrix to the result of multiplying itself with matrix m1.voidSets the value of this matrix to the result of multiplying the two argument matrices together.static M4newA16(float[] v) Constructs and initializes a Matrix4f from the specified 16 element array.static M4Constructs a new matrix with the same values as the Matrix4f parameter.static M4Constructs and initializes a Matrix4f from the rotation matrix and translation.voidTransforms the point parameter with this Matrix4f and places the result back into point.Transforms the point parameter with this Matrix4f and places the result into pointOut.round(float f) voidscale(float scalar) Multiplies each element of this matrix by a scalar.voidsetA(float[] m) Sets the values in this Matrix4f 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.).setAsXYRotation(float angle) Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.setAsXZRotation(float angle) Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.setAsYZRotation(float angle) Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.voidsetColumn4(int column, float x, float y, float z, float w) Sets the specified column of this matrix4f to the four values provided.voidsetColumnA(int column, float[] v) Sets the specified column of this matrix4f to the four values provided.voidsetElement(int row, int col, float v) Sets the specified element of this matrix4f to the value provided.voidSets this Matrix4f to identity.Sets the value of this matrix to a copy of the passed matrix m1.voidInitializes a Matrix4f from the rotation matrix and translation.voidsetRotationScale(M3 m1) Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.voidsetRowA(int row, float[] v) Sets the specified row of this matrix4f to the four values provided.voidSets the rotational component (upper 3x3) of this matrix to a rotation given by an axis anglevoidSets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are initialized as if this were an identity matrix (ie, affine matrix with no translational component).voidsetTranslation(T3 trans) Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.voidsetZero()Sets this matrix to all zeros.voidSets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).toString()Returns a string that contains the values of this Matrix4f.voidTransform the vector vec using this Matrix4f and place the result back into vec.voidtransform2(T4 vec, T4 vecOut) Transform the vector vec using this Matrix4f and place the result into vecOut.voidSets the value of this matrix to its transpose.
-
Field Details
-
m03
public float m03The fourth element of the first row. -
m13
public float m13The fourth element of the second row. -
m23
public float m23The fourth element of the third row. -
m30
public float m30The first element of the fourth row. -
m31
public float m31The second element of the fourth row. -
m32
public float m32The third element of the fourth row. -
m33
public float m33The fourth element of the fourth row.
-
-
Constructor Details
-
M4
public M4()all zeros
-
-
Method Details
-
newA16
Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.- Parameters:
v- the array of length 16 containing in order- Returns:
- m
-
newM4
-
newMV
-
setZero
public void setZero()Sets this matrix to all zeros. -
setIdentity
public void setIdentity()Sets this Matrix4f to identity. -
setM4
-
setMV
-
setToM3
Sets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are initialized as if this were an identity matrix (ie, affine matrix with no translational component).- Parameters:
m1- the 3x3 matrix
-
setToAA
Sets the rotational component (upper 3x3) of this matrix to a rotation given by an axis angle- Parameters:
a- the axis and angle to be converted
-
setA
public void setA(float[] m) Sets the values in this Matrix4f 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.).- Parameters:
m-
-
setTranslation
Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.- Parameters:
trans- the translational component
-
setElement
public void setElement(int row, int col, float v) Sets the specified element of this matrix4f to the value provided.- Parameters:
row- the row number to be modified (zero indexed)col- the column number to be modified (zero indexed)v- the new value
-
getElement
public float getElement(int row, int col) Retrieves the value at the specified row and column of this matrix.- Parameters:
row- the row number to be retrieved (zero indexed)col- the column number to be retrieved (zero indexed)- Returns:
- the value at the indexed element
-
getTranslation
Retrieves the translational components of this matrix.- Parameters:
trans- the vector that will receive the translational component
-
getRotationScale
Gets the upper 3x3 values of this matrix and places them into the matrix m1.- Parameters:
m1- The matrix that will hold the values
-
setRotationScale
Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.- Parameters:
m1- The matrix that will be the new upper 3x3
-
setRowA
public void setRowA(int row, float[] v) Sets the specified row of this matrix4f to the four values provided.- Parameters:
row- the row number to be modified (zero indexed)v- the replacement row
-
getRow
-
setColumn4
public void setColumn4(int column, float x, float y, float z, float w) Sets the specified column of this matrix4f to the four values provided.- Parameters:
column- the column number to be modified (zero indexed)x- the first row elementy- the second row elementz- the third row elementw- the fourth row element
-
setColumnA
public void setColumnA(int column, float[] v) Sets the specified column of this matrix4f to the four values provided.- Parameters:
column- the column number to be modified (zero indexed)v- the replacement column
-
getColumn
public void getColumn(int column, float[] v) Copies the matrix values in the specified column into the array parameter.- Parameters:
column- the matrix columnv- The array into which the matrix column values will be copied
-
sub
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).- Parameters:
m1- the other matrix
-
add
-
transpose
public void transpose()Sets the value of this matrix to its transpose. -
invert
-
determinant4
public float determinant4()Computes the determinant of this matrix.- Returns:
- the determinant of the matrix
-
scale
public void scale(float scalar) Multiplies each element of this matrix by a scalar.- Parameters:
scalar- The scalar multiplier.
-
mul
Sets the value of this matrix to the result of multiplying itself with matrix m1.- Parameters:
m1- the other matrix
-
mul2
-
transform
Transform the vector vec using this Matrix4f and place the result back into vec.- Parameters:
vec- the single precision vector to be transformed
-
transform2
-
rotTrans
Transforms the point parameter with this Matrix4f and places the result back into point. The fourth element of the point input parameter is assumed to be one.- Parameters:
point- the input point to be transformed.
-
rotTrans2
Transforms the point parameter with this Matrix4f and places the result into pointOut. The fourth element of the point input parameter is assumed to be one. point may be pointOut- Parameters:
point- the input point to be transformed.pointOut- the transformed point- Returns:
- pointOut
-
setAsXYRotation
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.- Parameters:
angle- the angle to rotate about the W axis in radians- Returns:
- this
-
setAsYZRotation
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.- Parameters:
angle- the angle to rotate about the W axis in radians- Returns:
- this
-
setAsXZRotation
Sets the value of this matrix to a rotation matrix about the w axis by the passed angle.- Parameters:
angle- the angle to rotate about the W axis in radians- Returns:
- this
-
equals
-
hashCode
public int hashCode()Returns a hash number based on the data values in this object. Two different Matrix4f objects with identical data values (ie, returns true for equals(Matrix4f) ) will return the same hash number. Two objects with different data members may return the same hash value, although this is not likely. -
toString
-
round
-