math.geom2d
Class AffineTransform2D

Package class diagram package AffineTransform2D
java.lang.Object
  extended by math.geom2d.AffineTransform2D
All Implemented Interfaces:
Cloneable, Bijection2D, Transform2D
Direct Known Subclasses:
AffineTransform2D

public class AffineTransform2D
extends Object
implements Bijection2D, Cloneable

Base class for generic affine transforms in the plane. They include rotations, translations, shears, homotheties, and combinations of these. Such transformations can be constructed by using coefficients specification, or by creating specialized instances, by using static methods.


Field Summary
protected  double m00
           
protected  double m01
           
protected  double m02
           
protected  double m10
           
protected  double m11
           
protected  double m12
           
 
Constructor Summary
AffineTransform2D()
          Main constructor
AffineTransform2D(AffineTransform2D trans)
          constructor by copy of an existing transform
AffineTransform2D(double[] coefs)
           
AffineTransform2D(double xx, double yx, double tx, double xy, double yy, double ty)
           
 
Method Summary
 AffineTransform2D chain(AffineTransform2D that)
          Return the affine transform created by applying first this affine transform, then the affine transform given by that.
 AffineTransform2D clone()
           
 AffineTransform2D compose(AffineTransform2D that)
          Deprecated. replaced by concatenate() method (0.6.3)
 AffineTransform2D concatenate(AffineTransform2D that)
          Return the affine transform created by applying first the affine transform given by that, then this affine transform.
static AffineTransform2D create(AffineTransform2D trans)
          Creates a new affine transform by copying coefficients.
static AffineTransform2D create(double[] coefs)
           
static AffineTransform2D create(double xx, double yx, double tx, double xy, double yy, double ty)
           
static AffineTransform2D createGlideReflection(LinearShape2D line, double distance)
           
static AffineTransform2D createHomothecy(Point2D center, double k)
           
static AffineTransform2D createIdentity()
           
static AffineTransform2D createLineReflection(LinearShape2D line)
           
static AffineTransform2D createPointReflection(Point2D center)
          Return a point reflection centered on a point.
static AffineTransform2D createQuadrantRotation(int numQuadrant)
           
static AffineTransform2D createRotation(double angle)
          Return a rotation around the origin, with angle in radians.
static AffineTransform2D createRotation(double cx, double cy, double angle)
          Return a rotation around the specified point, with angle in radians.
static AffineTransform2D createRotation(Point2D center, double angle)
          Return a rotation around the specified point, with angle in radians.
static AffineTransform2D createScaling(double sx, double sy)
          Return a scaling by the given coefficients, centered on the origin.
static AffineTransform2D createScaling(Point2D center, double sx, double sy)
          Return a scaling by the given coefficients, centered on the given point.
static AffineTransform2D createShear(double shx, double shy)
          Creates a Shear transform, using the classical Java notation.
static AffineTransform2D createTranslation(double dx, double dy)
          Return a translation by the given vector.
static AffineTransform2D createTranslation(Vector2D vect)
          Return a translation by the given vector.
 boolean equals(Object obj)
           
 double[][] getAffineMatrix()
          Returns the 3x3 square matrix representing the transform.
 double[] getCoefficients()
          Returns coefficients of the transform in a linear array of 6 double.
 AffineTransform2D getInverseTransform()
          Deprecated. use invert() method instead (0.6.3)
 AffineTransform2D invert()
          Return the inverse transform.
 boolean isDirect()
           
static boolean isDirect(AffineTransform2D trans)
          Checks if the transform is direct, i.e.
 boolean isIdentity()
           
static boolean isIdentity(AffineTransform2D trans)
          Checks if the given transform is the identity transform.
 boolean isIsometry()
           
static boolean isIsometry(AffineTransform2D trans)
          Checks if the transform is an isometry, i.e.
 boolean isMotion()
           
static boolean isMotion(AffineTransform2D trans)
          Checks if the transform is a motion, i.e.
 boolean isSimilarity()
           
