com.mapinfo.midev.geometry

## Class AffineTransform

- java.lang.Object
- - com.mapinfo.midev.geometry.AffineTransform

All Implemented Interfaces:
  IDirectPositionMutator, Serializable

    public final class AffineTransform
    extends Object
    implements IDirectPositionMutator, Serializable

Represents a 2D affine transform that performs a linear mapping from 2D coordinates to other 2D coordinates that preserves the "straightness" and "parallelness" of lines.

See Also:
  Serialized Form

### Field Summary

Fields
`static AffineTransform` `IDENTITY`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`AffineTransform` `createInverse()` Create a transform that is the inverse of this transform.
`boolean` `equals(Object o)`
`void` `getColumnFirstCoefficients(double[] coefficients)` Get the six coefficients for this transformation.
`static AffineTransform` `getColumnFirstInstance(double m00, double m10, double m01, double m11, double m02, double m12)` Create a new affine transform by specifying the six parameters in column-first order.
`static AffineTransform` `getInstance()` Get an instance of the identity transformation.
`static AffineTransform` `getInstance(AffineTransform t1, AffineTransform t2)` Construct a transform by combining two other transforms.
`static AffineTransform` `getRotateInstanceCCW(double theta)` Get an instance of an affine transform that will rotate a coordinate counter-clockwise about the origin.
`static AffineTransform` `getRotateInstanceCCW(double theta, double x, double y)` Get an instance of an affine transform that will rotate a coordinate counter-clockwise about a specified location.
`static AffineTransform` `getRotateInstanceCW(double theta)` Get an instance of an affine transform that will rotate a coordinate clockwise about the origin.
`static AffineTransform` `getRotateInstanceCW(double theta, double x, double y)` Get an instance of an affine transform that will rotate a coordinate clockwise about a specified location.
`void` `getRowFirstCoefficients(double[] coefficients)` Get the six coefficients for this transformation.
`static AffineTransform` `getRowFirstInstance(double a, double c, double e, double f)` Create a new linear affine transform by specifying the four parameters in row-first order.
`static AffineTransform` `getRowFirstInstance(double a, double b, double c, double d, double e, double f)` Create a new affine transform by specifying the six parameters in row-first order.
`static AffineTransform` `getScaleInstance(double sx, double sy)` Get an instance of an affine transform that will scale a coordinate.
`double` `getScaleX()` Get the horizontal scale specified by this transformation.
`double` `getScaleY()` Get the vertical scale specified by this transformation.
`static AffineTransform` `getShearInstance(double shx, double shy)` Get an instance of an affine transform that will shear a coordinate.
`double` `getShearX()` Get the horizontal shear specified by this transformation.
`double` `getShearY()` Get the vertical shear specified by this transformation.
`static AffineTransform` `getTranslateInstance(double tx, double ty)` Get an instance of an affine transform that will translate a coordinate.
`double` `getTranslateX()` Get the horizontal translation specified by this transformation.
`double` `getTranslateY()` Get the vertical translation specified by this transformation.
`int` `hashCode()`
`boolean` `isIdentity()` Determine whether or not this transformation is an identity transformation.
`boolean` `isLinear()` Determine whether or not this transformation is linear.
`AffineTransform` `rotateCCW(double theta)` Get an instance of an affine transform that will rotate a coordinate about the origin counter-clockwise in addition to the transformation already specified.
`AffineTransform` `rotateCCW(double theta, double x, double y)` Get an instance of an affine transform that will rotate a coordinate about a specified location counter-clockwise in addition to the transformation already specified.
`AffineTransform` `rotateCW(double theta)` Get an instance of an affine transform that will rotate a coordinate about the origin in addition to the transformation already specified.
`AffineTransform` `rotateCW(double theta, double x, double y)` Get an instance of an affine transform that will rotate a coordinate about a specified location in addition to the transformation already specified.
`AffineTransform` `scale(double sx, double sy)` Get an instance of an affine transform that will scale a coordinate in addition to the transformation already specified.
`AffineTransform` `shear(double shx, double shy)` Get an instance of an affine transform that will shear a coordinate in addition to the transformation already specified.
`DirectPosition` `transform(DirectPosition source, DirectPosition destination)` Transform the specified point according to the coefficients in this transform.
`AffineTransform` `translate(double tx, double ty)` Get an instance of an affine transform that will translate a coordinate in addition to the transformation already specified.

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### IDENTITY

    public static final AffineTransform IDENTITY

### Method Detail

#### getInstance

    public static AffineTransform getInstance()

Get an instance of the identity transformation.

Returns:
  An instance of the identity transformation.

#### getInstance

    public static AffineTransform getInstance(AffineTransform t1,
                                              AffineTransform t2)

Construct a transform by combining two other transforms. The effect of the new transform is to apply t1 first, and then t2, like this:

t2.transform(t1.transform(point, ...))

#### getColumnFirstInstance

    public static AffineTransform getColumnFirstInstance(double m00,
                                                         double m10,
                                                         double m01,
                                                         double m11,
                                                         double m02,
                                                         double m12)

