Package javajs.util
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 TypeFieldDescriptionfloat
The fourth element of the first row.float
The fourth element of the second row.float
The fourth element of the third row.float
The first element of the fourth row.float
The second element of the fourth row.float
The third element of the fourth row.float
The fourth element of the fourth row. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add to translationfloat
Computes the determinant of this matrix.boolean
Returns 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.void
getColumn
(int column, float[] v) Copies the matrix values in the specified column into the array parameter.float
getElement
(int row, int col) Retrieves the value at the specified row and column of this matrix.void
getRotationScale
(M3 m1) Gets the upper 3x3 values of this matrix and places them into the matrix m1.void
getRow
(int row, float[] v) Copies the matrix values in the specified row into the array parameter.void
getTranslation
(T3 trans) Retrieves the translational components of this matrix.int
hashCode()
Returns a hash number based on the data values in this object.invert()
Sets the value of this matrix to its inverse.void
Sets the value of this matrix to the result of multiplying itself with matrix m1.void
Sets the value of this matrix to the result of multiplying the two argument matrices together.static M4
newA16
(float[] v) Constructs and initializes a Matrix4f from the specified 16 element array.static M4
Constructs a new matrix with the same values as the Matrix4f parameter.static M4
Constructs and initializes a Matrix4f from the rotation matrix and translation.void
Transforms 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) void
scale
(float scalar) Multiplies each element of this matrix by a scalar.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.).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.void
setColumn4
(int column, float x, float y, float z, float w) Sets the specified column of this matrix4f to the four values provided.void
setColumnA
(int column, float[] v) Sets the specified column of this matrix4f to the four values provided.void
setElement
(int row, int col, float v) Sets the specified element of this matrix4f to the value provided.void
Sets this Matrix4f to identity.Sets the value of this matrix to a copy of the passed matrix m1.void
Initializes a Matrix4f from the rotation matrix and translation.void
setRotationScale
(M3 m1) Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.void
setRowA
(int row, float[] v) Sets the specified row of this matrix4f to the four values provided.void
Sets the rotational component (upper 3x3) of this matrix to a rotation given by an axis anglevoid
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).void
setTranslation
(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.void
setZero()
Sets this matrix to all zeros.void
Sets 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.void
Transform the vector vec using this Matrix4f and place the result back into vec.void
transform2
(T4 vec, T4 vecOut) Transform the vector vec using this Matrix4f and place the result into vecOut.void
Sets 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
Constructs a new matrix with the same values as the Matrix4f parameter.- Parameters:
m1
- the source matrix- Returns:
- m
-
newMV
Constructs and initializes a Matrix4f from the rotation matrix and translation.- Parameters:
m1
- The rotation matrix representing the rotational componentst
- The translational components of the matrix- Returns:
- m
-
setZero
public void setZero()Sets this matrix to all zeros. -
setIdentity
public void setIdentity()Sets this Matrix4f to identity. -
setM4
Sets the value of this matrix to a copy of the passed matrix m1.- Parameters:
m1
- the matrix to be copied- Returns:
- this
-
setMV
Initializes a Matrix4f from the rotation matrix and translation.- Parameters:
m1
- The rotation matrix representing the rotational componentst
- The translational components of the matrix
-
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
public void getRow(int row, float[] v) Copies the matrix values in the specified row into the array parameter. -
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
add to translation- Parameters:
pt
-
-
transpose
public void transpose()Sets the value of this matrix to its transpose. -
invert
Sets the value of this matrix to its inverse.- Returns:
- this
-
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
Sets the value of this matrix to the result of multiplying the two argument matrices together.- Parameters:
m1
- the first matrixm2
- the second matrix
-
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
Transform the vector vec using this Matrix4f and place the result into vecOut.- Parameters:
vec
- the single precision vector to be transformedvecOut
- the vector into which the transformed values are placed
-
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
Returns 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. -
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
Returns a string that contains the values of this Matrix4f. -
round
-