public final class AffineTransformMatrix1D extends AbstractAffineTransformMatrix<Vector1D,AffineTransformMatrix1D>
Instances of this class use a 2x2 matrix for all transform operations.
The last row of this matrix is always set to the values [0 1]
and so
is not stored. Hence, the methods in this class that accept or return arrays always
use arrays containing 2 elements, instead of 4.
Modifier and Type | Method and Description |
---|---|
Vector1D |
apply(Vector1D vec) |
Vector1D.Unit |
applyDirection(Vector1D vec)
Apply this transform to the given vector, ignoring translations and normalizing the
result.
|
Vector1D |
applyVector(Vector1D vec)
Apply this transform to the given vector, ignoring translations.
|
double |
applyVectorX(double x)
Apply this transform to the given vector coordinate, ignoring translations, and
return the transformed x value.
|
double |
applyX(double x)
Apply this transform to the given point coordinate and return the transformed
x value.
|
static AffineTransformMatrix1D |
createScale(double factor)
Get a transform representing a scale operation.
|
static AffineTransformMatrix1D |
createScale(Vector1D factor)
Get a transform representing a scale operation.
|
static AffineTransformMatrix1D |
createTranslation(double x)
Get a transform representing the given translation.
|
static AffineTransformMatrix1D |
createTranslation(Vector1D translation)
Get 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
AffineTransformMatrix1D
and all matrix element values are exactly equal. |
static AffineTransformMatrix1D |
from(UnaryOperator<Vector1D> fn)
Construct a new transform representing the given function.
|
int |
hashCode() |
static AffineTransformMatrix1D |
identity()
Get the transform representing the identity matrix.
|
AffineTransformMatrix1D |
inverse() |
AffineTransformMatrix1D |
linear()
Return a matrix containing only the linear portion of this transform.
|
AffineTransformMatrix1D |
linearTranspose()
Return a matrix containing the transpose of the linear portion of this transform.
|
AffineTransformMatrix1D |
multiply(AffineTransformMatrix1D m)
Get a new transform created by multiplying this instance by the argument.
|
static AffineTransformMatrix1D |
of(double... arr)
Get a new transform with the given matrix elements.
|
AffineTransformMatrix1D |
premultiply(AffineTransformMatrix1D m)
Get a new transform created by multiplying the argument by this instance.
|
AffineTransformMatrix1D |
scale(double x)
Get a new transform containing the result of applying a scale operation
logically after the transformation represented by the current instance.
|
AffineTransformMatrix1D |
scale(Vector1D scaleFactor)
Get a new transform containing the result of applying a scale operation
logically after the transformation represented by the current instance.
|
double[] |
toArray()
Return a 2 element array containing the variable elements from the
internal transformation matrix.
|
String |
toString() |
AffineTransformMatrix1D |
translate(double x)
Get a new transform containing the result of applying a translation logically after
the transformation represented by the current instance.
|
AffineTransformMatrix1D |
translate(Vector1D translation)
Get a new transform containing the result of applying a translation logically after
the transformation represented by the current instance.
|
normalTransform, preservesOrientation
public double[] toArray()
[ arr[0], arr[1], 0 1 ]
public double applyX(double x)
(x * m00) + m01
.x
- x coordinate valueapply(Vector1D)
public Vector1D applyVector(Vector1D 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.
vec
- the vector to transformapplyDirection(Vector1D)
public double applyVectorX(double x)
x * m00
.x
- x coordinate valueapplyVector(Vector1D)
public Vector1D.Unit applyDirection(Vector1D vec)
transform.applyVector(vec).normalize()
but without
the intermediate vector instance.applyDirection
in class AbstractAffineTransformMatrix<Vector1D,AffineTransformMatrix1D>
vec
- the vector to transformapplyVector(Vector1D)
public double determinant()
determinant
in class AbstractAffineTransformMatrix<Vector1D,AffineTransformMatrix1D>
public AffineTransformMatrix1D linear()
Example
[ a, b ] [ a, 0 ] [ 0, 1 ] → [ 0, 1 ]
linear
in class AbstractAffineTransformMatrix<Vector1D,AffineTransformMatrix1D>
public AffineTransformMatrix1D linearTranspose()
In the one dimensional case, this is exactly the same as linear()
.
Example
[ a, b ] [ a, 0 ] [ 0, 1 ] → [ 0, 1 ]
linearTranspose
in class AbstractAffineTransformMatrix<Vector1D,AffineTransformMatrix1D>
public AffineTransformMatrix1D translate(Vector1D translation)
B * A
, where A
is the current matrix and B
is the matrix representing the given translation.translation
- vector containing the translation values for each axispublic AffineTransformMatrix1D translate(double x)
B * A
, where A
is the current matrix and B
is the matrix representing the given translation.x
- translation in the x directionpublic AffineTransformMatrix1D scale(Vector1D scaleFactor)
B * A
, where A
is the current matrix and B
is the matrix representing the given scale operation.scaleFactor
- vector containing scale factors for each axispublic AffineTransformMatrix1D scale(double x)
B * A
, where A
is the current matrix and B
is the matrix representing the given scale operation.x
- scale factorpublic AffineTransformMatrix1D multiply(AffineTransformMatrix1D 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 AffineTransformMatrix1D premultiply(AffineTransformMatrix1D 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 AffineTransformMatrix1D inverse()
inverse
in interface Transform<Vector1D>
inverse
in class AbstractAffineTransformMatrix<Vector1D,AffineTransformMatrix1D>
IllegalStateException
- if the matrix cannot be invertedpublic boolean equals(Object obj)
AffineTransformMatrix1D
and all matrix element values are exactly equal.public static AffineTransformMatrix1D of(double... arr)
arr
- 2-element array containing values for the variable entries in the
transform matrixIllegalArgumentException
- if the array does not have 2 elementspublic static AffineTransformMatrix1D from(UnaryOperator<Vector1D> fn)
fn
- function to create a transform matrix fromIllegalArgumentException
- if the given function does not represent a valid
affine transformpublic static AffineTransformMatrix1D identity()
public static AffineTransformMatrix1D createTranslation(Vector1D translation)
translation
- vector containing translation values for each axispublic static AffineTransformMatrix1D createTranslation(double x)
x
- translation in the x directionpublic static AffineTransformMatrix1D createScale(Vector1D factor)
factor
- vector containing the scale factorpublic static AffineTransformMatrix1D createScale(double factor)
factor
- scale factorCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.