Package gaiasky.util.math
Class Matrix4d
java.lang.Object
gaiasky.util.math.Matrix4d
- All Implemented Interfaces:
Serializable
Encapsulates a column
major 4 by 4 matrix. Like the
Vector3d
class it allows the
chaining of methods by returning a reference to itself. For example:
Matrix4d mat = new Matrix4d().trn(position).mul(camera.combined);
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
XX: Typically the unrotated X component for scaling, also the cosine of the angle when rotated on the Y and/or Z axis.static final int
XY: Typically the negative sine of the angle when rotated on the Z axis.static final int
XZ: Typically the sine of the angle when rotated on the Y axis.static final int
XW: Typically the translation of the X component.static final int
YX: Typically the sine of the angle when rotated on the Z axis.static final int
YY: Typically the unrotated Y component for scaling, also the cosine of the angle when rotated on the X and/or Z axis.static final int
YZ: Typically the negative sine of the angle when rotated on the X axis.static final int
YW: Typically the translation of the Y component.static final int
ZX: Typically the negative sine of the angle when rotated on the Y axis.static final int
ZY: Typical the sine of the angle when rotated on the X axis.static final int
ZZ: Typically the unrotated Z component for scaling, also the cosine of the angle when rotated on the X and/or Y axis.static final int
ZW: Typically the translation of the Z component.static final int
WX: Typically the value zero.static final int
WY: Typically the value zero.static final int
WZ: Typically the value zero.static final int
WW: Typically the value one.static final double[]
final double[]
final double[]
-
Constructor Summary
ConstructorDescriptionMatrix4d()
Constructs an identity matrixMatrix4d
(double[] values) Constructs a matrix from the given double array.Matrix4d
(float[] values) Constructs a matrix from the given matrix.Matrix4d
(Quaterniond quaternion) Constructs a rotation matrix from the givenQuaterniond
.Matrix4d
(Vector3d position, Quaterniond rotation, Vector3d scale) Construct a matrix from the given translation, rotation and scale. -
Method Summary
Modifier and TypeMethodDescriptionaddTranslationTo
(Vector3d position) static Matrix4d
changeOfBasis
(double[] x, double[] y, double[] z) Constructs a change of basis from the canonical basis to the base defined by the given x, y and z vectors.static Matrix4d
changeOfBasis
(Vector3d x, Vector3d y, Vector3d z) Constructs a change of basis from the canonical basis to the base defined by the given x, y and z vectors.cpy()
double
det()
double
det3x3()
void
extract4x3Matrix
(double[] dst) Copies the 4x3 upper-left sub-matrix into double array.getRotation
(Quaterniond rotation) Gets the rotation of this matrix.getRotation
(Quaterniond rotation, boolean normalizeAxes) Gets the rotation of this matrix.double
double
double
double
double
double
double[]
getTranslation
(Vector3d position) float[]
void
getTranslationf
(float[] vec) com.badlogic.gdx.math.Vector3
getTranslationf
(com.badlogic.gdx.math.Vector3 position) double[]
float[]
idt()
Sets the matrix to an identity matrix.inv()
static boolean
inv
(double[] values) Computes the inverse of the given matrix.Linearly interpolates between this matrix and the given matrix mixing by alphastatic void
mul
(double[] mata, double[] matb) Multiplies the matrix mata with matrix matb, storing the result in mata.Postmultiplies this matrix with the given matrix, storing the result in this matrix.Premultiplies this matrix with the given matrix, storing the result in this matrix.static void
prj
(double[] mat, double[] vec) Multiplies the vector with the given matrix, performing a division by w.static void
prj
(double[] mat, double[] vecs, int offset, int numVecs, int stride) Multiplies the vectors with the given matrix, , performing a division by w.com.badlogic.gdx.math.Matrix4
putIn
(com.badlogic.gdx.math.Matrix4 aux) Sets the given matrix to this matrixrotate
(double axisX, double axisY, double axisZ, double degrees) Postmultiplies this matrix with a (counter-clockwise) rotation matrix.rotate
(Quaterniond rotation) Postmultiplies this matrix with a (counter-clockwise) rotation matrix.Postmultiplies this matrix with a (counter-clockwise) rotation matrix.Postmultiplies this matrix by the rotation between two vectors.rotateRad
(double axisX, double axisY, double axisZ, double radians) Postmultiplies this matrix with a (counter-clockwise) rotation matrix.Postmultiplies this matrix with a (counter-clockwise) rotation matrix.scale
(double scaleX, double scaleY, double scaleZ) Postmultiplies this matrix with a scale matrix.scl
(double scale) scl
(double x, double y, double z) set
(double[] values) Sets the matrix to the given matrix as a double array.set
(double quaternionX, double quaternionY, double quaternionZ, double quaternionW) Sets the matrix to a rotation matrix representing the quaternion.set
(double translationX, double translationY, double translationZ, double quaternionX, double quaternionY, double quaternionZ, double quaternionW) Sets the matrix to a rotation matrix representing the translation and quaternion.set
(double translationX, double translationY, double translationZ, double quaternionX, double quaternionY, double quaternionZ, double quaternionW, double scaleX, double scaleY, double scaleZ) Sets the matrix to a rotation matrix representing the translation and quaternion.set
(float[] values) set
(com.badlogic.gdx.math.Matrix3 mat) Sets this matrix to the given 3x3 matrix.set
(com.badlogic.gdx.math.Matrix4 matrix) Sets the matrix to the given matrix.set
(Quaterniond quaternion) Sets the matrix to a rotation matrix representing the quaternion.set
(Vector3d position, Quaterniond orientation) Set this matrix to the specified translation and rotation.set
(Vector3d position, Quaterniond orientation, Vector3d scale) Set this matrix to the specified translation, rotation and scale.Sets the four columns of the matrix which correspond to the x-, y- and z-axis of the vector space this matrix creates as well as the 4th column representing the translation of any point that is multiplied by this matrix.setFromEulerAngles
(double yaw, double pitch, double roll) Sets this matrix to a rotation matrix from the given euler angles.setToLookAt
(Vector3b direction, Vector3b up) setToLookAt
(Vector3b position, Vector3b target, Vector3b up) setToLookAt
(Vector3d direction, Vector3d up) Sets the matrix to a look at matrix with a direction and an up vector.setToLookAt
(Vector3d position, Vector3d target, Vector3d up) Sets this matrix to a look at matrix with the given position, target and up vector.setToOrtho
(double left, double right, double bottom, double top, double near, double far) Sets the matrix to an orthographic projection like glOrtho following the OpenGL equivalentsetToOrtho2D
(double x, double y, double width, double height) Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height.setToOrtho2D
(double x, double y, double width, double height, double near, double far) Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height, having a near and far plane.setToProjection
(double near, double far, double fov, double aspectRatio) Sets the matrix to a projection matrix with a near- and far plane, a field of view in degrees and an aspect ratio.setToRotation
(double axisX, double axisY, double axisZ, double degrees) Sets the matrix to a rotation matrix around the given axis.setToRotation
(double x1, double y1, double z1, double x2, double y2, double z2) Set the matrix to a rotation matrix between two vectors.setToRotation
(Vector3d axis, double degrees) Sets the matrix to a rotation matrix around the given axis.setToRotation
(Vector3d v1, Vector3d v2) Set the matrix to a rotation matrix between two vectors.setToRotationRad
(double axisX, double axisY, double axisZ, double radians) Sets the matrix to a rotation matrix around the given axis.setToRotationRad
(Vector3d axis, double radians) Sets the matrix to a rotation matrix around the given axis.setToScaling
(double x, double y, double z) Sets this matrix to a scaling matrixsetToScaling
(Vector3d vector) Sets this matrix to a scaling matrixsetToTranslation
(double x, double y, double z) Sets this matrix to a translation matrix, overwriting it first by an identity matrix and then setting the 4th column to the translation vector.setToTranslation
(com.badlogic.gdx.math.Vector3 vector) setToTranslation
(Vector3d vector) Sets this matrix to a translation matrix, overwriting it first by an identity matrix and then setting the 4th column to the translation vector.setToTranslationAndScaling
(double translationX, double translationY, double translationZ, double scalingX, double scalingY, double scalingZ) Sets this matrix to a translation and scaling matrix by first overwriting it with an identity and then setting the translation vector in the 4th column and the scaling vector in the diagonal.setToTranslationAndScaling
(Vector3d translation, Vector3d scaling) Sets this matrix to a translation and scaling matrix by first overwriting it with an identity and then setting the translation vector in the 4th column and the scaling vector in the diagonal.setToWorld
(Vector3d position, Vector3d forward, Vector3d up) setTranslation
(double x, double y, double z) Sets the 4th column to the translation vector.setTranslation
(Vector3d vector) Sets the 4th column to the translation vector.removes the translational part and transposes the matrix.toString()
tra()
Transposes the matrix.translate
(double[] translation) Postmultiplies this matrix by a translation matrix.translate
(double x, double y, double z) Postmultiplies this matrix by a translation matrix.Postmultiplies this matrix by a translation matrix.trn
(double x, double y, double z) Adds a translational component to the matrix in the 4th column.Adds a translational component to the matrix in the 4th column.
-
Field Details
-
M00
public static final int M00XX: Typically the unrotated X component for scaling, also the cosine of the angle when rotated on the Y and/or Z axis. On Vector3d multiplication this value is multiplied with the source X component and added to the target X component.- See Also:
-
M01
public static final int M01XY: Typically the negative sine of the angle when rotated on the Z axis. On Vector3d multiplication this value is multiplied with the source Y component and added to the target X component.- See Also:
-
M02
public static final int M02XZ: Typically the sine of the angle when rotated on the Y axis. On Vector3d multiplication this value is multiplied with the source Z component and added to the target X component.- See Also:
-
M03
public static final int M03XW: Typically the translation of the X component. On Vector3d multiplication this value is added to the target X component.- See Also:
-
M10
public static final int M10YX: Typically the sine of the angle when rotated on the Z axis. On Vector3d multiplication this value is multiplied with the source X component and added to the target Y component.- See Also:
-
M11
public static final int M11YY: Typically the unrotated Y component for scaling, also the cosine of the angle when rotated on the X and/or Z axis. On Vector3d multiplication this value is multiplied with the source Y component and added to the target Y component.- See Also:
-
M12
public static final int M12YZ: Typically the negative sine of the angle when rotated on the X axis. On Vector3d multiplication this value is multiplied with the source Z component and added to the target Y component.- See Also:
-
M13
public static final int M13YW: Typically the translation of the Y component. On Vector3d multiplication this value is added to the target Y component.- See Also:
-
M20
public static final int M20ZX: Typically the negative sine of the angle when rotated on the Y axis. On Vector3d multiplication this value is multiplied with the source X component and added to the target Z component.- See Also:
-
M21
public static final int M21ZY: Typical the sine of the angle when rotated on the X axis. On Vector3d multiplication this value is multiplied with the source Y component and added to the target Z component.- See Also:
-
M22
public static final int M22ZZ: Typically the unrotated Z component for scaling, also the cosine of the angle when rotated on the X and/or Y axis. On Vector3d multiplication this value is multiplied with the source Z component and added to the target Z component.- See Also:
-
M23
public static final int M23ZW: Typically the translation of the Z component. On Vector3d multiplication this value is added to the target Z component.- See Also:
-
M30
public static final int M30WX: Typically the value zero. On Vector3d multiplication this value is ignored.- See Also:
-
M31
public static final int M31WY: Typically the value zero. On Vector3d multiplication this value is ignored.- See Also:
-
M32
public static final int M32WZ: Typically the value zero. On Vector3d multiplication this value is ignored.- See Also:
-
M33
public static final int M33WW: Typically the value one. On Vector3d multiplication this value is ignored.- See Also:
-
stmp
public static final double[] stmp -
tmp
public final double[] tmp -
val
public final double[] val
-
-
Constructor Details
-
Matrix4d
public Matrix4d()Constructs an identity matrix -
Matrix4d
Constructs a matrix from the given matrix.- Parameters:
matrix
- The matrix to copy. (This matrix is not modified)
-
Matrix4d
public Matrix4d(double[] values) Constructs a matrix from the given double array. The array must have at least 16 elements; the first 16 will be copied.- Parameters:
values
- The double array to copy. Remember that this matrix is in column major order. (The double array is not modified.)
-
Matrix4d
public Matrix4d(float[] values) -
Matrix4d
Constructs a rotation matrix from the givenQuaterniond
.- Parameters:
quaternion
- The quaternion to be copied. (The quaternion is not modified)
-
Matrix4d
Construct a matrix from the given translation, rotation and scale.- Parameters:
position
- The translationrotation
- The rotation, must be normalizedscale
- The scale
-
-
Method Details
-
inv
public static boolean inv(double[] values) Computes the inverse of the given matrix. The matrix array is assumed to hold a 4x4 column major matrix as you can get fromMatrix4.val
.- Parameters:
values
- the matrix values.- Returns:
- false in case the inverse could not be calculated, true otherwise.
-
prj
public static void prj(double[] mat, double[] vec) Multiplies the vector with the given matrix, performing a division by w. The matrix array is assumed to hold a 4x4 column major matrix as you can get fromval
. The vector array is assumed to hold a 3-component vector, with x being the first element, y being the second and z being the last component. The result is stored in the vector array. This is the same asVector3d.prj(Matrix4d)
.- Parameters:
mat
- the matrixvec
- the vector.
-
prj
public static void prj(double[] mat, double[] vecs, int offset, int numVecs, int stride) Multiplies the vectors with the given matrix, , performing a division by w. The matrix array is assumed to hold a 4x4 column major matrix as you can get fromMatrix4.val
. The vectors array is assumed to hold 3-component vectors. Offset specifies the offset into the array where the x-component of the first vector is located. The numVecs parameter specifies the number of vectors stored in the vectors array. The stride parameter specifies the number of floats between subsequent vectors and must be >= 3. This is the same asVector3.prj(Matrix4)
applied to multiple vectors.- Parameters:
mat
- the matrixvecs
- the vectorsoffset
- the offset into the vectors arraynumVecs
- the number of vectorsstride
- the stride between vectors in floats
-
mul
public static void mul(double[] mata, double[] matb) Multiplies the matrix mata with matrix matb, storing the result in mata. The arrays are assumed to hold 4x4 column major matrices as you can get fromval
. This is the same asmul(Matrix4d)
.- Parameters:
mata
- the first matrix.matb
- the second matrix.
-
changeOfBasis
Constructs a change of basis from the canonical basis to the base defined by the given x, y and z vectors.- Parameters:
x
- The x vector of the new basis expressed in the canonical basis.y
- The y vector of the new basis expressed in the canonical basis.z
- The z vector of the new basis expressed in the canonical basis.- Returns:
- The change of basis matrix.
-
changeOfBasis
Constructs a change of basis from the canonical basis to the base defined by the given x, y and z vectors.- Parameters:
x
- The x vector of the new basis expressed in the canonical basis.y
- The y vector of the new basis expressed in the canonical basis.z
- The z vector of the new basis expressed in the canonical basis.- Returns:
- The change of basis matrix.
-
set
Sets the matrix to the given matrix.- Parameters:
matrix
- The matrix that is to be copied. (The given matrix is not modified)- Returns:
- This matrix for the purpose of chaining methods together.
-
set
-
set
Sets the matrix to the given matrix as a double array. The double array must have at least 16 elements; the first 16 will be copied.- Parameters:
values
- The matrix, in double form, that is to be copied. Remember that this matrix is in column major order.- Returns:
- This matrix for the purpose of chaining methods together.
-
set
-
set
Sets the matrix to a rotation matrix representing the quaternion.- Parameters:
quaternion
- The quaternion that is to be used to set this matrix.- Returns:
- This matrix for the purpose of chaining methods together.
-
set
Sets the matrix to a rotation matrix representing the quaternion.- Parameters:
quaternionX
- The X component of the quaternion that is to be used to set this matrix.quaternionY
- The Y component of the quaternion that is to be used to set this matrix.quaternionZ
- The Z component of the quaternion that is to be used to set this matrix.quaternionW
- The W component of the quaternion that is to be used to set this matrix.- Returns:
- This matrix for the purpose of chaining methods together.
-
set
Set this matrix to the specified translation and rotation.- Parameters:
position
- The translationorientation
- The rotation, must be normalized- Returns:
- This matrix for chaining
-
set
public Matrix4d set(double translationX, double translationY, double translationZ, double quaternionX, double quaternionY, double quaternionZ, double quaternionW) Sets the matrix to a rotation matrix representing the translation and quaternion.- Parameters:
translationX
- The X component of the translation that is to be used to set this matrix.translationY
- The Y component of the translation that is to be used to set this matrix.translationZ
- The Z component of the translation that is to be used to set this matrix.quaternionX
- The X component of the quaternion that is to be used to set this matrix.quaternionY
- The Y component of the quaternion that is to be used to set this matrix.quaternionZ
- The Z component of the quaternion that is to be used to set this matrix.quaternionW
- The W component of the quaternion that is to be used to set this matrix.- Returns:
- This matrix for the purpose of chaining methods together.
-
set
Set this matrix to the specified translation, rotation and scale.- Parameters:
position
- The translationorientation
- The rotation, must be normalizedscale
- The scale- Returns:
- This matrix for chaining
-
set
public Matrix4d set(double translationX, double translationY, double translationZ, double quaternionX, double quaternionY, double quaternionZ, double quaternionW, double scaleX, double scaleY, double scaleZ) Sets the matrix to a rotation matrix representing the translation and quaternion.- Parameters:
translationX
- The X component of the translation that is to be used to set this matrix.translationY
- The Y component of the translation that is to be used to set this matrix.translationZ
- The Z component of the translation that is to be used to set this matrix.quaternionX
- The X component of the quaternion that is to be used to set this matrix.quaternionY
- The Y component of the quaternion that is to be used to set this matrix.quaternionZ
- The Z component of the quaternion that is to be used to set this matrix.quaternionW
- The W component of the quaternion that is to be used to set this matrix.scaleX
- The X component of the scaling that is to be used to set this matrix.scaleY
- The Y component of the scaling that is to be used to set this matrix.scaleZ
- The Z component of the scaling that is to be used to set this matrix.- Returns:
- This matrix for the purpose of chaining methods together.
-
set
Sets the four columns of the matrix which correspond to the x-, y- and z-axis of the vector space this matrix creates as well as the 4th column representing the translation of any point that is multiplied by this matrix.- Parameters:
xAxis
- The x-axis.yAxis
- The y-axis.zAxis
- The z-axis.pos
- The translation vector.
-
cpy
- Returns:
- a copy of this matrix
-
trn
Adds a translational component to the matrix in the 4th column. The other columns are untouched.- Parameters:
vector
- The translation vector to add to the current matrix. (This vector is not modified)- Returns:
- This matrix for the purpose of chaining methods together.
-
trn
Adds a translational component to the matrix in the 4th column. The other columns are untouched.- Parameters:
x
- The x-component of the translation vector.y
- The y-component of the translation vector.z
- The z-component of the translation vector.- Returns:
- This matrix for the purpose of chaining methods together.
-
getValues
public double[] getValues()- Returns:
- the backing double array
-
getValuesFloat
public float[] getValuesFloat() -
mul
Postmultiplies this matrix with the given matrix, storing the result in this matrix. For example:A.mul(B) results in A := AB.
- Parameters:
matrix
- The other matrix to multiply by.- Returns:
- This matrix for the purpose of chaining operations together.
-
mulLeft
Premultiplies this matrix with the given matrix, storing the result in this matrix. For example:A.mulLeft(B) results in A := BA.
- Parameters:
matrix
- The other matrix to multiply by.- Returns:
- This matrix for the purpose of chaining operations together.
-
tra
Transposes the matrix.- Returns:
- This matrix for the purpose of chaining methods together.
-
idt
Sets the matrix to an identity matrix.- Returns:
- This matrix for the purpose of chaining methods together.
-
inv
-
det
public double det()- Returns:
- The determinant of this matrix
-
det3x3
public double det3x3()- Returns:
- The determinant of the 3x3 upper left matrix
-
setToProjection
Sets the matrix to a projection matrix with a near- and far plane, a field of view in degrees and an aspect ratio.- Parameters:
near
- The near planefar
- The far planefov
- The field of view in degreesaspectRatio
- The "width over height" aspect ratio- Returns:
- This matrix for the purpose of chaining methods together.
-
setToOrtho2D
Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height. The near plane is set to 0, the far plane is set to 1.- Parameters:
x
- The x-coordinate of the originy
- The y-coordinate of the originwidth
- The widthheight
- The height- Returns:
- This matrix for the purpose of chaining methods together.
-
setToOrtho2D
public Matrix4d setToOrtho2D(double x, double y, double width, double height, double near, double far) Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height, having a near and far plane.- Parameters:
x
- The x-coordinate of the originy
- The y-coordinate of the originwidth
- The widthheight
- The heightnear
- The near planefar
- The far plane- Returns:
- This matrix for the purpose of chaining methods together.
-
setToOrtho
public Matrix4d setToOrtho(double left, double right, double bottom, double top, double near, double far) Sets the matrix to an orthographic projection like glOrtho following the OpenGL equivalent- Parameters:
left
- The left clipping planeright
- The right clipping planebottom
- The bottom clipping planetop
- The top clipping planenear
- The near clipping planefar
- The far clipping plane- Returns:
- This matrix for the purpose of chaining methods together.
-
setTranslation
Sets the 4th column to the translation vector.- Parameters:
x
- The X coordinate of the translation vectory
- The Y coordinate of the translation vectorz
- The Z coordinate of the translation vector- Returns:
- This matrix for the purpose of chaining methods together.
-
setToTranslation
Sets this matrix to a translation matrix, overwriting it first by an identity matrix and then setting the 4th column to the translation vector.- Parameters:
vector
- The translation vector- Returns:
- This matrix for the purpose of chaining methods together.
-
setToTranslation
-
setToTranslation
Sets this matrix to a translation matrix, overwriting it first by an identity matrix and then setting the 4th column to the translation vector.- Parameters:
x
- The x-component of the translation vector.y
- The y-component of the translation vector.z
- The z-component of the translation vector.- Returns:
- This matrix for the purpose of chaining methods together.
-
setToTranslationAndScaling
Sets this matrix to a translation and scaling matrix by first overwriting it with an identity and then setting the translation vector in the 4th column and the scaling vector in the diagonal.- Parameters:
translation
- The translation vectorscaling
- The scaling vector- Returns:
- This matrix for the purpose of chaining methods together.
-
setToTranslationAndScaling
public Matrix4d setToTranslationAndScaling(double translationX, double translationY, double translationZ, double scalingX, double scalingY, double scalingZ) Sets this matrix to a translation and scaling matrix by first overwriting it with an identity and then setting the translation vector in the 4th column and the scaling vector in the diagonal.- Parameters:
translationX
- The x-component of the translation vectortranslationY
- The y-component of the translation vectortranslationZ
- The z-component of the translation vectorscalingX
- The x-component of the scaling vectorscalingY
- The x-component of the scaling vectorscalingZ
- The x-component of the scaling vector- Returns:
- This matrix for the purpose of chaining methods together.
-
setToRotation
Sets the matrix to a rotation matrix around the given axis.- Parameters:
axis
- The axisdegrees
- The angle in degrees- Returns:
- This matrix for the purpose of chaining methods together.
-
setToRotationRad
Sets the matrix to a rotation matrix around the given axis.- Parameters:
axis
- The axisradians
- The angle in radians- Returns:
- This matrix for the purpose of chaining methods together.
-
setToRotation
Sets the matrix to a rotation matrix around the given axis.- Parameters:
axisX
- The x-component of the axisaxisY
- The y-component of the axisaxisZ
- The z-component of the axisdegrees
- The angle in degrees- Returns:
- This matrix for the purpose of chaining methods together.
-
setToRotationRad
Sets the matrix to a rotation matrix around the given axis.- Parameters:
axisX
- The x-component of the axisaxisY
- The y-component of the axisaxisZ
- The z-component of the axisradians
- The angle in radians- Returns:
- This matrix for the purpose of chaining methods together.
-
setToRotation
Set the matrix to a rotation matrix between two vectors.- Parameters:
v1
- The base vectorv2
- The target vector- Returns:
- This matrix for the purpose of chaining methods together
-
setToRotation
Set the matrix to a rotation matrix between two vectors.- Parameters:
x1
- The base vectors x valuey1
- The base vectors y valuez1
- The base vectors z valuex2
- The target vector x valuey2
- The target vector y valuez2
- The target vector z value- Returns:
- This matrix for the purpose of chaining methods together
-
setFromEulerAngles
Sets this matrix to a rotation matrix from the given euler angles.- Parameters:
yaw
- the yaw in degreespitch
- the pitch in degreesroll
- the roll in degrees- Returns:
- This matrix
-
setToScaling
Sets this matrix to a scaling matrix- Parameters:
vector
- The scaling vector- Returns:
- This matrix for chaining.
-
setToScaling
Sets this matrix to a scaling matrix- Parameters:
x
- The x-component of the scaling vectory
- The y-component of the scaling vectorz
- The z-component of the scaling vector- Returns:
- This matrix for chaining.
-
setToLookAt
Sets the matrix to a look at matrix with a direction and an up vector. Multiply with a translation matrix to get a camera model view matrix.- Parameters:
direction
- The direction vectorup
- The up vector- Returns:
- This matrix for the purpose of chaining methods together.
-
setToLookAt
-
setToLookAt
Sets this matrix to a look at matrix with the given position, target and up vector.- Parameters:
position
- the positiontarget
- the targetup
- the up vector- Returns:
- This matrix
-
setToLookAt
-
setToWorld
-
toString
-
lerp
Linearly interpolates between this matrix and the given matrix mixing by alpha- Parameters:
matrix
- the matrixalpha
- the alpha value in the range [0,1]- Returns:
- This matrix for the purpose of chaining methods together.
-
set
Sets this matrix to the given 3x3 matrix. The third column of this matrix is set to (0,0,1,0).- Parameters:
mat
- the matrix
-
scl
-
scl
-
scl
-
getTranslation
-
getTranslationf
public com.badlogic.gdx.math.Vector3 getTranslationf(com.badlogic.gdx.math.Vector3 position) -
getTranslation
public double[] getTranslation() -
setTranslation
Sets the 4th column to the translation vector.- Parameters:
vector
- The translation vector- Returns:
- This matrix for the purpose of chaining methods together.
-
getTranslationf
public float[] getTranslationf() -
getTranslationf
public void getTranslationf(float[] vec) -
addTranslationTo
-
getRotation
Gets the rotation of this matrix.- Parameters:
rotation
- TheQuaterniond
to receive the rotationnormalizeAxes
- True to normalize the axes, necessary when the matrix might also include scaling.- Returns:
- The provided
Quaterniond
for chaining.
-
getRotation
Gets the rotation of this matrix.- Parameters:
rotation
- TheQuaterniond
to receive the rotation- Returns:
- The provided
Quaterniond
for chaining.
-
getScaleXSquared
public double getScaleXSquared()- Returns:
- the squared scale factor on the X axis
-
getScaleYSquared
public double getScaleYSquared()- Returns:
- the squared scale factor on the Y axis
-
getScaleZSquared
public double getScaleZSquared()- Returns:
- the squared scale factor on the Z axis
-
getScaleX
public double getScaleX()- Returns:
- the scale factor on the X axis (non-negative)
-
getScaleY
public double getScaleY()- Returns:
- the scale factor on the Y axis (non-negative)
-
getScaleZ
public double getScaleZ()- Returns:
- the scale factor on the X axis (non-negative)
-
getScale
-
toNormalMatrix
removes the translational part and transposes the matrix. -
translate
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' glTranslate/glRotate/glScale- Parameters:
translation
-- Returns:
- This matrix for the purpose of chaining methods together.
-
translate
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' glTranslate/glRotate/glScale- Parameters:
translation
-- Returns:
- This matrix for the purpose of chaining methods together.
-
translate
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.- Parameters:
x
- Translation in the x-axis.y
- Translation in the y-axis.z
- Translation in the z-axis.- Returns:
- This matrix for the purpose of chaining methods together.
-
rotate
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.- Parameters:
axis
- The vector axis to rotate around.degrees
- The angle in degrees.- Returns:
- This matrix for the purpose of chaining methods together.
-
rotateRad
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.- Parameters:
axis
- The vector axis to rotate around.radians
- The angle in radians.- Returns:
- This matrix for the purpose of chaining methods together.
-
rotate
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale- Parameters:
axisX
- The x-axis component of the vector to rotate around.axisY
- The y-axis component of the vector to rotate around.axisZ
- The z-axis component of the vector to rotate around.degrees
- The angle in degrees- Returns:
- This matrix for the purpose of chaining methods together.
-
rotateRad
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale- Parameters:
axisX
- The x-axis component of the vector to rotate around.axisY
- The y-axis component of the vector to rotate around.axisZ
- The z-axis component of the vector to rotate around.radians
- The angle in radians- Returns:
- This matrix for the purpose of chaining methods together.
-
rotate
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.- Parameters:
rotation
-- Returns:
- This matrix for the purpose of chaining methods together.
-
rotate
Postmultiplies this matrix by the rotation between two vectors.- Parameters:
v1
- The base vectorv2
- The target vector- Returns:
- This matrix for the purpose of chaining methods together
-
scale
Postmultiplies this matrix with a scale matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.- Parameters:
scaleX
- The scale in the x-axis.scaleY
- The scale in the y-axis.scaleZ
- The scale in the z-axis.- Returns:
- This matrix for the purpose of chaining methods together.
-
extract4x3Matrix
public void extract4x3Matrix(double[] dst) Copies the 4x3 upper-left sub-matrix into double array. The destination array is supposed to be a column major matrix.- Parameters:
dst
- the destination matrix
-
putIn
public com.badlogic.gdx.math.Matrix4 putIn(com.badlogic.gdx.math.Matrix4 aux) Sets the given matrix to this matrix- Parameters:
aux
- The out matrix- Returns:
- The aux matrix
-