Class AffineParameters2D

java.lang.Object
com.irurueta.geometry.AffineParameters2D
All Implemented Interfaces:
Serializable

public class AffineParameters2D extends Object implements Serializable
This class defines additional parameters that can be defined on affine 2D transformations.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default scale value having no effect on transformations.
    static final double
    Default skewness value having no effect on transformations.
    private static final double
    Default threshold to determine whether a matrix is a valid 2x2 upper triangular one.
    static final int
    Number of inhomogeneous coordinates in 2D space.
    private double
    Horizontal scale.
    private double
    Vertical scale.
    private double
    Skewness factor.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
    AffineParameters2D(double scale)
    Constructor with scale.
    AffineParameters2D(double scale, double skewness)
    Constructor with scale and skewness.
    AffineParameters2D(double scaleX, double scaleY, double skewness)
    Constructor with horizontal scale, vertical scale and skewness.
    AffineParameters2D(com.irurueta.algebra.Matrix m)
    Constructor with matrix.
    AffineParameters2D(com.irurueta.algebra.Matrix m, double threshold)
    Constructor with matrix and threshold.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.irurueta.algebra.Matrix
    Converts this affine parameters instance into matrix representation.
    void
    asMatrix(com.irurueta.algebra.Matrix m)
    Converts this affine parameters instance into matrix representation and stores the result into provided matrix.
    final void
    fromMatrix(com.irurueta.algebra.Matrix m)
    Sets parameters of this instance from provided matrix.
    final void
    fromMatrix(com.irurueta.algebra.Matrix m, double threshold)
    Sets parameters of this instance from provided matrix.
    double
    Returns horizontal scale.
    double
    Returns vertical scale.
    double
    Returns skewness value.
    static boolean
    isValidMatrix(com.irurueta.algebra.Matrix m)
    Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters from.
    static boolean
    isValidMatrix(com.irurueta.algebra.Matrix m, double threshold)
    Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters form.
    void
    setScale(double scale)
    Sets overall scale (both, horizontal and vertical).
    void
    setScaleX(double scaleX)
    Sets horizontal scale.
    void
    setScaleY(double scaleY)
    Sets vertical scale.
    void
    setSkewness(double skewness)
    Sets skewness value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_SCALE

      public static final double DEFAULT_SCALE
      Default scale value having no effect on transformations.
      See Also:
    • DEFAULT_SKEWNESS

      public static final double DEFAULT_SKEWNESS
      Default skewness value having no effect on transformations.
      See Also:
    • INHOM_COORDS

      public static final int INHOM_COORDS
      Number of inhomogeneous coordinates in 2D space.
      See Also:
    • DEFAULT_VALID_THRESHOLD

      private static final double DEFAULT_VALID_THRESHOLD
      Default threshold to determine whether a matrix is a valid 2x2 upper triangular one.
      See Also:
    • scaleX

      private double scaleX
      Horizontal scale.
    • scaleY

      private double scaleY
      Vertical scale.
    • skewness

      private double skewness
      Skewness factor. If 0.0, horizontal and vertical axes remain orthogonal, otherwise they get slanted.
  • Constructor Details

    • AffineParameters2D

      public AffineParameters2D()
      Constructor. Sets default scale and skewness
    • AffineParameters2D

      public AffineParameters2D(double scale)
      Constructor with scale. Sets default skewness and provided scale.
      Parameters:
      scale - Scale to be set (both, horizontal and vertical). A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
    • AffineParameters2D

      public AffineParameters2D(double scale, double skewness)
      Constructor with scale and skewness.
      Parameters:
      scale - Scale to be set (both, horizontal and vertical). A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      skewness - Skewness to be set.
    • AffineParameters2D

      public AffineParameters2D(double scaleX, double scaleY, double skewness)
      Constructor with horizontal scale, vertical scale and skewness.
      Parameters:
      scaleX - Horizontal scale to be set. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      scaleY - Vertical scale to be set. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      skewness - Skewness to be set.
    • AffineParameters2D

      public AffineParameters2D(com.irurueta.algebra.Matrix m, double threshold)
      Constructor with matrix and threshold.
      Parameters:
      m - Upper triangular matrix to extract affine parameters from.
      threshold - Threshold to determine whether provided matrix is a valid upper triangular one.
      Throws:
      IllegalArgumentException - Raised if provided matrix is not 2x2 or if it is not upper triangular, or if threshold is negative.
    • AffineParameters2D

      public AffineParameters2D(com.irurueta.algebra.Matrix m)
      Constructor with matrix.
      Parameters:
      m - Upper triangular matrix to extract affine parameters from.
      Throws:
      IllegalArgumentException - Raised if provided matrix is not 2x2 or if it is not upper triangular.
  • Method Details

    • getScaleX

      public double getScaleX()
      Returns horizontal scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      Returns:
      Horizontal scale.
    • setScaleX

      public void setScaleX(double scaleX)
      Sets horizontal scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      Parameters:
      scaleX - Horizontal scale to be set.
    • getScaleY

      public double getScaleY()
      Returns vertical scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      Returns:
      Vertical scale.
    • setScaleY

      public void setScaleY(double scaleY)
      Sets vertical scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      Parameters:
      scaleY - Vertical scale to be set.
    • setScale

      public void setScale(double scale)
      Sets overall scale (both, horizontal and vertical). A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
      Parameters:
      scale - Horizontal and vertical scale to be set.
    • getSkewness

      public double getSkewness()
      Returns skewness value. A value of 0.0 indicates that horizontal and vertical axis are orthogonal, otherwise they are slanted to each other.
      Returns:
      Skewness value.
    • setSkewness

      public void setSkewness(double skewness)
      Sets skewness value. A value of 0.0 indicates that horizontal and vertical axis are orthogonal, otherwise they are slanted to each other.
      Parameters:
      skewness - Skewness to be set.
    • asMatrix

      public com.irurueta.algebra.Matrix asMatrix()
      Converts this affine parameters instance into matrix representation.
      Returns:
      A matrix representation of this instance.
    • asMatrix

      public void asMatrix(com.irurueta.algebra.Matrix m)
      Converts this affine parameters instance into matrix representation and stores the result into provided matrix.
      Parameters:
      m - Matrix where representation of this instance will be stored.
      Throws:
      IllegalArgumentException - Raised if provided matrix is not 2x2.
    • fromMatrix

      public final void fromMatrix(com.irurueta.algebra.Matrix m)
      Sets parameters of this instance from provided matrix.
      Parameters:
      m - Matrix to set parameters from. Provided matrix must be 2x2 and upper triangular.
      Throws:
      IllegalArgumentException - Raised if provided matrix is not 2x2 or if it is not upper triangular.
    • fromMatrix

      public final void fromMatrix(com.irurueta.algebra.Matrix m, double threshold)
      Sets parameters of this instance from provided matrix.
      Parameters:
      m - Matrix to set parameters from. Provided matrix must be 2x2 and upper triangular up to provided threshold.
      threshold - Threshold to determine whether provided matrix is upper triangular. Matrix will be considered upper triangular if its lower triangular elements are smaller or equal than provided threshold.
      Throws:
      IllegalArgumentException - Raised if provided matrix is not 2x2 or if it is not upper triangular or if threshold is negative.
    • isValidMatrix

      public static boolean isValidMatrix(com.irurueta.algebra.Matrix m)
      Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters from. Valid matrices need to be 2x2 and upper triangular.
      Parameters:
      m - A matrix to determine whether it is valid to set affine parameters from.
      Returns:
      True if matrix is valid, false otherwise.
    • isValidMatrix

      public static boolean isValidMatrix(com.irurueta.algebra.Matrix m, double threshold)
      Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters form. Valid matrices need to be 2x2 and upper triangular up to provided threshold. In Layman terms, a valid matrix lower triangular elements need to be smaller or equal than provided threshold.
      Parameters:
      m - A matrix to determine whether it is valid to set affine parameters from.
      threshold - A threshold to determine whether provided matrix is upper triangular. Matrix will be considered upper triangular if its lower triangular elements are smaller or equal than provided threshold (without taking into account the sign of the elements).
      Returns:
      True if matrix is valid, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.