static boolean isSimilarity(AffineTransform2D trans)
          Checks if the transform is an similarity, i.e.
 AffineTransform2D preConcatenate(AffineTransform2D that)
          Return the affine transform created by applying first this affine transform, then the affine transform given by that.
 String toString()
          Displays the coefficients of the transform, row by row.
 Point2D transform(Point2D src)
          Transforms a point
 Point2D[] transform(Point2D[] src, Point2D[] dst)
          Transforms an array of points, and returns the transformed points.
 Point2D transform(Point2D src, Point2D dst)
          Deprecated. use point.transform() instead. (0.7.0)
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m00

protected double m00

m01

protected double m01

m02

protected double m02

m10

protected double m10

m11

protected double m11

m12

protected double m12
Constructor Detail

AffineTransform2D

public AffineTransform2D()
Main constructor


AffineTransform2D

public AffineTransform2D(AffineTransform2D trans)
constructor by copy of an existing transform


AffineTransform2D

public AffineTransform2D(double[] coefs)

AffineTransform2D

public AffineTransform2D(double xx,
                         double yx,
                         double tx,
                         double xy,
                         double yy,
                         double ty)
Method Detail

createIdentity

public static final AffineTransform2D createIdentity()
Since:
0.8.1

create

public static final AffineTransform2D create(AffineTransform2D trans)
Creates a new affine transform by copying coefficients.

Since:
0.8.1

create

public static final AffineTransform2D create(double[] coefs)
Since:
0.8.1

create

public static final AffineTransform2D create(double xx,
                                             double yx,
                                             double tx,
                                             double xy,
                                             double yy,
                                             double ty)
Since:
0.8.1

createGlideReflection

public static final AffineTransform2D createGlideReflection(LinearShape2D line,
                                                            double distance)

createHomothecy

public static final AffineTransform2D createHomothecy(Point2D center,
                                                      double k)

createLineReflection

public static final AffineTransform2D createLineReflection(LinearShape2D line)

createPointReflection

public static final AffineTransform2D createPointReflection(Point2D center)
Return a point reflection centered on a point.

Parameters:
center - the center of the reflection
Returns:
an instance of AffineTransform2D representing a point reflection

createQuadrantRotation

public static final AffineTransform2D createQuadrantRotation(int numQuadrant)

createRotation

public static final AffineTransform2D createRotation(double angle)
Return a rotation around the origin, with angle in radians.


createRotation

public static final AffineTransform2D createRotation(Point2D center,
                                                     double angle)
Return a rotation around the specified point, with angle in radians.


createRotation

public static final AffineTransform2D createRotation(double cx,
                                                     double cy,
                                                     double angle)
Return a rotation around the specified point, with angle in radians. If the angular distance of the angle with a multiple of PI/2 is lower than the threshold Shape2D.ACCURACY, the method assumes equality.


createScaling

public static final AffineTransform2D createScaling(double sx,
                                                    double sy)
Return a scaling by the given coefficients, centered on the origin.


createScaling

public static final AffineTransform2D createScaling(Point2D center,
                                                    double sx,
                                                    double sy)
Return a scaling by the given coefficients, centered on the given point.


createShear

public static final AffineTransform2D createShear(double shx,
                                                  double shy)
Creates a Shear transform, using the classical Java notation.

Parameters:
shx - shear in x-axis
shy - shear in y-axis
Returns:
a shear transform

createTranslation

public static final AffineTransform2D createTranslation(Vector2D vect)
Return a translation by the given vector.


createTranslation

public static final AffineTransform2D createTranslation(double dx,
                                                        double dy)
Return a translation by the given vector.


isIdentity

public static final boolean isIdentity(AffineTransform2D trans)
Checks if the given transform is the identity transform.


isDirect

public static final boolean isDirect(AffineTransform2D trans)
Checks if the transform is direct, i.e. it preserves the orientation of transformed shapes.

