Class Transformation2D

java.lang.Object
com.esri.core.geometry.Transformation2D

public final class Transformation2D extends Object
The affine transformation class for 2D. Vector is a row:
|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:
v' = v * M1 * M2 * M3 = ( (v * M1) * M2 ) * M3, where v is a vector, Mn are the matrices.
This is equivalent to the following line of code:
ResultVector = (M1.mul(M2).mul(M3)).transform(Vector)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
    X translation component of the transformation.
    double
    Matrix coefficient XX of the transformation.
    double
    Matrix coefficient XY of the transformation.
    double
    Y translation component of the transformation.
    double
    Matrix coefficient YX of the transformation.
    double
    Matrix coefficient YY of the transformation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a 2D affine transformation with identity transformation.
    Transformation2D(double scale)
    Creates a 2D affine transformation with a specified scale.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    long
     
    void
    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
    Returns the hash code for the 2D transformation.
    (package private) void
    initializeFromCurveParameters(Point2D Position, Point2D Tangent, double Offset)
    Initializes transformation from Position, Tangent vector and offset value.
    (package private) void
    Initialize transformation from two rectangles.
    (package private) void
    Initializes an orhtonormal transformation from the Src and Dest rectangles.
    void
    Inverses the matrix.
    void
    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
    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
    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
    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
    Multiplies this matrix on the left with the "left" matrix.
    void
    Multiplies this matrix on the right with the "right" matrix.
    static void
    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
    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.
    (package private) void
    setRotate(double cosA, double sinA, Point2D rotationCenter)
    Sets this transformation to be a rotation around point rotationCenter.
    (package private) void
    setRotate(double angle_in_Radians, Point2D rotationCenter)
    Sets this transformation to be a rotation around point rotationCenter.
    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.
    (package private) Transformation2D
    Produces a transformation that swaps x and y coordinate values.
    void
    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.
    (package private) void
    Transforms envelope
    void
    transform(Point[] pointsIn, int count, Point[] pointsOut)
    Transforms an array of points.
    (package private) void
    transform(Point2D[] points, int start, int count)
     
    (package private) void
    transform(Point2D[] pointsIn, Point2D[] pointsOut)
     
    (package private) void
    transform(Point2D psrc, Point2D pdst)
     
    (package private) Point2D
    Transforms size.
    (package private) Point2D
     
    (package private) void
    transformWithoutShift(Point2D[] pointsIn, int from, int count, Point2D[] pointsOut)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • xx

      public double xx
      Matrix coefficient XX of the transformation.
    • xy

      public double xy
      Matrix coefficient XY of the transformation.
    • xd

      public double xd
      X translation component of the transformation.
    • yx

      public double yx
      Matrix coefficient YX of the transformation.
    • yy

      public double yy
      Matrix coefficient YY of the transformation.
    • yd

      public double yd
      Y translation component of the transformation.
  • Constructor Details

    • Transformation2D

      public Transformation2D()
      Creates a 2D affine transformation with identity transformation.
    • Transformation2D

      public Transformation2D(double scale)
      Creates a 2D affine transformation with a specified scale.
      Parameters:
      scale - The scale to use for the transformation.
  • Method Details

    • setZero

      public void setZero()
      Initializes a zero transformation. Transforms any coordinate to (0, 0).
    • transform

      void transform(Point2D psrc, Point2D pdst)
    • equals

      public boolean equals(Object other)
      Returns True when all members of this transformation are equal to the corresponding members of the other.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns the hash code for the 2D transformation.
      Overrides:
      hashCode in class Object
    • transform

      void transform(Point2D[] points, int start, int count)
    • transform

      public void transform(Point[] pointsIn, int count, Point[] pointsOut)
      Transforms an array of points.
      Parameters:
      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.
    • transform

      public void transform(double[] pointsXYInterleaved, int start, int count)
      Transforms an array of points stored in an array of doubles as interleaved XY coordinates.
      Parameters:
      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).
    • multiply

      public void multiply(Transformation2D right)
      Multiplies this matrix on the right with the "right" matrix. Stores the result into this matrix and returns a reference to it.
      Equivalent to this *= right.
      Parameters:
      right - The matrix to be multiplied with.
    • mulLeft

      public void mulLeft(Transformation2D left)
      Multiplies this matrix on the left with the "left" matrix. Stores the result into this matrix and returns a reference to it.
      Equivalent to this = left * this.
      Parameters:
      left - The matrix to be multiplied with.
    • multiply

      public static void multiply(Transformation2D a, Transformation2D b, Transformation2D result)
      Performs multiplication of matrices a and b and places the result into this matrix. The a, b, and result could point to same objects.
      Equivalent to result = a * b.
      Parameters:
      a - The 2D transformation to be multiplied.
      b - The 2D transformation to be multiplied.
      result - The 2D transformation created by multiplication of matrices.
    • copy

      public Transformation2D copy()
      Returns a copy of the Transformation2D object.
      Returns:
      A copy of this object.
    • getCoefficients

      public void getCoefficients(double[] coefs)
      Writes the matrix coefficients in the order XX, XY, XD, YX, YY, YD into the given array.
      Parameters:
      coefs - The array into which the coefficients are returned. Should be of size 6 elements.
    • transform

      void transform(Envelope2D env)
      Transforms envelope
      Parameters:
      env - The envelope that is to be transformed
    • transform

      void transform(Point2D[] pointsIn, Point2D[] pointsOut)
    • initializeFromRect

      void initializeFromRect(Envelope2D src, Envelope2D dest)
      Initialize transformation from two rectangles.
    • initializeFromRectIsotropic

      void initializeFromRectIsotropic(Envelope2D src, Envelope2D dest)
      Initializes an orhtonormal transformation from the Src and Dest rectangles. The result transformation proportionally fits the Src into the Dest. The center of the Src will be in the center of the Dest.
    • initializeFromCurveParameters

      void initializeFromCurveParameters(Point2D Position, Point2D Tangent, double Offset)
      Initializes transformation from Position, Tangent vector and offset value. Tangent vector must have unity length
    • transformSize

      Point2D transformSize(Point2D SizeSrc)
      Transforms size. Creates an AABB with width of SizeSrc.x and height of SizeSrc.y. Transforms that AABB and gets a quadrangle in new coordinate system. The result x contains the length of the quadrangle edge, which were parallel to X in the original system, and y contains the length of the edge, that were parallel to the Y axis in the original system.
    • transform

      public double transform(double tolerance)
      Transforms a tolerance value.
      Parameters:
      tolerance - The tolerance value.
    • transformWithoutShift

      void transformWithoutShift(Point2D[] pointsIn, int from, int count, Point2D[] pointsOut)
    • transformWithoutShift

      Point2D transformWithoutShift(Point2D srcPoint)
    • setIdentity

      public void setIdentity()
      Sets this matrix to be the identity matrix.
    • isIdentity

      public boolean isIdentity()
      Returns TRUE if this matrix is the identity matrix.
    • isIdentity

      public boolean isIdentity(double tol)
      Returns TRUE if this matrix is an identity matrix within the given tolerance.
      Parameters:
      tol - The tolerance value.
    • isReflective

      public boolean isReflective()
      Returns TRUE for reflective transformations. It inverts the sign of vector cross product.
    • isUniform

      public boolean isUniform(double eps)
      Returns TRUE if this transformation is a uniform transformation. The uniform transformation is a transformation, which transforms a square to a square.
    • isShift

      public boolean isShift()
      Returns TRUE if this transformation is a shift transformation. The shift transformation performs shift only.
    • isShift

      public boolean isShift(double tol)
      Returns TRUE if this transformation is a shift transformation within the given tolerance.
      Parameters:
      tol - The tolerance value.
    • isOrthonormal

      public boolean isOrthonormal(double tol)
      Returns TRUE if this is an orthonormal transformation with the given tolerance. The orthonormal: Rotation or rotoinversion and shift (preserves lengths of vectors and angles between vectors).
      Parameters:
      tol - The tolerance value.
    • isDegenerate

      public boolean isDegenerate(double tol)
      Returns TRUE if this matrix is degenerated (does not have an inverse) within the given tolerance.
      Parameters:
      tol - The tolerance value.
    • isScaleAndShift

      public boolean isScaleAndShift(double tol)
      Returns TRUE, if this transformation does not have rotation and shear within the given tolerance.
      Parameters:
      tol - The tolerance value.
    • setShift

      public void setShift(double x, double y)
      Set this transformation to be a shift.
      Parameters:
      x - The X coordinate to shift to.
      y - The Y coordinate to shift to.
    • setScale

      public void setScale(double x, double y)
      Set this transformation to be a scale.
      Parameters:
      x - The X coordinate to scale to.
      y - The Y coordinate to scale to.
    • setScale

      public void setScale(double _scale)
      Set transformation to be a uniform scale.
      Parameters:
      _scale - The scale of the transformation.
    • setFlipX

      public void setFlipX(double x0, double x1)
      Sets the transformation to be a flip around the X axis. Flips the X coordinates so that the x0 becomes x1 and vice verse.
      Parameters:
      x0 - The X coordinate to flip.
      x1 - The X coordinate to flip to.
    • setFlipY

      public void setFlipY(double y0, double y1)
      Sets the transformation to be a flip around the Y axis. Flips the Y coordinates so that the y0 becomes y1 and vice verse.
      Parameters:
      y0 - The Y coordinate to flip.
      y1 - The Y coordinate to flip to.
    • setShear

      public void setShear(double proportionX, double proportionY)
      Set transformation to a shear.
      Parameters:
      proportionX - The proportion of shearing in x direction.
      proportionY - The proportion of shearing in y direction.
    • setRotate

      public void setRotate(double angle_in_Radians)
      Sets this transformation to be a rotation around point (0, 0). When the axis Y is directed up and X is directed to the right, the positive angle corresponds to the anti-clockwise rotation. When the axis Y is directed down and X is directed to the right, the positive angle corresponds to the clockwise rotation.
      Parameters:
      angle_in_Radians - The rotation angle in radian.
    • setSwapCoordinates

      Transformation2D setSwapCoordinates()
      Produces a transformation that swaps x and y coordinate values. xx = 0.0; xy = 1.0; xd = 0; yx = 1.0; yy = 0.0; yd = 0;
    • setRotate

      void setRotate(double angle_in_Radians, Point2D rotationCenter)
      Sets this transformation to be a rotation around point rotationCenter. When the axis Y is directed up and X is directed to the right, the positive angle corresponds to the anti-clockwise rotation. When the axis Y is directed down and X is directed to the right, the positive angle corresponds to the clockwise rotation.
      Parameters:
      angle_in_Radians - The rotation angle in radian.
      rotationCenter - The center point of the rotation.
    • setRotate

      public void setRotate(double cosA, double sinA)
      Sets rotation for this transformation. When the axis Y is directed up and X is directed to the right, the positive angle corresponds to the anti-clockwise rotation. When the axis Y is directed down and X is directed to the right, the positive angle corresponds to the clockwise rotation.
      Parameters:
      cosA - The rotation angle.
      sinA - The rotation angle.
    • setRotate

      void setRotate(double cosA, double sinA, Point2D rotationCenter)
      Sets this transformation to be a rotation around point rotationCenter. When the axis Y is directed up and X is directed to the right, the positive angle corresponds to the anti-clockwise rotation. When the axis Y is directed down and X is directed to the right, the positive angle corresponds to the clockwise rotation.
      Parameters:
      cosA - The cos of the rotation angle.
      sinA - The sin of the rotation angle.
      rotationCenter - The center point of the rotation.
    • shift

      public void shift(double x, double y)
      Shifts the transformation.
      Parameters:
      x - The shift factor in X direction.
      y - The shift factor in Y direction.
    • scale

      public void scale(double x, double y)
      Scales the transformation.
      Parameters:
      x - The scale factor in X direction.
      y - The scale factor in Y direction.
    • flipX

      public void flipX(double x0, double x1)
      Flips the transformation around the X axis.
      Parameters:
      x0 - The X coordinate to flip.
      x1 - The X coordinate to flip to.
    • flipY

      public void flipY(double y0, double y1)
      Flips the transformation around the Y axis.
      Parameters:
      y0 - The Y coordinate to flip.
      y1 - The Y coordinate to flip to.
    • shear

      public void shear(double proportionX, double proportionY)
      Shears the transformation.
      Parameters:
      proportionX - The proportion of shearing in x direction.
      proportionY - The proportion of shearing in y direction.
    • rotate

      public void rotate(double angle_in_Radians)
      Rotates the transformation.
      Parameters:
      angle_in_Radians - The rotation angle in radian.
    • rotate

      public void rotate(double cos, double sin)
      Rotates the transformation.
      Parameters:
      cos - The cos angle of the rotation.
      sin - The sin angle of the rotation.
    • rotate

      public void rotate(double cos, double sin, Point2D rotationCenter)
      Rotates the transformation aroung a center point.
      Parameters:
      cos - The cos angle of the rotation.
      sin - sin angle of the rotation.
      rotationCenter - The center point of the rotation.
    • inverse

      public void inverse(Transformation2D inverse)
      Produces inverse matrix for this matrix and puts result into the inverse parameter.
      Parameters:
      inverse - The result inverse matrix.
    • inverse

      public void inverse()
      Inverses the matrix.
    • extractScaleTransform

      public void extractScaleTransform(Transformation2D scale, Transformation2D rotateNshearNshift)
      Extracts scaling part of the transformation. this == scale * rotateNshearNshift.
      Parameters:
      scale - The destination matrix where the scale part is copied.
      rotateNshearNshift - The destination matrix where the part excluding rotation is copied.
    • estimateMemorySize

      public long estimateMemorySize()