pythagoras.d

## Class AffineTransform

• All Implemented Interfaces:
Transform

```public class AffineTransform
extends AbstractTransform```
Implements an affine (3x2 matrix) transform. The transformation matrix has the form:
``````
[ m00, m10, tx ]
[ m01, m11, ty ]
[   0,   0,  1 ]
``````
• ### Field Summary

Fields
Modifier and Type Field and Description
`static int` `GENERALITY`
Identifies the affine transform in `generality()`.
`double` `m00`
The scale, rotation and shear components of this transform.
`double` `m01`
The scale, rotation and shear components of this transform.
`double` `m10`
The scale, rotation and shear components of this transform.
`double` `m11`
The scale, rotation and shear components of this transform.
`double` `tx`
The translation components of this transform.
`double` `ty`
The translation components of this transform.
• ### Constructor Summary

Constructors
Constructor and Description
`AffineTransform()`
Creates an affine transform configured with the identity transform.
```AffineTransform(double scale, double angle, double tx, double ty)```
Creates an affine transform from the supplied scale, rotation and translation.
```AffineTransform(double scaleX, double scaleY, double angle, double tx, double ty)```
Creates an affine transform from the supplied scale, rotation and translation.
```AffineTransform(double m00, double m01, double m10, double m11, double tx, double ty)```
Creates an affine transform with the specified transform matrix.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Transform` `concatenate(Transform other)`
Returns a new transform comprised of the concatenation of `other` to this transform (i.e.
`AffineTransform` `copy()`
Returns a copy of this transform.
`int` `generality()`
Returns an integer that increases monotonically with the generality of the transform implementation.
`void` `get(double[] matrix)`
Copies the affine transform matrix into the supplied array.
`Point` ```inverseTransform(IPoint p, Point into)```
Inverse transforms the supplied point, writing the result into `into`.
`Vector` ```inverseTransform(IVector v, Vector into)```
Inverse transforms the supplied vector, writing the result into `into`.
`AffineTransform` `invert()`
Returns a new transform that represents the inverse of this transform.
`Transform` ```lerp(Transform other, double t)```
Returns a new transform comprised of the linear interpolation between this transform and the specified other.
`Transform` `preConcatenate(Transform other)`
Returns a new transform comprised of the concatenation of this transform to `other` (i.e.
`AffineTransform` `rotate(double angle)`
Rotates this transform.
`double` `rotation()`
Returns the rotation applied by this transform.
`AffineTransform` ```scale(double scaleX, double scaleY)```
Scales this transform by the specified amount in the x and y dimensions.
`double` `scaleX()`
Returns the x-component of the scale applied by this transform.
`AffineTransform` `scaleX(double scaleX)`
Scales this transform by the specified amount in the x dimension.
`double` `scaleY()`
Returns the y-component of the scale applied by this transform.
`AffineTransform` `scaleY(double scaleY)`
Scales this transform by the specified amount in the y dimension.
`AffineTransform` `set(AffineTransform other)`
Sets this affine transform matrix to `other`.
`AffineTransform` `setRotation(double angle)`
Sets the rotation component of this transform.
`AffineTransform` `setScaleX(double scaleX)`
Sets the x scale of this transform.
`AffineTransform` `setScaleY(double scaleY)`
Sets the y scale of this transform.
`AffineTransform` ```setTransform(double m00, double m01, double m10, double m11, double tx, double ty)```
Sets the affine transform matrix.
`AffineTransform` ```setTranslation(double tx, double ty)```
Sets the translation component of this transform.
`AffineTransform` `setTx(double tx)`
Sets the x-component of this transform's translation.
`AffineTransform` `setTy(double ty)`
Sets the y-component of this transform's translation.
`AffineTransform` `setUniformScale(double scale)`
Sets the uniform scale of this transform.
`AffineTransform` ```shear(double sx, double sy)```
Shears this transform.
`AffineTransform` `shearX(double sx)`
Shears this transform in the x dimension.
`AffineTransform` `shearY(double sy)`
Shears this transform in the y dimension.
`String` `toString()`
`void` ```transform(double[] src, int srcOff, double[] dst, int dstOff, int count)```
Transforms the supplied points.
`void` ```transform(IPoint[] src, int srcOff, Point[] dst, int dstOff, int count)```
Transforms the supplied points.
`Point` ```transform(IPoint p, Point into)```
Transforms the supplied point, writing the result into `into`.
`Vector` ```transform(IVector v, Vector into)```
Transforms the supplied vector, writing the result into `into`.
`Vector` ```transformPoint(IVector v, Vector into)```
Transforms the supplied vector as a point (accounting for translation), writing the result into `into`.
`AffineTransform` ```translate(double tx, double ty)```
Translates this transform.
`AffineTransform` `translateX(double tx)`
Translates this transform in the x dimension.
`AffineTransform` `translateY(double ty)`
Translates this transform in the y dimension.
`double` `tx()`
Returns the x-coordinate of the translation component.
`double` `ty()`
Returns the y-coordinate of the translation component.
`double` `uniformScale()`
Returns the uniform scale applied by this transform.
`AffineTransform` `uniformScale(double scale)`
Scales this transform in a uniform manner by the specified amount.
• ### Methods inherited from class pythagoras.d.AbstractTransform

`clone, scale, setScale, translation`
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### m00

`public double m00`
The scale, rotation and shear components of this transform.
• #### m01

`public double m01`
The scale, rotation and shear components of this transform.
• #### m10

`public double m10`
The scale, rotation and shear components of this transform.
• #### m11

`public double m11`
The scale, rotation and shear components of this transform.
• #### tx

`public double tx`
The translation components of this transform.
• #### ty

`public double ty`
The translation components of this transform.
• ### Constructor Detail

• #### AffineTransform

`public AffineTransform()`
Creates an affine transform configured with the identity transform.
• #### AffineTransform

```public AffineTransform(double scale,
double angle,
double tx,
double ty)```
Creates an affine transform from the supplied scale, rotation and translation.
• #### AffineTransform

```public AffineTransform(double scaleX,
double scaleY,
double angle,
double tx,
double ty)```
Creates an affine transform from the supplied scale, rotation and translation.
• #### AffineTransform

```public AffineTransform(double m00,
double m01,
double m10,
double m11,
double tx,
double ty)```
Creates an affine transform with the specified transform matrix.
• ### Method Detail

• #### set

`public AffineTransform set(AffineTransform other)`
Sets this affine transform matrix to `other`.
Returns:
this instance, for chaining.
• #### uniformScale

`public double uniformScale()`
Description copied from interface: `Transform`
Returns the uniform scale applied by this transform. The uniform scale will be approximated for non-uniform transforms.
• #### scaleX

`public double scaleX()`
Description copied from interface: `Transform`
Returns the x-component of the scale applied by this transform. Note that this will be extracted and therefore approximate for affine transforms.
• #### scaleY

`public double scaleY()`
Description copied from interface: `Transform`
Returns the y-component of the scale applied by this transform. Note that this will be extracted and therefore approximate for affine transforms.
• #### rotation

`public double rotation()`
Description copied from interface: `Transform`
Returns the rotation applied by this transform. Note that the rotation is extracted and therefore approximate for affine transforms.
• #### tx

`public double tx()`
Description copied from interface: `Transform`
Returns the x-coordinate of the translation component.
• #### ty

`public double ty()`
Description copied from interface: `Transform`
Returns the y-coordinate of the translation component.
• #### get

`public void get(double[] matrix)`
Description copied from interface: `Transform`
Copies the affine transform matrix into the supplied array.
Parameters:
`matrix` - the array which receives `m00, m01, m10, m11, tx, ty`.
• #### setUniformScale

`public AffineTransform setUniformScale(double scale)`
Description copied from interface: `Transform`
Sets the uniform scale of this transform.
Specified by:
`setUniformScale` in interface `Transform`
Overrides:
`setUniformScale` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### setScaleX

`public AffineTransform setScaleX(double scaleX)`
Description copied from interface: `Transform`
Sets the x scale of this transform.
Specified by:
`setScaleX` in interface `Transform`
Overrides:
`setScaleX` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### setScaleY

`public AffineTransform setScaleY(double scaleY)`
Description copied from interface: `Transform`
Sets the y scale of this transform.
Specified by:
`setScaleY` in interface `Transform`
Overrides:
`setScaleY` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### setRotation

`public AffineTransform setRotation(double angle)`
Description copied from interface: `Transform`
Sets the rotation component of this transform.
Specified by:
`setRotation` in interface `Transform`
Overrides:
`setRotation` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### setTranslation

```public AffineTransform setTranslation(double tx,
double ty)```
Description copied from interface: `Transform`
Sets the translation component of this transform.
Specified by:
`setTranslation` in interface `Transform`
Overrides:
`setTranslation` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### setTx

`public AffineTransform setTx(double tx)`
Description copied from interface: `Transform`
Sets the x-component of this transform's translation.
Specified by:
`setTx` in interface `Transform`
Overrides:
`setTx` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### setTy

`public AffineTransform setTy(double ty)`
Description copied from interface: `Transform`
Sets the y-component of this transform's translation.
Specified by:
`setTy` in interface `Transform`
Overrides:
`setTy` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### setTransform

```public AffineTransform setTransform(double m00,
double m01,
double m10,
double m11,
double tx,
double ty)```
Description copied from interface: `Transform`
Sets the affine transform matrix.
Specified by:
`setTransform` in interface `Transform`
Overrides:
`setTransform` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### uniformScale

`public AffineTransform uniformScale(double scale)`
Description copied from interface: `Transform`
Scales this transform in a uniform manner by the specified amount.
Specified by:
`uniformScale` in interface `Transform`
Overrides:
`uniformScale` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### scale

```public AffineTransform scale(double scaleX,
double scaleY)```
Description copied from interface: `Transform`
Scales this transform by the specified amount in the x and y dimensions.
Specified by:
`scale` in interface `Transform`
Overrides:
`scale` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### scaleX

`public AffineTransform scaleX(double scaleX)`
Description copied from interface: `Transform`
Scales this transform by the specified amount in the x dimension.
Specified by:
`scaleX` in interface `Transform`
Overrides:
`scaleX` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### scaleY

`public AffineTransform scaleY(double scaleY)`
Description copied from interface: `Transform`
Scales this transform by the specified amount in the y dimension.
Specified by:
`scaleY` in interface `Transform`
Overrides:
`scaleY` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### rotate

`public AffineTransform rotate(double angle)`
Description copied from interface: `Transform`
Rotates this transform.
Specified by:
`rotate` in interface `Transform`
Overrides:
`rotate` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### translate

```public AffineTransform translate(double tx,
double ty)```
Description copied from interface: `Transform`
Translates this transform.
Specified by:
`translate` in interface `Transform`
Overrides:
`translate` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### translateX

`public AffineTransform translateX(double tx)`
Description copied from interface: `Transform`
Translates this transform in the x dimension.
Specified by:
`translateX` in interface `Transform`
Overrides:
`translateX` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### translateY

`public AffineTransform translateY(double ty)`
Description copied from interface: `Transform`
Translates this transform in the y dimension.
Specified by:
`translateY` in interface `Transform`
Overrides:
`translateY` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### shear

```public AffineTransform shear(double sx,
double sy)```
Description copied from interface: `Transform`
Shears this transform.
Specified by:
`shear` in interface `Transform`
Overrides:
`shear` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### shearX

`public AffineTransform shearX(double sx)`
Description copied from interface: `Transform`
Shears this transform in the x dimension.
Specified by:
`shearX` in interface `Transform`
Overrides:
`shearX` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### shearY

`public AffineTransform shearY(double sy)`
Description copied from interface: `Transform`
Shears this transform in the y dimension.
Specified by:
`shearY` in interface `Transform`
Overrides:
`shearY` in class `AbstractTransform`
Returns:
this instance, for chaining.
• #### invert

`public AffineTransform invert()`
Description copied from interface: `Transform`
Returns a new transform that represents the inverse of this transform.
• #### concatenate

`public Transform concatenate(Transform other)`
Description copied from interface: `Transform`
Returns a new transform comprised of the concatenation of `other` to this transform (i.e. `this x other`).
• #### preConcatenate

`public Transform preConcatenate(Transform other)`
Description copied from interface: `Transform`
Returns a new transform comprised of the concatenation of this transform to `other` (i.e. `other x this`).
• #### lerp

```public Transform lerp(Transform other,
double t)```
Description copied from interface: `Transform`
Returns a new transform comprised of the linear interpolation between this transform and the specified other.
• #### transform

```public Point transform(IPoint p,
Point into)```
Description copied from interface: `Transform`
Transforms the supplied point, writing the result into `into`.
`into` - a point into which to store the result, may be the same object as `p`.
Returns:
`into` for chaining.
• #### transform

```public void transform(IPoint[] src,
int srcOff,
Point[] dst,
int dstOff,
int count)```
Description copied from interface: `Transform`
Transforms the supplied points.
Parameters:
`src` - the points to be transformed.
`srcOff` - the offset into the `src` array at which to start.
`dst` - the points into which to store the transformed points. May be `src`.
`dstOff` - the offset into the `dst` array at which to start.
`count` - the number of points to transform.
• #### transform

```public void transform(double[] src,
int srcOff,
double[] dst,
int dstOff,
int count)```
Description copied from interface: `Transform`
Transforms the supplied points.
Parameters:
`src` - the points to be transformed (as `[x, y, x, y, ...]`).
`srcOff` - the offset into the `src` array at which to start.
`dst` - the points into which to store the transformed points. May be `src`.
`dstOff` - the offset into the `dst` array at which to start.
`count` - the number of points to transform.
• #### inverseTransform

```public Point inverseTransform(IPoint p,
Point into)```
Description copied from interface: `Transform`
Inverse transforms the supplied point, writing the result into `into`.
`into` - a point into which to store the result, may be the same object as `p`.
Returns:
`into`, for chaining.
• #### transformPoint

```public Vector transformPoint(IVector v,
Vector into)```
Description copied from interface: `Transform`
Transforms the supplied vector as a point (accounting for translation), writing the result into `into`.
`into` - a vector into which to store the result, may be the same object as `v`.
Returns:
`into`, for chaining.
• #### transform

```public Vector transform(IVector v,
Vector into)```
Description copied from interface: `Transform`
Transforms the supplied vector, writing the result into `into`.
`into` - a vector into which to store the result, may be the same object as `v`.
Returns:
`into`, for chaining.
• #### inverseTransform

```public Vector inverseTransform(IVector v,
Vector into)```
Description copied from interface: `Transform`
Inverse transforms the supplied vector, writing the result into `into`.
`into` - a vector into which to store the result, may be the same object as `v`.
Returns:
`into`, for chaining.
• #### copy

`public AffineTransform copy()`
Description copied from interface: `Transform`
Returns a copy of this transform.
Specified by:
`copy` in interface `Transform`
Specified by:
`copy` in class `AbstractTransform`
• #### generality

`public int generality()`
Description copied from interface: `Transform`
Returns an integer that increases monotonically with the generality of the transform implementation. Used internally when combining transforms.
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`