public class Matrix3D
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
class |
Matrix3D.MatrixInvert
This class is a helper class supporting the Matrix3D class; it is not
intended to be used directly.
|
Constructor and Description |
---|
Matrix3D()
Creates a Matrix3D initialized to the identity matrix
|
Matrix3D(double[] values)
Creates a Matrix3D containing the contents specified by the
given double 'values' array.
|
Matrix3D(double degrees,
Vector3D axis)
Creates a new Matrix3D containing the rotation transformation equivalent
to a rotation of the specified angle (in degrees) about the specified
axis.
|
Matrix3D(float[] values)
Creates a Matrix3D containing the contents specified by the
given float 'values' array.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a deep clone (copy) of this Matrix3D.
|
void |
concatenate(Matrix3D matrix2)
Concatenates a second matrix onto this matrix on the right.
|
double |
elementAt(int row,
int col)
Returns the element stored in this matrix at the specified
location.
|
Vector3D |
getCol(int col)
Returns a new Vector3D containing in its XYZW fields
the values currently stored in the specified column
(0,1,2, or 3) of this matrix.
|
float[] |
getFloatValues()
Returns a 1-dimensional array of floats containing the elements of this Matrix3D extracted
in column order.
|
Vector3D |
getRow(int row)
Returns a Vector3D containing in its XYZW fields
the values currently stored in the specified row
(0,1,2, or 3) of this matrix.
|
double[] |
getValues()
Returns a 1-dimensional array of doubles containing the elements of this Matrix3D extracted
in column order.
|
Matrix3D |
inverse()
Returns a new Matrix3D which is the inverse of this Matrix3D.
|
void |
rotate(double xDegrees,
double yDegrees,
double zDegrees)
Concatenates onto this matrix a rotation about the
X, Y, and Z axes by the specified angles, which are assumed
to be in degrees.
|
void |
rotate(double degrees,
Vector3D axis)
Concatenates onto this matrix a rotation of
degrees
about the specified axis. |
void |
rotateX(double degrees)
Concatenates a rotation about the X axis by amount degrees
onto this matrix.
|
void |
rotateY(double degrees)
Concatenates a rotation about the Y axis by amount degrees
onto this matrix.
|
void |
rotateZ(double degrees)
Concatenates a rotation about the Z axis by amount degrees
onto this matrix.
|
void |
scale(double sx,
double sy,
double sz)
Concatentates a scaling transformation onto this matrix.
|
void |
setCol(int col,
Vector3D vector)
Sets the specified column of this matrix to the
XYZW values of the specified vector.
|
void |
setElementAt(int row,
int col,
double value)
Sets the element stored in this matrix at the specified location
to the specified value.
|
void |
setRow(int row,
Vector3D vector)
Sets the specified row of this matrix to the
XYZW values of the specified vector.
|
void |
setToIdentity()
Initializes this matrix to the identity matrix.
|
void |
setValues(double[] newValues)
Loads the elements of this Matrix3D from a 16-element 1-dimensional array containing
the elements arranged in column order.
|
java.lang.String |
toString()
Returns a printable representation of
the contents of this matrix, formatted
into row and columns via embedded newlines.
|
void |
translate(double tx,
double ty,
double tz)
Concatentates a translation onto this matrix.
|
Matrix3D |
transpose()
Returns a new Matrix3D which is the transpose of this Matrix3D.
|
public Matrix3D()
public Matrix3D(double[] values)
values
- A linear array containing in column-major order the values
to be loaded into the matrix.public Matrix3D(float[] values)
values
- A linear array containing in column-major order the values
to be loaded into the matrix.public Matrix3D(double degrees, Vector3D axis)
degrees
- The angle, given in degrees, specifying the rotation
component of the matrixaxis
- The X,Y,Z components of the axis of rotation for the matrix.public double elementAt(int row, int col)
row
- The row number in the matrixcol
- The column number in the matrixpublic void setElementAt(int row, int col, double value)
row
- the row number in the matrixcol
- the column number in the matrixvalue
- the value to be stored at [row,col] in the matrixpublic Vector3D getRow(int row)
row
- The row in the matrixpublic Vector3D getCol(int col)
col
- The number of the column whose contents are to be returnedVector3D
containing the elements of the specified matrix column.public void setRow(int row, Vector3D vector)
row
- The row number which is to be set in this matrixvector
- A Vector3D
containing the values which are to be used to
set the specified matrix rowpublic void setCol(int col, Vector3D vector)
col
- The column number which is to be set in this matrixvector
- A Vector3D
containing the values which are to be used to
set the specified matrix columnpublic double[] getValues()
public float[] getFloatValues()
public void setValues(double[] newValues)
newValues
- A linear array representing, in column-major order, the values
to be inserted into this matrixpublic void concatenate(Matrix3D matrix2)
matrix2
- The matrix which is to be concatenated onto this matrix
from the rightpublic void scale(double sx, double sy, double sz)
sx
- The scale amount in the X directionsy
- The scale amount in the Y directionsz
- The scale amount in the Z directionpublic void translate(double tx, double ty, double tz)
tx
- The translation amount in the X directionty
- The translation amount in the Y directiontz
- The translation amount in the Z directionpublic void rotate(double degrees, Vector3D axis)
degrees
about the specified axis.degrees
- The angle of rotation in degreesaxis
- The axis of rotation for the specified angle.public void rotate(double xDegrees, double yDegrees, double zDegrees)
xDegrees
- The angle of rotation, in degrees, about the X axisyDegrees
- The angle of rotation, in degrees, about the Y axiszDegrees
- The angle of rotation, in degrees, about the Z axispublic void rotateX(double degrees)
degrees
- The angle of rotation, in degrees, about the X axispublic void rotateY(double degrees)
degrees
- The angle of rotation, in degrees, about the Y axispublic void rotateZ(double degrees)
degrees
- The angle of rotation, in degrees, about the Z axispublic void setToIdentity()
public Matrix3D inverse()
Matrix3D.MatrixInvert
helper class
loaded with the same values as this Matrix3D to create the inverse, then
copies the values from the inverted helper class matrix into a new Matrix3D
which is returned.
Does not alter the contents of this matrix.Matrix3D
containing the inverse transformation of this matrix.public Matrix3D transpose()
Matrix3D
containing the transpose of this matrixpublic java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object