Class Transform

java.lang.Object
ch.epfl.cs107.play.math.Transform
All Implemented Interfaces:
Serializable

public final class Transform extends Object implements Serializable
Represents an immutable 2D affine transformation.
See Also:
  • Field Details

    • I

      public static final Transform I
      The identity transform
    • m00

      public final double m00
      X scale
    • m01

      public final double m01
      X shear
    • m02

      public final double m02
      X translation
    • m10

      public final double m10
      Y shear
    • m11

      public final double m11
      Y scale
    • m12

      public final double m12
      Y translation
  • Constructor Details

    • Transform

      public Transform(double m00, double m01, double m02, double m10, double m11, double m12)
      Creates a new transform.
      Parameters:
      m00 - (double): X scale
      m01 - (double): X shear
      m02 - (double): X translation
      m10 - (double): Y shear
      m11 - (double): Y scale
      m12 - (double): Y translate
  • Method Details

    • getX

      public Vector getX()
      Returns:
      (Vector): X-axis, not null
    • getY

      public Vector getY()
      Returns:
      (Vector): Y-axis, not null
    • getOrigin

      public Vector getOrigin()
      Returns:
      (Vector): translation vector, not null
    • getAngle

      public double getAngle()
      Returns:
      (double): angle, in radians
    • onPoint

      public Vector onPoint(double x, double y)
      Transforms point.
      Parameters:
      x - (double): abcissa
      y - (double): ordinate
      Returns:
      (Vector): transformed point, not null
    • onPoint

      public Vector onPoint(Vector p)
      Transforms point.
      Parameters:
      p - (Vector): point, not null
      Returns:
      (Vector): transformed point, not null
    • onVector

      public Vector onVector(double x, double y)
      Transforms vector.
      Parameters:
      x - (double): abcissa
      y - (double): ordinate
      Returns:
      (Vector): transformed vector, not null
    • onVector

      public Vector onVector(Vector v)
      Transforms vector.
      Parameters:
      v - (Vector): point, not null
      Returns:
      (Vector): transformed vector, not null
    • transformed

      public Transform transformed(Transform t)
      Appends another transform (applied after this transform).
      Parameters:
      t - (Transform): transform, not null
      Returns:
      (Transform): extended transform, not null
    • translated

      public Transform translated(double dx, double dy)
      Appends translation (applied after this transform).
      Parameters:
      dx - (double): X translation
      dy - (double): Y translation
      Returns:
      (Transform): extended transform, not null
    • translated

      public Transform translated(Vector d)
      Appends translation (applied after this transform).
      Parameters:
      d - (Vector): translation, not null
      Returns:
      (Transform): extended transform, not null
    • scaled

      public Transform scaled(double sx, double sy)
      Appends scale (applied after this transform).
      Parameters:
      sx - (double) X scale
      sy - (double) Y scale
      Returns:
      (Transform): extended transform, not null
    • scaled

      public Transform scaled(double s)
      Appends scale (applied after this transform).
      Parameters:
      s - (double): scale
      Returns:
      (Transform): extended transform, not null
    • rotated

      public Transform rotated(double a)
      Appends rotation around origin (applied after this transform).
      Parameters:
      a - (double): angle, in radians
      Returns:
      (Transform): extended transform, not null
    • rotated

      public Transform rotated(double a, Vector center)
      Appends rotation around specified point (applied after this transform).
      Parameters:
      a - (double): angle, in radians
      center - (Vector): rotation axis, not null
      Returns:
      (Transform): extended transform, not null
    • inverted

      public Transform inverted()
      Returns:
      (Transform): transform inverse, not null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAffineTransform

      public AffineTransform getAffineTransform()
      Returns:
      (AffineTransform): AWT affine transform equivalent, not null