Package ch.epfl.cs107.play.math
Class Transform
java.lang.Object
ch.epfl.cs107.play.math.Transform
- All Implemented Interfaces:
Serializable
Represents an immutable 2D affine transformation.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTransform(float m00, float m01, float m02, float m10, float m11, float m12) Creates a new transform. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfloatgetAngle()getX()getY()inthashCode()inverted()onPoint(float x, float y) Transforms point.Transforms point.onVector(float x, float y) Transforms vector.Transforms vector.rotated(float a) Appends rotation around origin (applied after this transform).Appends rotation around specified point (applied after this transform).scaled(float s) Appends scale (applied after this transform).scaled(float sx, float sy) Appends scale (applied after this transform).toString()Appends another transform (applied after this transform).translated(float dx, float dy) Appends translation (applied after this transform).translated(Vector d) Appends translation (applied after this transform).
-
Field Details
-
I
The identity transform -
m00
public final float m00X scale -
m01
public final float m01X shear -
m02
public final float m02X translation -
m10
public final float m10Y shear -
m11
public final float m11Y scale -
m12
public final float m12Y translation
-
-
Constructor Details
-
Transform
public Transform(float m00, float m01, float m02, float m10, float m11, float m12) Creates a new transform.- Parameters:
m00- (float): X scalem01- (float): X shearm02- (float): X translationm10- (float): Y shearm11- (float): Y scalem12- (float): Y translate
-
-
Method Details
-
getX
- Returns:
- (Vector): X-axis, not null
-
getY
- Returns:
- (Vector): Y-axis, not null
-
getOrigin
- Returns:
- (Vector): translation vector, not null
-
getAngle
public float getAngle()- Returns:
- (float): angle, in radians
-
onPoint
Transforms point.- Parameters:
x- (float): abcissay- (float): ordinate- Returns:
- (Vector): transformed point, not null
-
onPoint
Transforms point.- Parameters:
p- (Vector): point, not null- Returns:
- (Vector): transformed point, not null
-
onVector
Transforms vector.- Parameters:
x- (float): abcissay- (float): ordinate- Returns:
- (Vector): transformed vector, not null
-
onVector
Transforms vector.- Parameters:
v- (Vector): point, not null- Returns:
- (Vector): transformed vector, not null
-
transformed
Appends another transform (applied after this transform).- Parameters:
t- (Transform): transform, not null- Returns:
- (Transform): extended transform, not null
-
translated
Appends translation (applied after this transform).- Parameters:
dx- (float): X translationdy- (float): Y translation- Returns:
- (Transform): extended transform, not null
-
translated
Appends translation (applied after this transform).- Parameters:
d- (Vector): translation, not null- Returns:
- (Transform): extended transform, not null
-
scaled
Appends scale (applied after this transform).- Parameters:
sx- (float) X scalesy- (float) Y scale- Returns:
- (Transform): extended transform, not null
-
scaled
Appends scale (applied after this transform).- Parameters:
s- (float): scale- Returns:
- (Transform): extended transform, not null
-
rotated
Appends rotation around origin (applied after this transform).- Parameters:
a- (float): angle, in radians- Returns:
- (Transform): extended transform, not null
-
rotated
Appends rotation around specified point (applied after this transform).- Parameters:
a- (float): angle, in radianscenter- (Vector): rotation axis, not null- Returns:
- (Transform): extended transform, not null
-
inverted
- Returns:
- (Transform): transform inverse, not null
-
hashCode
public int hashCode() -
equals
-
toString
-
getAffineTransform
- Returns:
- (AffineTransform): AWT affine transform equivalent, not null
-