public final class AffineTransformMatrix3D extends AbstractAffineTransformMatrix<Vector3D,AffineTransformMatrix3D>
Instances of this class use a 4x4 matrix for all transform operations.
The last row of this matrix is always set to the values [0 0 0 1]
and so
is not stored. Hence, the methods in this class that accept or return arrays always
use arrays containing 12 elements, instead of 16.
Modifier and Type | Method and Description |
---|---|
Vector3D |
apply(Vector3D pt)
Apply this transform to the given point, returning the result as a new instance.
|
Vector3D.Unit |
applyDirection(Vector3D vec)
Apply this transform to the given vector, ignoring translations and normalizing the
result.
|
Vector3D |
applyVector(Vector3D vec)
Apply this transform to the given vector, ignoring translations.
|
double |
applyVectorX(double x,
double y,
double z)
Apply this transform to the given vector coordinates, ignoring translations, and
return the transformed x value.
|
double |
applyVectorY(double x,
double y,
double z)
Apply this transform to the given vector coordinates, ignoring translations, and
return the transformed y value.
|
double |
applyVectorZ(double x,
double y,
double z)
Apply this transform to the given vector coordinates, ignoring translations, and
return the transformed z value.
|
double |
applyX(double x,
double y,
double z)
Apply this transform to the given point coordinates and return the transformed
x value.
|
double |
applyY(double x,
double y,
double z)
Apply this transform to the given point coordinates and return the transformed
y value.
|
double |
applyZ(double x,
double y,
double z)
Apply this transform to the given point coordinates and return the transformed
z value.
|
static AffineTransformMatrix3D |
createRotation(Vector3D center,
QuaternionRotation rotation)
Create a transform representing a rotation about the given center point.
|
static AffineTransformMatrix3D |
createScale(double factor)
Create a transform representing a scale operation with the given scale factor applied to all axes.
|
static AffineTransformMatrix3D |
createScale(double x,
double y,
double z)
Create a transform representing a scale operation.
|
static AffineTransformMatrix3D |
createScale(Vector3D factors)
Create a transform representing a scale operation.
|
static AffineTransformMatrix3D |
createTranslation(double x,
double y,
double z)
Create a transform representing the given translation.
|
static AffineTransformMatrix3D |
createTranslation(Vector3D translation)
Create a transform representing the given translation.
|
double |
determinant()
Get the determinant of the matrix.
|
boolean |
equals(Object obj)
Return true if the given object is an instance of
AffineTransformMatrix3D
and all matrix element values are exactly equal. |
static AffineTransformMatrix3D |
from(UnaryOperator<Vector3D> fn)
Construct a new transform representing the given function.
|
static AffineTransformMatrix3D |
fromColumnVectors(Vector3D u,
Vector3D v,
Vector3D w)
Get a new transform create from the given column vectors.
|
static AffineTransformMatrix3D |
fromColumnVectors(Vector3D u,
Vector3D v,
Vector3D w,
Vector3D t)
Get a new transform created from the given column vectors.
|
int |
hashCode() |
static AffineTransformMatrix3D |
identity()
Get the transform representing the identity matrix.
|
AffineTransformMatrix3D |
inverse() |
AffineTransformMatrix3D |
linear()
Return a matrix containing only the linear portion of this transform.
|
AffineTransformMatrix3D |
linearTranspose()
Return a matrix containing the transpose of the linear portion of this transform.
|
AffineTransformMatrix3D |
multiply(AffineTransformMatrix3D m)
Get a new transform created by multiplying this instance by the argument.
|
static AffineTransformMatrix3D |
of(double... arr)
Get a new transform with the given matrix elements.
|
AffineTransformMatrix3D |
premultiply(AffineTransformMatrix3D m)
Get a new transform created by multiplying the argument by this instance.
|
AffineTransformMatrix3D |
rotate(QuaternionRotation rotation)
Apply a rotation to the current instance, returning the result as a new transform.
|
AffineTransformMatrix3D |
rotate(Vector3D center,
QuaternionRotation rotation)
Apply a rotation around the given center point to the current instance, returning the result
as a new transform.
|
AffineTransformMatrix3D |
scale(double factor)
Apply a scale operation to the current instance, returning the result as a new transform.
|
AffineTransformMatrix3D |
scale(double x,
double y,
double z)
Apply a scale operation to the current instance, returning the result as a new transform.
|
AffineTransformMatrix3D |
scale(Vector3D scaleFactors)
Apply a scale operation to the current instance, returning the result as a new transform.
|
double[] |
toArray()
Return a 12 element array containing the variable elements from the
internal transformation matrix.
|
String |
toString() |
AffineTransformMatrix3D |
translate(double x,
double y,
double z)
Apply a translation to the current instance, returning the result as a new transform.
|
AffineTransformMatrix3D |
translate(Vector3D translation)
Apply a translation to the current instance, returning the result as a new transform.
|
normalTransform, preservesOrientation
public double[] toArray()
[ arr[0], arr[1], arr[2], arr[3] arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], 0 0 0 1 ]
public Vector3D apply(Vector3D pt)
The transformed point is computed by creating a 4-element column vector from the
coordinates in the input and setting the last element to 1. This is then multiplied with the
4x4 transform matrix to produce the transformed point. The 1
in the last position
is ignored.
[ m00 m01 m02 m03 ] [ x ] [ x'] [ m10 m11 m12 m13 ] * [ y ] = [ y'] [ m20 m21 m22 m23 ] [ z ] [ z'] [ 0 0 0 1 ] [ 1 ] [ 1 ]
public double applyX(double x, double y, double z)
(x * m00) + (y * m01) + (z * m02) + m03
.x
- x coordinate valuey
- y coordinate valuez
- z coordinate valueapply(Vector3D)
public double applyY(double x, double y, double z)
(x * m10) + (y * m11) + (z * m12) + m13
.x
- x coordinate valuey
- y coordinate valuez
- z coordinate valueapply(Vector3D)
public double applyZ(double x, double y, double z)
(x * m20) + (y * m21) + (z * m22) + m23
.x
- x coordinate valuey
- y coordinate valuez
- z coordinate valueapply(Vector3D)
public Vector3D applyVector(Vector3D vec)
This method can be used to transform vector instances representing displacements between points.
For example, if v
represents the difference between points p1
and p2
,
then transform.applyVector(v)
will represent the difference between p1
and p2
after transform
is applied.
The transformed vector is computed by creating a 4-element column vector from the
coordinates in the input and setting the last element to 0. This is then multiplied with the
4x4 transform matrix to produce the transformed vector. The 0
in the last position
is ignored.
[ m00 m01 m02 m03 ] [ x ] [ x'] [ m10 m11 m12 m13 ] * [ y ] = [ y'] [ m20 m21 m22 m23 ] [ z ] [ z'] [ 0 0 0 1 ] [ 0 ] [ 0 ]
vec
- the vector to transformapplyDirection(Vector3D)
public double applyVectorX(double x, double y, double z)
(x * m00) + (y * m01) + (z * m02)
.x
- x coordinate valuey
- y coordinate valuez
- z coordinate valueapplyVector(Vector3D)
public double applyVectorY(double x, double y, double z)
(x * m10) + (y * m11) + (z * m12)
.x
- x coordinate valuey
- y coordinate valuez
- z coordinate valueapplyVector(Vector3D)
public double applyVectorZ(double x, double y, double z)
(x * m20) + (y * m21) + (z * m22)
.x
- x coordinate valuey
- y coordinate valuez
- z coordinate valueapplyVector(Vector3D)
public Vector3D.Unit applyDirection(Vector3D vec)
transform.applyVector(vec).normalize()
but without
the intermediate vector instance.applyDirection
in class AbstractAffineTransformMatrix<Vector3D,AffineTransformMatrix3D>
vec
- the vector to transformapplyVector(Vector3D)
public double determinant()
determinant
in class AbstractAffineTransformMatrix<Vector3D,AffineTransformMatrix3D>
public AffineTransformMatrix3D linear()
Example
[ a, b, c, d ] [ a, b, c, 0 ] [ e, f, g, h ] [ e, f, g, 0 ] [ i, j, k, l ] → [ i, j, k, 0 ] [ 0, 0, 0, 1 ] [ 0, 0, 0, 1 ]
linear
in class AbstractAffineTransformMatrix<Vector3D,AffineTransformMatrix3D>
public AffineTransformMatrix3D linearTranspose()
Example
[ a, b, c, d ] [ a, e, i, 0 ] [ e, f, g, h ] [ b, f, j, 0 ] [ i, j, k, l ] → [ c, g, k, 0 ] [ 0, 0, 0, 1 ] [ 0, 0, 0, 1 ]
linearTranspose
in class AbstractAffineTransformMatrix<Vector3D,AffineTransformMatrix3D>
public AffineTransformMatrix3D translate(Vector3D translation)
translation
- vector containing the translation values for each axispublic AffineTransformMatrix3D translate(double x, double y, double z)
x
- translation in the x directiony
- translation in the y directionz
- translation in the z directionpublic AffineTransformMatrix3D scale(double factor)
factor
- the scale factor to apply to all axespublic AffineTransformMatrix3D scale(Vector3D scaleFactors)
scaleFactors
- vector containing scale factors for each axispublic AffineTransformMatrix3D scale(double x, double y, double z)
x
- scale factor for the x axisy
- scale factor for the y axisz
- scale factor for the z axispublic AffineTransformMatrix3D rotate(QuaternionRotation rotation)
rotation
- the rotation to applyQuaternionRotation.toMatrix()
public AffineTransformMatrix3D rotate(Vector3D center, QuaternionRotation rotation)
center
- the center of rotationrotation
- the rotation to applyQuaternionRotation.toMatrix()
public AffineTransformMatrix3D multiply(AffineTransformMatrix3D m)
A * M
where A
is the
current transform matrix and M
is the given transform matrix. In
terms of transformations, applying the returned matrix is equivalent to
applying M
and then applying A
. In other words,
the rightmost transform is applied first.m
- the transform to multiply withpublic AffineTransformMatrix3D premultiply(AffineTransformMatrix3D m)
M * A
where A
is the
current transform matrix and M
is the given transform matrix. In
terms of transformations, applying the returned matrix is equivalent to
applying A
and then applying M
. In other words,
the rightmost transform is applied first.m
- the transform to multiply withpublic AffineTransformMatrix3D inverse()
inverse
in interface Transform<Vector3D>
inverse
in class AbstractAffineTransformMatrix<Vector3D,AffineTransformMatrix3D>
IllegalStateException
- if the matrix cannot be invertedpublic boolean equals(Object obj)
AffineTransformMatrix3D
and all matrix element values are exactly equal.public static AffineTransformMatrix3D of(double... arr)
arr
- 12-element array containing values for the variable entries in the
transform matrixIllegalArgumentException
- if the array does not have 12 elementspublic static AffineTransformMatrix3D from(UnaryOperator<Vector3D> fn)
fn
- function to create a transform matrix fromIllegalArgumentException
- if the given function does not represent a valid
affine transformpublic static AffineTransformMatrix3D fromColumnVectors(Vector3D u, Vector3D v, Vector3D w)
u
- first column vector; this corresponds to the first basis vector
in the coordinate framev
- second column vector; this corresponds to the second basis vector
in the coordinate framew
- third column vector; this corresponds to the third basis vector
in the coordinate framepublic static AffineTransformMatrix3D fromColumnVectors(Vector3D u, Vector3D v, Vector3D w, Vector3D t)
u
- first column vector; this corresponds to the first basis vector
in the coordinate framev
- second column vector; this corresponds to the second basis vector
in the coordinate framew
- third column vector; this corresponds to the third basis vector
in the coordinate framet
- fourth column vector; this corresponds to the translation of the transformpublic static AffineTransformMatrix3D identity()
public static AffineTransformMatrix3D createTranslation(Vector3D translation)
translation
- vector containing translation values for each axispublic static AffineTransformMatrix3D createTranslation(double x, double y, double z)
x
- translation in the x directiony
- translation in the y directionz
- translation in the z directionpublic static AffineTransformMatrix3D createScale(double factor)
factor
- scale factor to apply to all axespublic static AffineTransformMatrix3D createScale(Vector3D factors)
factors
- vector containing scale factors for each axispublic static AffineTransformMatrix3D createScale(double x, double y, double z)
x
- scale factor for the x axisy
- scale factor for the y axisz
- scale factor for the z axispublic static AffineTransformMatrix3D createRotation(Vector3D center, QuaternionRotation rotation)
center
- the center of rotationrotation
- the rotation to applyQuaternionRotation.toMatrix()
Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.