public final class Transform extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static Transform |
IDENTITY
The identity transformation, maps any vector to itself and therefore
"does nothing".
|
Constructor and Description |
---|
Transform()
Constructs an identity transformation.
|
Transform(float a00,
float a01,
float a02,
float a10,
float a11,
float a12,
float a20,
float a21,
float a22)
Constructs a new transformation from a 3x3 matrix of the following format:
|
Transform(Transform t)
Constructs a new transformation by copying another transformation.
|
Modifier and Type | Method and Description |
---|---|
static Transform |
combine(Transform t1,
Transform t2)
Combines two transformation matrices by multiplying them.
|
boolean |
equals(Object o) |
Transform |
getInverse()
Returns the inverse transformation.
|
float[] |
getMatrix()
Gets a copy of the underlying 4x4 3D transformation matrix.
|
int |
hashCode() |
static Transform |
rotate(Transform t,
float angle)
Adds a rotation around the origin to a transformation.
|
static Transform |
rotate(Transform t,
float angle,
float centerX,
float centerY)
Adds a rotation around an arbitrary center to this transformation.
|
static Transform |
rotate(Transform t,
float angle,
Vector2f center)
Adds a rotation around an arbitrary center to this transformation.
|
static Transform |
scale(Transform t,
float scaleX,
float scaleY)
Adds a scaling operation from the origin to a transformation.
|
static Transform |
scale(Transform t,
float scaleX,
float scaleY,
float centerX,
float centerY)
Adds a scaling operation from an arbitrary center to a transformation.
|
static Transform |
scale(Transform t,
Vector2f factors)
Adds a scaling operation from the origin to a transformation.
|
static Transform |
scale(Transform t,
Vector2f factors,
Vector2f center)
Adds a scaling operation from an arbitrary center to a transformation.
|
String |
toString() |
Vector2f |
transformPoint(float x,
float y)
Transforms a 2D point using the transformation matrix.
|
Vector2f |
transformPoint(Vector2f v)
Transforms a 2D point using the transformation matrix.
|
FloatRect |
transformRect(FloatRect rectangle)
Transforms a rectangle and returns the axis-aligned bounding rectangle.
|
static Transform |
translate(Transform t,
float x,
float y)
Adds a translation by a 2D vector to a transformation.
|
static Transform |
translate(Transform t,
Vector2f v)
Adds a translation by a 2D vector to a transformation.
|
public static final Transform IDENTITY
public Transform()
public Transform(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22)
a00, a01, a02, a10, a11, a12, a20, a21, a22
a00
- Matrix component.a01
- Matrix component.a02
- Matrix component.a10
- Matrix component.a11
- Matrix component.a12
- Matrix component.a20
- Matrix component.a21
- Matrix component.a22
- Matrix component.public Transform(Transform t)
t
- the transformation to copy.public static Transform combine(Transform t1, Transform t2)
t1
- the first transformation matrix.t2
- the second transformation matrix.public static Transform translate(Transform t, float x, float y)
t
- the transformation to apply the translation on.x
- the X coordinate of the translation vector.y
- the Y coordinate of the translation vector.public static Transform translate(Transform t, Vector2f v)
t
- the transformation to apply the translation to.v
- the translation vector.public static Transform rotate(Transform t, float angle)
t
- the transformation to apply the rotation on.angle
- the rotation angle in degrees.public static Transform rotate(Transform t, float angle, float centerX, float centerY)
t
- the transformation to apply the rotation on.angle
- the rotation angle in degrees.centerX
- the X coordinate of the rotation center.centerY
- the Y coordinate of the rotation center.public static Transform rotate(Transform t, float angle, Vector2f center)
t
- the transformation to apply the rotation on.angle
- the rotation angle in degrees.center
- the rotation center.public static Transform scale(Transform t, float scaleX, float scaleY)
t
- the transform to apply the scaling on.scaleX
- the X factor of the scaling operation.scaleY
- the Y factor of the scaling operation.public static Transform scale(Transform t, Vector2f factors)
t
- the transform to apply the scaling on.factors
- the factors of the scaling operation.public static Transform scale(Transform t, float scaleX, float scaleY, float centerX, float centerY)
t
- the transform to apply the scaling on.scaleX
- the X factor of the scaling operation.scaleY
- the Y factor of the scaling operation.centerX
- the X coordinate of the scaling center.centerY
- the Y coordinate of the scaling center.public static Transform scale(Transform t, Vector2f factors, Vector2f center)
t
- the transform to apply the scaling on.factors
- the factors of the scaling operation.center
- the scaling center.public float[] getMatrix()
public Transform getInverse()
public Vector2f transformPoint(float x, float y)
x
- the X coordinate of the point.y
- the Y coordinate of the point.public final Vector2f transformPoint(Vector2f v)
v
- the point to transform.public FloatRect transformRect(FloatRect rectangle)
rectangle
- the rectangle to transform.