public final class Matrix2D extends Object implements ICloneable, Cloneable
PointD
.
The matrix is interpreted row-major. The rows are defined as follows: [ m11 m12 dx ], [ m21 m22 dy ], ([ 0 0 1 ] implicitly).
When transforming a vector v using this matrix, the multiplication is done in this order: v' = M v.
Prepending
a matrix T to this instance results in the operation
M′ = M T. In concept, this means that T is applied before M
when applying M' to a vector. Appending
T to M results in
M′ = T M.
Constructor and Description |
---|
Matrix2D()
Create an identity matrix.
|
Matrix2D(double m11,
double m12,
double m21,
double m22,
double dx,
double dy)
Create a matrix using the provided matrix entries.
|
Modifier and Type | Method and Description |
---|---|
Matrix2D |
clone()
Clones this instance.
|
static Matrix2D |
createRotateInstance(double theta)
Creates a matrix rotation instance around the origin.
|
boolean |
equals(Matrix2D other) |
static Matrix2D |
fromTransform(Transform transform) |
double[] |
getElements()
Returns a new double[] of the elements describing the matrix.
|
void |
invert()
Inverts this instance.
|
void |
multiply(Matrix2D matrix,
MatrixOrder order)
Multiplies this matrix instance by the given instance using the given order.
|
void |
reset()
Resets this instance to the identity.
|
void |
rotate(double theta)
Prepends a rotate operation to this matrix.
|
void |
rotate(double theta,
MatrixOrder order)
Prepends or appends a rotation operation to this matrix around the origin.
|
void |
rotate(double theta,
PointD center)
Prepends a rotation operation to this matrix around the specified rotation center.
|
void |
rotate(double theta,
PointD center,
MatrixOrder order)
Prepends or appends a rotation operation to this matrix around the specified rotation center.
|
void |
scale(double x,
double y)
Prepends a scale operation to this instance.
|
void |
scale(double x,
double y,
MatrixOrder order)
Appends or prepends a scale operation to this instance.
|
void |
set(double m0,
double m1,
double m2,
double m3,
double dx,
double dy)
Sets all elements of this instance.
|
void |
set(Matrix2D matrix)
Sets the values of the given matrix to this instance.
|
Transform |
toTransform() |
PointD |
transform(PointD point)
Transforms the given coordinate.
|
<T extends IMutablePoint> |
transform(T point)
Transforms the given point in place.
|
void |
translate(PointD delta)
Prepends a translation to this instance.
|
void |
translate(PointD delta,
MatrixOrder order)
Appends or Prepends a translation to this instance.
|
public Matrix2D()
public Matrix2D(double m11, double m12, double m21, double m22, double dx, double dy)
public final Matrix2D clone()
clone
in interface ICloneable
clone
in class Object
Object.clone()
public static final Matrix2D createRotateInstance(double theta)
theta
- The rotation angle in radians.public final boolean equals(Matrix2D other)
public final double[] getElements()
The order is m11, m12, m21, m22, dx, dy.
public final void invert()
public final void multiply(Matrix2D matrix, MatrixOrder order)
matrix
- The matrix to multiply with this one.order
- The order of the multiplication.public final void reset()
public final void rotate(double theta)
theta
- The angle to rotate in radians.public final void rotate(double theta, MatrixOrder order)
theta
- The rotation angle in radiansorder
- Whether to append or prepend the rotation matrix.public final void rotate(double theta, PointD center)
theta
- The rotation angle in radianscenter
- The coordinates of the center of the rotation.public final void rotate(double theta, PointD center, MatrixOrder order)
theta
- The rotation angle in radianscenter
- The coordinate of the center of the rotation.order
- Whether to append or prepend the rotation matrix.public final void scale(double x, double y)
public final void scale(double x, double y, MatrixOrder order)
public final void set(double m0, double m1, double m2, double m3, double dx, double dy)
public final void set(Matrix2D matrix)
public Transform toTransform()
public final PointD transform(PointD point)
point
- The coordinate to transform.public final <T extends IMutablePoint> T transform(T point)
point
- The point to transform and return.point
public final void translate(PointD delta)
public final void translate(PointD delta, MatrixOrder order)