Returns:
true if transform is direct.

isIsometry

public static final boolean isIsometry(AffineTransform2D trans)
Checks if the transform is an isometry, i.e. a compound of translation, rotation and reflection. Isometry keeps area of shapes unchanged, but can change orientation (directed or undirected).

Returns:
true in case of isometry.

isMotion

public static final boolean isMotion(AffineTransform2D trans)
Checks if the transform is a motion, i.e. a compound of translations and rotation. Motion remains area and orientation (directed or undirected) of shapes unchanged.

Returns:
true in case of motion.

isSimilarity

public static final boolean isSimilarity(AffineTransform2D trans)
Checks if the transform is an similarity, i.e. transformation which keeps unchanged the global shape, up to a scaling factor.

Returns:
true in case of similarity.

getCoefficients

public double[] getCoefficients()
Returns coefficients of the transform in a linear array of 6 double.


getAffineMatrix

public double[][] getAffineMatrix()
Returns the 3x3 square matrix representing the transform.

Returns:
the 3x3 affine transform representing the matrix

compose

@Deprecated
public AffineTransform2D compose(AffineTransform2D that)
Deprecated. replaced by concatenate() method (0.6.3)

Return the affine transform created by applying first the affine transform given by that, then this affine transform.

Parameters:
that - the transform to apply first
Returns:
the composition this * that

concatenate

public AffineTransform2D concatenate(AffineTransform2D that)
Return the affine transform created by applying first the affine transform given by that, then this affine transform. This the equivalent method of the 'concatenate' method in java.awt.geom.AffineTransform.

Parameters:
that - the transform to apply first
Returns:
the composition this * that
Since:
0.6.3

chain

public AffineTransform2D chain(AffineTransform2D that)
Return the affine transform created by applying first this affine transform, then the affine transform given by that. This the equivalent method of the 'preConcatenate' method in java.awt.geom.AffineTransform.
 shape = shape.transform(T1.chain(T2).chain(T3));
 
is equivalent to the sequence:
 shape = shape.transform(T1);
 shape = shape.transform(T2);
 shape = shape.transform(T3);
 

Parameters:
that - the transform to apply in a second step
Returns:
the composition that * this
Since:
0.6.3

preConcatenate

public AffineTransform2D preConcatenate(AffineTransform2D that)
Return the affine transform created by applying first this affine transform, then the affine transform given by that. This the equivalent method of the 'preConcatenate' method in java.awt.geom.AffineTransform.

Parameters:
that - the transform to apply in a second step
Returns:
the composition that * this
Since:
0.6.3

isSimilarity

public boolean isSimilarity()

isMotion

public boolean isMotion()

isIsometry

public boolean isIsometry()

isDirect

public boolean isDirect()

isIdentity

public boolean isIdentity()

invert

public AffineTransform2D invert()
Return the inverse transform. If the transform is not invertible, throws a new NonInvertibleTransformException.

Since:
0.6.3

getInverseTransform

@Deprecated
public AffineTransform2D getInverseTransform()
Deprecated. use invert() method instead (0.6.3)

Return the inverse transform. If the transform is not invertible, throws a new NonInvertibleTransformException.

Specified by:
getInverseTransform in interface Bijection2D

transform

public Point2D[] transform(Point2D[] src,
                           Point2D[] dst)
Description copied from interface: Transform2D
Transforms an array of points, and returns the transformed points.

Specified by:
transform in interface Transform2D

transform

public Point2D transform(Point2D src)
Description copied from interface: Transform2D
Transforms a point

Specified by:
transform in interface Transform2D

transform

@Deprecated
public Point2D transform(Point2D src,
                                    Point2D dst)
Deprecated. use point.transform() instead. (0.7.0)


toString

public String toString()
Displays the coefficients of the transform, row by row.

Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

clone

public AffineTransform2D clone()
Overrides:
clone in class Object


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.