public class Transform
extends java.lang.Object
[ 0 0 1 ]
:
[ x' ] [ xx yx tx ] [ x ] [ xx * x + yx * y + tx ] [ y' ] = [ xy yy ty ] * [ y ] = [ xy * x + yy * y + ty ] [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]A transform is invalid if a value is infinite or not a number, or if the matrix is not invertible (when its determinant
(xx * yy - yx * xy)
is zero).Modifier and Type | Field and Description |
---|---|
double |
tx
The X coordinate translation element M1,3 of the
transform matrix.
|
double |
ty
The Y coordinate translation element M2,3 of the
transform matrix.
|
double |
xx
The X coordinate scaling element M1,1 of the transform
matrix.
|
double |
xy
The Y coordinate shearing element M2,1 of the transform
matrix.
|
double |
yx
The X coordinate shearing element M1,2 of the transform
matrix.
|
double |
yy
The Y coordinate scaling element M2,2 of the transform
matrix.
|
Constructor and Description |
---|
Transform()
Default constructor.
|
Transform(double xx,
double yx,
double tx,
double xy,
double yy,
double ty)
Constructor.
|
Transform(Transform other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
Point |
apply(float x,
float y)
Applies this transform to 2D point (x,y).
|
void |
apply(Point p)
Applies this transform to 2D point (x,y).
|
void |
apply(Point[] points)
Applies this transform to 2D points (x,y).
|
void |
apply(Point[] points,
int offset,
int count)
Applies this transform to 2D points (x,y).
|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
void |
invert()
Inverts this transform.
|
boolean |
isNear(Transform other)
Floating point comparison with tolerance.
|
void |
multiply(double xx,
double yx,
double tx,
double xy,
double yy,
double ty)
Multiply this transform.
|
void |
multiply(Transform other)
Multiplies this transform by the second transform.
|
void |
rotate(double a)
Multiplies the transform with a rotation transformation.
|
void |
rotate(double cosA,
double sinA)
Multiplies the transform with a rotation transformation.
|
void |
rotate(double a,
double x0,
double y0)
Multiplies the transform with a rotation transformation.
|
void |
rotate(double cosA,
double sinA,
double x0,
double y0)
Multiplies the transform with a rotation transformation.
|
void |
scale(double s)
Multiplies this transform with a scaling transformation.
|
void |
scale(double sx,
double sy)
Multiplies this transform with a scaling transformation.
|
java.lang.String |
toString() |
void |
translate(double tx,
double ty)
Multiplies the transform with a translation transformation.
|
public double xx
public double yx
public double tx
public double xy
public double yy
public double ty
public Transform(double xx, double yx, double tx, double xy, double yy, double ty)
xx
- The X coordinate scaling element M1,1 of the transform matrix.yx
- The X coordinate scaling element M1,2 of the transform matrix.tx
- The X coordinate scaling element M1,3 of the transform matrix.xy
- The Y coordinate scaling element M2,1 of the transform matrix.yy
- The Y coordinate scaling element M2,2 of the transform matrix.ty
- The Y coordinate scaling element M2,3 of the transform matrix.public Transform()
public Transform(Transform other)
other
- copied object.public final boolean isNear(Transform other)
other
- the compared object.true
if transforms are close to equal, false
otherwise/public final void invert()
java.lang.IllegalStateException
- when transform is not invertiblepublic final void multiply(Transform other)
other
- the right hand side operand.public final void multiply(double xx, double yx, double tx, double xy, double yy, double ty)
xx
- The right hand transform side X coordinate scaling element M1,1.yx
- The right hand transform side X coordinate scaling element M1,2.tx
- The right hand transform side X coordinate scaling element M1,3.xy
- The right hand transform side Y coordinate scaling element M2,1.yy
- The right hand transform side Y coordinate scaling element M2,2.ty
- The right hand transform side Y coordinate scaling element M2,3.public final void translate(double tx, double ty)
multiply(T)
, where T
is a Transform
represented by the following matrix:
[ 1 0 tx ] [ 0 1 ty ] [ 0 0 1 ]
tx
- the translation offset along the x axis.ty
- the translation offset along the y axis.public final void scale(double s)
multiply(S)
, where S
is a Transform
represented by the
following matrix:
[ s 0 0 ] [ 0 s 0 ] [ 0 0 1 ]
s
- the scaling factor.public final void scale(double sx, double sy)
multiply(S)
, where S
is a Transform
represented by the
following matrix:
[ sx 0 0 ] [ 0 sy 0 ] [ 0 0 1 ]
sx
- the scaling factor along the x axis.sy
- the scaling factor along the y axis.public final void rotate(double a)
multiply(R)
, where R
is a Transform
represented by the
following matrix:
[ cos(a) -sin(a) 0 ] [ sin(a) cos(a) 0 ] [ 0 0 1 ]
a
- the rotation angle in radians.public final void rotate(double a, double x0, double y0)
multiply(R)
, where R
is a Transform
represented by the
following matrix:
[ cos(a) -sin(a) -cos(a) * x0 + sin(a) * y0 + x0 ] [ sin(a) cos(a) -sin(a) * x0 - cos(a) * y0 + y0 ] [ 0 0 1 ]
a
- the rotation angle in radians.x0
- the x position of the origin point.y0
- the y position of the origin point.public final void rotate(double cosA, double sinA)
multiply(R)
, where R
is a Transform
represented by the
following matrix:
[ cosA -sinA 0 ] [ sinA cosA 0 ] [ 0 0 1 ]
cosA
- the cosine of rotation angle in radians.sinA
- the sinus of rotation angle in radians.public final void rotate(double cosA, double sinA, double x0, double y0)
multiply(R)
, where R
is a Transform
represented by the
following matrix:
[ cosA -sinA -cosA * x0 + sinA * y0 + x0 ] [ sinA cosA -sinA * x0 - cosA * y0 + y0 ] [ 0 0 1 ]
cosA
- the cosine of rotation angle in radians.sinA
- the sinus of rotation angle in radians.x0
- the x position of the origin point.y0
- the y position of the origin point.public final Point apply(float x, float y)
x
- the point x coordinate.y
- the point y coordinate.public final void apply(Point p)
p
- the point.public final void apply(Point[] points)
points
- an array of points.public final void apply(Point[] points, int offset, int count)
points
- an array of points.offset
- the offset in the array, to start transforming from.count
- the number of items to transform.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String toString()
toString
in class java.lang.Object