Documentation of 'math.geom2d.AffineTransform2D' Java class
AffineTransform2D
math.geom2d

Class AffineTransform2D

  • All Implemented Interfaces:
    java.lang.Cloneable, GeometricObject2D, Bijection2D, Transform2D


    public class AffineTransform2D
    extends java.lang.Object
    implements Bijection2D, GeometricObject2D, java.lang.Cloneable
    Base class for generic affine transforms in the plane. They include rotations, translations, shears, similarities, and combinations of these. Such transformations can be constructed by using coefficients specification, or by creating specialized instances, by using static methods.

    • Constructor Detail

      • AffineTransform2D

        public AffineTransform2D()
        Creates a new AffineTransform2D, initialized with Identity.
      • AffineTransform2D

        @Deprecated
        public AffineTransform2D(AffineTransform2D trans)
        Deprecated. not necessary to clone immutable objects (0.11.2)
        Constructor by copy of an existing transform
      • AffineTransform2D

        public AffineTransform2D(java.awt.geom.AffineTransform transform)
        Creates a new transform from a java AWT transform.
      • AffineTransform2D

        public AffineTransform2D(double[] coefs)
        Creates a new Affine Transform by directly specifying the coefficients, in the order m00, m01, m02, m10, m11, m12 (different order of java.awt.geom.AffineTransform).
      • AffineTransform2D

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

      • create

        public static AffineTransform2D create(double[] coefs)
        Creates an affine transform defined by an array of coefficients. The input array must have either 4 or 6 coefficients.
        Since:
        0.8.1
      • create

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

        public static AffineTransform2D createGlideReflection(LinearShape2D line,
                                                              double distance)
        Create a glide reflection, composed of a reflection by the given line, and a translation in the direction of the line by a distance given by second parameter.
      • createHomothecy

        @Deprecated
        public static AffineTransform2D createHomothecy(Point2D center,
                                                                    double k)
        Deprecated. replaced by scaling (0.11.1)
      • createLineReflection

        public static AffineTransform2D createLineReflection(LinearShape2D line)
        Creates a reflection by the given line. The resulting transform is indirect.
      • createPointReflection

        public static AffineTransform2D createPointReflection(Point2D center)
        Returns a center reflection around a point. The resulting transform is equivalent to a rotation by 180 around this point.
        Parameters:
        center - the center of the reflection
        Returns:
        an instance of AffineTransform2D representing a point reflection
      • createQuadrantRotation

        public static AffineTransform2D createQuadrantRotation(int numQuadrant)
        Creates a rotation composed of the given number of rotations by 90 degrees around the origin.
      • createQuadrantRotation

        public static AffineTransform2D createQuadrantRotation(Point2D center,
                                                               int numQuadrant)
        Creates a rotation composed of the given number of rotations by 90 degrees around the given point.
      • createQuadrantRotation

        public static AffineTransform2D createQuadrantRotation(double x0,
                                                               double y0,
                                                               int numQuadrant)
        Creates a rotation composed of the given number of rotations by 90 degrees around the point given by (x0,y0).
      • createRotation

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

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

        public static AffineTransform2D createRotation(double cx,
                                                       double cy,
                                                       double angle)
        Creates 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 AffineTransform2D createScaling(double sx,
                                                      double sy)
        Creates a scaling by the given coefficients, centered on the origin.
      • createScaling

        public static AffineTransform2D createScaling(Point2D center,
                                                      double sx,
                                                      double sy)
        Creates a scaling by the given coefficients, centered on the point given by (x0,y0).
      • createShear

        public static 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
      • createTransform

        public static AffineTransform2D createTransform(java.awt.geom.AffineTransform transform)
        Creates a new transform from a java AWT transform.
      • createTranslation

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

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

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

        public static 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 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 (direct or indirect).
        Returns:
        true in case of isometry.
      • isMotion

        public static boolean isMotion(AffineTransform2D trans)
        Checks if the transform is a motion, i.e. a compound of translations and rotations. Motions are special case of isometries that keep orientation (directed or undirected) of shapes unchanged.
        Returns:
        true in case of motion.
      • isSimilarity

        public static 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.
      • coefficients

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

        public double[][] affineMatrix()
        Returns the 3x3 square matrix representing the transform.
        Returns:
        the 3x3 affine transform representing the matrix
      • asAwtTransform

        public java.awt.geom.AffineTransform asAwtTransform()
        Returns this transform as an instance of java AWT AffineTransform.
      • concatenate

        public AffineTransform2D concatenate(AffineTransform2D that)
        Returns the affine transform created by applying first the affine transform given by that, then this affine transform. This is 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)
        Returns 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()
        Tests if this affine transform is a similarity.
      • isMotion

        public boolean isMotion()
        Tests if this affine transform is a motion, i.e. is composed only of rotations and translations.
      • isIsometry

        public boolean isIsometry()
        Tests if this affine transform is an isometry, i.e. is equivalent to a compound of translations, rotations and reflections. Isometry keeps area of shapes unchanged, but can change orientation (direct or indirect).
        Returns:
        true in case of isometry.
      • isDirect

        public boolean isDirect()
        Tests if this affine transform is direct, i.e. the sign of the determinant of the associated matrix is positive. Direct transforms preserve the orientation of transformed shapes.
      • isIdentity

        public boolean isIdentity()
        Tests is this affine transform is equal to the identity transform.
        Returns:
        true if this transform is the identity transform
      • invert

        public AffineTransform2D invert()
        Returns the inverse transform. If the transform is not invertible, throws a new NonInvertibleTransform2DException.
        Specified by:
        invert in interface Bijection2D
        Since:
        0.6.3
      • almostEquals

        public boolean almostEquals(GeometricObject2D obj,
                                    double eps)
        Description copied from interface: GeometricObject2D
        Checks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.
        Specified by:
        almostEquals in interface GeometricObject2D
        Parameters:
        obj - the object to compare
        eps - a threshold value, for example the minimal coordinate difference
        Returns:
        true if both object have the same value up to the threshold
      • toString

        public java.lang.String toString()
        Displays the coefficients of the transform, row by row.
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • clone

        @Deprecated
        public AffineTransform2D clone()
        Deprecated. immutable objects do not need to be cloned (0.11.2)
        Overrides:
        clone in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.