public final class Transformation2D extends Object
|m11 m12 0|
| x y 1| * |m21 m22 0| = |m11 * x + m21 * y + m31 m12 * x + m22 * y + m32 1|
|m31 m32 1|
Then elements of the Transformation2D are as follows:
|xx yx 0|
| x y 1| * |xy yy 0| = |xx * x + xy * y + xd yx * x + yy * y + yd 1|
|xd yd 1|
Matrices are used for transformations of the vectors as rows (case
2). That means the math expressions on the Geometry matrix operations should
be writen like this: Modifier and Type | Field and Description |
---|---|
double |
xd
X translation component of the transformation.
|
double |
xx
Matrix coefficient XX of the transformation.
|
double |
xy
Matrix coefficient XY of the transformation.
|
double |
yd
Y translation component of the transformation.
|
double |
yx
Matrix coefficient YX of the transformation.
|
double |
yy
Matrix coefficient YY of the transformation.
|
Constructor and Description |
---|
Transformation2D()
Creates a 2D affine transformation with identity transformation.
|
Transformation2D(double scale)
Creates a 2D affine transformation with a specified scale.
|
Modifier and Type | Method and Description |
---|---|
Transformation2D |
copy()
Returns a copy of the Transformation2D object.
|
boolean |
equals(Object other)
Returns True when all members of this transformation are equal to the
corresponding members of the other.
|
void |
extractScaleTransform(Transformation2D scale,
Transformation2D rotateNshearNshift)
Extracts scaling part of the transformation.
|
void |
flipX(double x0,
double x1)
Flips the transformation around the X axis.
|
void |
flipY(double y0,
double y1)
Flips the transformation around the Y axis.
|
void |
getCoefficients(double[] coefs)
Writes the matrix coefficients in the order XX, XY, XD, YX, YY, YD into
the given array.
|
int |
hashCode()
Returns the hash code for the 2D transformation.
|
void |
inverse()
Inverses the matrix.
|
void |
inverse(Transformation2D inverse)
Produces inverse matrix for this matrix and puts result into the inverse
parameter.
|
boolean |
isDegenerate(double tol)
Returns TRUE if this matrix is degenerated (does not have an inverse)
within the given tolerance.
|
boolean |
isIdentity()
Returns TRUE if this matrix is the identity matrix.
|
boolean |
isIdentity(double tol)
Returns TRUE if this matrix is an identity matrix within the given
tolerance.
|
boolean |
isOrthonormal(double tol)
Returns TRUE if this is an orthonormal transformation with the given
tolerance.
|
boolean |
isReflective()
Returns TRUE for reflective transformations.
|
boolean |
isScaleAndShift(double tol)
Returns TRUE, if this transformation does not have rotation and shear
within the given tolerance.
|
boolean |
isShift()
Returns TRUE if this transformation is a shift transformation.
|
boolean |
isShift(double tol)
Returns TRUE if this transformation is a shift transformation within the
given tolerance.
|
boolean |
isUniform(double eps)
Returns TRUE if this transformation is a uniform transformation.
|
void |
mulLeft(Transformation2D left)
Multiplies this matrix on the left with the "left" matrix.
|
void |
multiply(Transformation2D right)
Multiplies this matrix on the right with the "right" matrix.
|
static void |
multiply(Transformation2D a,
Transformation2D b,
Transformation2D result)
Performs multiplication of matrices a and b and places the result into
this matrix.
|
void |
rotate(double angle_in_Radians)
Rotates the transformation.
|
void |
rotate(double cos,
double sin)
Rotates the transformation.
|
void |
rotate(double cos,
double sin,
Point2D rotationCenter)
Rotates the transformation aroung a center point.
|
void |
scale(double x,
double y)
Scales the transformation.
|
void |
setFlipX(double x0,
double x1)
Sets the transformation to be a flip around the X axis.
|
void |
setFlipY(double y0,
double y1)
Sets the transformation to be a flip around the Y axis.
|
void |
setIdentity()
Sets this matrix to be the identity matrix.
|
void |
setRotate(double angle_in_Radians)
Sets this transformation to be a rotation around point (0, 0).
|
void |
setRotate(double cosA,
double sinA)
Sets rotation for this transformation.
|
void |
setScale(double _scale)
Set transformation to be a uniform scale.
|
void |
setScale(double x,
double y)
Set this transformation to be a scale.
|
void |
setShear(double proportionX,
double proportionY)
Set transformation to a shear.
|
void |
setShift(double x,
double y)
Set this transformation to be a shift.
|
void |
setZero()
Initializes a zero transformation.
|
void |
shear(double proportionX,
double proportionY)
Shears the transformation.
|
void |
shift(double x,
double y)
Shifts the transformation.
|
double |
transform(double tolerance)
Transforms a tolerance value.
|
void |
transform(double[] pointsXYInterleaved,
int start,
int count)
Transforms an array of points stored in an array of doubles as
interleaved XY coordinates.
|
void |
transform(Point[] pointsIn,
int count,
Point[] pointsOut)
Transforms an array of points.
|
public double xx
public double xy
public double xd
public double yx
public double yy
public double yd
public Transformation2D()
public Transformation2D(double scale)
scale
- The scale to use for the transformation.public void setZero()
public boolean equals(Object other)
public int hashCode()
public void transform(Point[] pointsIn, int count, Point[] pointsOut)
pointsIn
- The points to be transformed.count
- The number of points to transform.pointsOut
- The transformed points are returned using this array. It
should have the same or greater size as the input array.public void transform(double[] pointsXYInterleaved, int start, int count)
pointsXYInterleaved
- The array of points with interleaved X, Y values to be
transformed.start
- The start point index to transform from (the actual element
index is 2 * start).count
- The number of points to transform (the actual element count is
2 * count).public void multiply(Transformation2D right)
right
- The matrix to be multiplied with.public void mulLeft(Transformation2D left)
left
- The matrix to be multiplied with.public static void multiply(Transformation2D a, Transformation2D b, Transformation2D result)
a
- The 2D transformation to be multiplied.b
- The 2D transformation to be multiplied.result
- The 2D transformation created by multiplication of matrices.public Transformation2D copy()
public void getCoefficients(double[] coefs)
coefs
- The array into which the coefficients are returned. Should be
of size 6 elements.public double transform(double tolerance)
tolerance
- The tolerance value.public void setIdentity()
public boolean isIdentity()
public boolean isIdentity(double tol)
tol
- The tolerance value.public boolean isReflective()
public boolean isUniform(double eps)
public boolean isShift()
public boolean isShift(double tol)
tol
- The tolerance value.public boolean isOrthonormal(double tol)
tol
- The tolerance value.public boolean isDegenerate(double tol)
tol
- The tolerance value.public boolean isScaleAndShift(double tol)
tol
- The tolerance value.public void setShift(double x, double y)
x
- The X coordinate to shift to.y
- The Y coordinate to shift to.public void setScale(double x, double y)
x
- The X coordinate to scale to.y
- The Y coordinate to scale to.public void setScale(double _scale)
_scale
- The scale of the transformation.public void setFlipX(double x0, double x1)
x0
- The X coordinate to flip.x1
- The X coordinate to flip to.public void setFlipY(double y0, double y1)
y0
- The Y coordinate to flip.y1
- The Y coordinate to flip to.public void setShear(double proportionX, double proportionY)
proportionX
- The proportion of shearing in x direction.proportionY
- The proportion of shearing in y direction.public void setRotate(double angle_in_Radians)
angle_in_Radians
- The rotation angle in radian.public void setRotate(double cosA, double sinA)
cosA
- The rotation angle.sinA
- The rotation angle.public void shift(double x, double y)
x
- The shift factor in X direction.y
- The shift factor in Y direction.public void scale(double x, double y)
x
- The scale factor in X direction.y
- The scale factor in Y direction.public void flipX(double x0, double x1)
x0
- The X coordinate to flip.x1
- The X coordinate to flip to.public void flipY(double y0, double y1)
y0
- The Y coordinate to flip.y1
- The Y coordinate to flip to.public void shear(double proportionX, double proportionY)
proportionX
- The proportion of shearing in x direction.proportionY
- The proportion of shearing in y direction.public void rotate(double angle_in_Radians)
angle_in_Radians
- The rotation angle in radian.public void rotate(double cos, double sin)
cos
- The cos angle of the rotation.sin
- The sin angle of the rotation.public void rotate(double cos, double sin, Point2D rotationCenter)
cos
- The cos angle of the rotation.sin
- sin angle of the rotation.rotationCenter
- The center point of the rotation.public void inverse(Transformation2D inverse)
inverse
- The result inverse matrix.public void inverse()
public void extractScaleTransform(Transformation2D scale, Transformation2D rotateNshearNshift)
scale
- The destination matrix where the scale part is copied.rotateNshearNshift
- The destination matrix where the part excluding rotation is
copied.Copyright © 2018. All rights reserved.