Create a new affine transform by specifying the six parameters in column-first order.

Parameters:
  `m00` - The horizontal scale specified by this transformation.
  `m10` - The vertical shear specified by this transformation.
  `m01` - The horizontal shear specified by this transformation.
  `m11` - The vertical scale specified by this transformation.
  `m02` - The horizontal translation specified by this transformation.
  `m12` - The vertical translation specified by this transformation.
Returns:
  The new affine transform.

#### getRowFirstInstance

    public static AffineTransform getRowFirstInstance(double a,
                                                      double b,
                                                      double c,
                                                      double d,
                                                      double e,
                                                      double f)

Create a new affine transform by specifying the six parameters in row-first order.

Parameters:
  `a` - The horizontal scale specified by this transformation.
  `b` - The horizontal shear specified by this transformation.
  `c` - The horizontal translation specified by this transformation.
  `d` - The vertical shear specified by this transformation.
  `e` - The vertical scale specified by this transformation.
  `f` - The vertical translation specified by this transformation.
Returns:
  The new affine transform.

#### getRowFirstInstance

    public static AffineTransform getRowFirstInstance(double a,
                                                      double c,
                                                      double e,
                                                      double f)

Create a new linear affine transform by specifying the four parameters in row-first order.

Parameters:
  `a` - The horizontal scale specified by this transformation.
  `c` - The horizontal translation specified by this transformation.
  `e` - The vertical scale specified by this transformation.
  `f` - The vertical translation specified by this transformation.
Returns:
  The new affine transform.

#### getRotateInstanceCW

    public static AffineTransform getRotateInstanceCW(double theta)

Get an instance of an affine transform that will rotate a coordinate clockwise about the origin.

Parameters:
  `theta` - The degree of rotation clockwise about the origin (in radians).
Returns:
  An instance of an affine transform that will rotate a coordinate about the origin.

#### getRotateInstanceCCW

    public static AffineTransform getRotateInstanceCCW(double theta)

Get an instance of an affine transform that will rotate a coordinate counter-clockwise about the origin.

Parameters:
  `theta` - The degree of rotation clockwise about the origin (in radians).
Returns:
  An instance of an affine transform that will rotate a coordinate about the origin.

#### getRotateInstanceCW

    public static AffineTransform getRotateInstanceCW(double theta,
                                                      double x,
                                                      double y)

Get an instance of an affine transform that will rotate a coordinate clockwise about a specified location.

Parameters:
  `theta` - The degree of rotation clockwise about the point specified (in radians).
  `x` - The x coordinate of the location to be rotated about.
  `y` - The y coordinate of the location to be rotated about.
Returns:
  An instance of an affine transform that will rotate a coordinate about a specified location.

#### getRotateInstanceCCW

    public static AffineTransform getRotateInstanceCCW(double theta,
                                                       double x,
                                                       double y)

Get an instance of an affine transform that will rotate a coordinate counter-clockwise about a specified location.

Parameters:
  `theta` - The degree of rotation counter-clockwise about the point specified (in radians).
  `x` - The x coordinate of the location to be rotated about.
  `y` - The y coordinate of the location to be rotated about.
Returns:
  An instance of an affine transform that will rotate a coordinate about a specified location.

#### getScaleInstance

    public static AffineTransform getScaleInstance(double sx,
                                                   double sy)

Get an instance of an affine transform that will scale a coordinate.

Parameters:
  `sx` - The factor by which coordinates are scaled along the X axis direction.
  `sy` - The factor by which coordinates are scaled along the Y axis direction.
Returns:
  An instance of an affine transform that will scale a coordinate.

#### getShearInstance

    public static AffineTransform getShearInstance(double shx,
                                                   double shy)

Get an instance of an affine transform that will shear a coordinate.

Parameters:
  `shx` - The factor by which coordinates are sheared along the X axis direction.
  `shy` - The factor by which coordinates are sheared along the Y axis direction.
Returns:
  An instance of an affine transform that will shear a coordinate.

#### getTranslateInstance

    public static AffineTransform getTranslateInstance(double tx,
                                                       double ty)

Get an instance of an affine transform that will translate a coordinate.

Parameters:
  `tx` - The factor by which coordinates are translated along the X axis direction.
  `ty` - The factor by which coordinates are translated along the Y axis direction.
Returns:
  An instance of an affine transform that will translate a coordinate.

#### rotateCW

    public AffineTransform rotateCW(double theta)

Get an instance of an affine transform that will rotate a coordinate about the origin in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

Parameters:
  `theta` - The degree of rotation clockwise about the origin (in radians).
Returns:
  An instance of an affine transform that will rotate a coordinate about the origin in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

#### rotateCW

    public AffineTransform rotateCW(double theta,
                                    double x,
                                    double y)

Get an instance of an affine transform that will rotate a coordinate about a specified location in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

