Class MetricTransformation2D

All Implemented Interfaces:
Serializable

public class MetricTransformation2D extends EuclideanTransformation2D implements Serializable
This class performs metric transformations on 2D space. Metric transformations include transformations related to rotations, translations and scale.
See Also:
  • Field Details

    • DEFAULT_SCALE

      public static final double DEFAULT_SCALE
      Default scale factor, which leaves objects with the same scale.
      See Also:
    • scale

      private double scale
      Scale factor. Negative values mean that objects get reversed. Values greater than 1.0 means that objects get enlarged and values between 0.0 and 1.0 means that objects get reduced.
  • Constructor Details

    • MetricTransformation2D

      public MetricTransformation2D()
      Empty constructor. Creates transformation that has no effect.
    • MetricTransformation2D

      public MetricTransformation2D(Rotation2D rotation)
      Creates transformation with provided rotation.
      Parameters:
      rotation - a 2D rotation.
      Throws:
      NullPointerException - raised if provided rotation is null.
    • MetricTransformation2D

      public MetricTransformation2D(double[] translation)
      Creates transformation with provided 2D translation.
      Parameters:
      translation - array indicating 2D translation using inhomogeneous coordinates.
      Throws:
      NullPointerException - raised if provided array is null.
      IllegalArgumentException - raised if length of array is not equal to NUM_TRANSLATION_COORDS.
    • MetricTransformation2D

      public MetricTransformation2D(double scale)
      Creates transformation with provided scale value.
      Parameters:
      scale - scale value. Values between 0.0 and 1.0 reduce objects, values greater than 1.0 enlarge objects and negative values reverse objects.
    • MetricTransformation2D

      public MetricTransformation2D(Rotation2D rotation, double[] translation, double scale)
      Creates transformation with provided rotation, translation and scale value.
      Parameters:
      rotation - a 2D rotation.
      translation - array indicating 2D translation using inhomogeneous coordinates.
      scale - scale value. Values between 0.0 and 1.0 reduce objects, values greater than 1.0 enlarge objects and negative values reverse objects.
      Throws:
      NullPointerException - raised if provided array is null or if rotation is null.
      IllegalArgumentException - raised if length of array is not equal to NUM_TRANSLATION_COORDS.
    • MetricTransformation2D

      public MetricTransformation2D(Point2D inputPoint1, Point2D inputPoint2, Point2D inputPoint3, Point2D outputPoint1, Point2D outputPoint2, Point2D outputPoint3) throws CoincidentPointsException
      Creates transformation by estimating its internal values using provided 3 corresponding original and transformed points.
      Parameters:
      inputPoint1 - 1st input point.
      inputPoint2 - 2nd input point.
      inputPoint3 - 3rd input point.
      outputPoint1 - 1st output point.
      outputPoint2 - 2nd output point.
      outputPoint3 - 3rd output point.
      Throws:
      CoincidentPointsException - if points are in a degenerate configuration.
  • Method Details

    • getScale

      public double getScale()
      Returns scale of this transformation. A value between 0.0 and 1.0 indicates that objects will be reduced, a value greater than 1.0 indicates that objects will be enlarged, and a negative value indicates that objects will be reversed.
      Returns:
      scale.
    • setScale

      public void setScale(double scale)
      Sets scale of this transformation.
      Parameters:
      scale - scale value to be set. A value between 0.0 and 1.0 indicates that objects will be reduced, a value greater than 1.0 indicates that objects will be enlarged, and a negative value indicates that objects will be reversed.
    • asMatrix

      public void asMatrix(com.irurueta.algebra.Matrix m)
      Represents this transformation as a 3x3 matrix and stores the result in provided instance.
      Overrides:
      asMatrix in class EuclideanTransformation2D
      Parameters:
      m - instance where transformation matrix will be stored.
      Throws:
      IllegalArgumentException - raised if provided instance is not a 3x3 matrix.
    • transform

      public void transform(Point2D inputPoint, Point2D outputPoint)
      Transforms input point using this transformation and stores the result in provided output points.
      Overrides:
      transform in class EuclideanTransformation2D
      Parameters:
      inputPoint - point to be transformed.
      outputPoint - instance where transformed point data will be stored.
    • inverse

      public void inverse()
      Inverses this transformation.
      Overrides:
      inverse in class EuclideanTransformation2D
    • inverseAndReturnNew

      public Transformation2D inverseAndReturnNew()
      Computes the inverse of this transformation and returns the result as a new transformation instance.
      Overrides:
      inverseAndReturnNew in class EuclideanTransformation2D
      Returns:
      inverse transformation.
    • inverse

      protected void inverse(MetricTransformation2D result)
      Computes the inverse of this transformation and stores the result in provided instance.
      Parameters:
      result - instance where inverse transformation will be stored.
    • toMetric

      public MetricTransformation2D toMetric()
      Converts this transformation into a metric transformation. Because this method is inherited, and this instance is already metric, this method just returns a copy of this transformation.
      Overrides:
      toMetric in class EuclideanTransformation2D
      Returns:
      this transformation converted into a metric transformation.
    • toAffine

      public AffineTransformation2D toAffine()
      Converts this transformation into an affine transformation.
      Returns:
      this transformation converted into an affine transformation.
    • combine

      public void combine(EuclideanTransformation2D transformation)
      Combines this transformation with provided transformation. The combination is equivalent to multiplying the matrix of this transformation with the matrix of provided transformation.
      Overrides:
      combine in class EuclideanTransformation2D
      Parameters:
      transformation - transformation to be combined with.
    • combineAndReturnNew

      public MetricTransformation2D combineAndReturnNew(EuclideanTransformation2D transformation)
      Combines this transformation with provided transformation and returns the result as a new transformation instance. The combination is equivalent to multiplying the matrix of this transformation with the matrix of provided transformation.
      Overrides:
      combineAndReturnNew in class EuclideanTransformation2D
      Parameters:
      transformation - transformation to be combined with.
      Returns:
      a new transformation resulting of the combination with this transformation and provided transformation.
    • combine

      public void combine(MetricTransformation2D transformation)
      Combines this transformation with provided transformation. The combination is equivalent to multiplying the matrix of this transformation with the matrix of provided transformation.
      Parameters:
      transformation - transformation to be combined with.
    • combineAndReturnNew

      public MetricTransformation2D combineAndReturnNew(MetricTransformation2D transformation)
      Combines this transformation with provided transformation and returns the result as a new transformation instance. The combination is equivalent to multiplying the matrix of this transformation with the matrix of provided transformation.
      Parameters:
      transformation - transformation to be combined with.
      Returns:
      a new transformation resulting of the combination with this transformation and provided transformation.
    • setTransformationFromPoints

      public void setTransformationFromPoints(Point2D inputPoint1, Point2D inputPoint2, Point2D inputPoint3, Point2D outputPoint1, Point2D outputPoint2, Point2D outputPoint3) throws CoincidentPointsException
      Estimates this transformation internal parameters by using 3 corresponding original and transformed points.
      Overrides:
      setTransformationFromPoints in class EuclideanTransformation2D
      Parameters:
      inputPoint1 - 1st input point.
      inputPoint2 - 2nd input point.
      inputPoint3 - 3rd input point.
      outputPoint1 - 1st transformed point corresponding to 1st input point.
      outputPoint2 - 2nd transformed point corresponding to 2nd input point.
      outputPoint3 - 3rd transformed point corresponding to 3rd input point.
      Throws:
      CoincidentPointsException - raised if transformation cannot be estimated for some reason (point configuration degeneracy, duplicate points or numerical instabilities).
    • combine

      private void combine(MetricTransformation2D inputTransformation, MetricTransformation2D outputTransformation)
      Combines this transformation with provided input transformation and stores the result into provided output transformation. The combination is equivalent to multiplying the matrix of this transformation with the matrix of provided input transformation.
      Parameters:
      inputTransformation - transformation to be combined with.
      outputTransformation - transformation where result will be stored.
    • internalSetMetricTransformationFromPoints

      private void internalSetMetricTransformationFromPoints(Point2D inputPoint1, Point2D inputPoint2, Point2D inputPoint3, Point2D outputPoint1, Point2D outputPoint2, Point2D outputPoint3) throws CoincidentPointsException
      Estimates this transformation internal parameters by using 3 corresponding original and transformed points.
      Parameters:
      inputPoint1 - 1st input point.
      inputPoint2 - 2nd input point.
      inputPoint3 - 3rd input point.
      outputPoint1 - 1st transformed point corresponding to 1st input point.
      outputPoint2 - 2nd transformed point corresponding to 2nd input point.
      outputPoint3 - 3rd transformed point corresponding to 3rd input point.
      Throws:
      CoincidentPointsException - raised if transformation cannot be estimated for some reason (point configuration degeneracy, duplicate points or numerical instabilities).