Parameters:
  `theta` - The degree of rotation clockwise about the origin (in radians).
  `x` - The x coordinate of the location to be rotated about.
  `y` - The y coordinate of the location to be rotated about.
Returns:
  An instance of an affine transform that will rotate a coordinate about a specified location in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

#### rotateCCW

    public AffineTransform rotateCCW(double theta)

Get an instance of an affine transform that will rotate a coordinate about the origin counter-clockwise in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

Parameters:
  `theta` - The degree of rotation counter-clockwise about the origin (in radians).
Returns:
  An instance of an affine transform that will rotate a coordinate about the origin in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

#### rotateCCW

    public AffineTransform rotateCCW(double theta,
                                     double x,
                                     double y)

Get an instance of an affine transform that will rotate a coordinate about a specified location counter-clockwise in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

Parameters:
  `theta` - The degree of rotation counter-clockwise about the origin (in radians).
  `x` - The x coordinate of the location to be rotated about.
  `y` - The y coordinate of the location to be rotated about.
Returns:
  An instance of an affine transform that will rotate a coordinate about a specified location in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

#### scale

    public AffineTransform scale(double sx,
                                 double sy)

Get an instance of an affine transform that will scale a coordinate in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

Parameters:
  `sx` - The factor by which coordinates are scaled along the X axis direction.
  `sy` - The factor by which coordinates are scaled along the Y axis direction.
Returns:
  An instance of an affine transform that will scale a coordinate in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

#### shear

    public AffineTransform shear(double shx,
                                 double shy)

Get an instance of an affine transform that will shear a coordinate in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

Parameters:
  `shx` - The factor by which coordinates are sheared along the X axis direction.
  `shy` - The factor by which coordinates are sheared along the Y axis direction.
Returns:
  An instance of an affine transform that will shear a coordinate in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

#### translate

    public AffineTransform translate(double tx,
                                     double ty)

Get an instance of an affine transform that will translate a coordinate in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

Parameters:
  `tx` - The factor by which coordinates are translated along the X axis direction.
  `ty` - The factor by which coordinates are translated along the Y axis direction.
Returns:
  An instance of an affine transform that will translate a coordinate in addition to the transformation already specified. Note that a copy is returned and the original transform is not modified.

#### getScaleX

    public double getScaleX()

Get the horizontal scale specified by this transformation. This is equivalent to the "a" parameter in a row-first instance or the "m00" parameter in the column-first instance.

Returns:
  The horizontal scale specified by this transformation.

#### getScaleY

    public double getScaleY()

Get the vertical scale specified by this transformation. This is equivalent to the "e" parameter in a row-first instance or the "m11" parameter in the column-first instance.

Returns:
  The vertical scale specified by this transformation.

#### getShearX

    public double getShearX()

Get the horizontal shear specified by this transformation. This is equivalent to the "b" parameter in a row-first instance or the "m01" parameter in the column-first instance.

Returns:
  The horizontal shear specified by this transformation.

#### getShearY

    public double getShearY()

Get the vertical shear specified by this transformation. This is equivalent to the "d" parameter in a row-first instance or the "m10" parameter in the column-first instance.

Returns:
  The vertical shear specified by this transformation.

#### getTranslateX

    public double getTranslateX()

Get the horizontal translation specified by this transformation. This is equivalent to the "c" parameter in a row-first instance or the "m02" parameter in the column-first instance.

Returns:
  The horizontal translation specified by this transformation.

#### getTranslateY

    public double getTranslateY()

Get the vertical translation specified by this transformation. This is equivalent to the "f" parameter in a row-first instance or the "m12" parameter in the column-first instance.

Returns:
  The vertical translation specified by this transformation.

#### isIdentity

    public boolean isIdentity()

Determine whether or not this transformation is an identity transformation.

Returns:
  true if this transformation is an identity transformation; false otherwise.

#### isLinear

    public boolean isLinear()

Determine whether or not this transformation is linear.

Returns:
  true if this transformation is linear; false otherwise.

#### getColumnFirstCoefficients

    public void getColumnFirstCoefficients(double[] coefficients)

Get the six coefficients for this transformation.

Parameters:
  `coefficients` - The six coefficients for this transformation ([a, d, b, e, c f]).

#### getRowFirstCoefficients

    public void getRowFirstCoefficients(double[] coefficients)

Get the six coefficients for this transformation.

Parameters:
  `coefficients` - The six coefficients for this transformation ([a, b, c, d, e f]).

#### createInverse

    public AffineTransform createInverse()

Create a transform that is the inverse of this transform.

Returns:
  The inverse of this transform.
Throws:
  `NonInvertibleAffineTransformException` - if this transform is not invertible.

#### transform

    public DirectPosition transform(DirectPosition source,
                                    DirectPosition destination)

Transform the specified point according to the coefficients in this transform.

Specified by:
  `transform` in interface `IDirectPositionMutator`
Parameters:
  `source` - Transform this point.
  `destination` - The resulting point.
Returns:
  The transformed point.

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`