Class ScaleTransform

All Implemented Interfaces:
Serializable, ExtendedPrecisionMatrix, Parameterized, LinearTransform, LenientComparable, org.opengis.referencing.operation.MathTransform, org.opengis.referencing.operation.Matrix

final class ScaleTransform extends AbstractLinearTransform implements ExtendedPrecisionMatrix
An affine transform that multiply the coordinate values by constant values, and optionally drop the last coordinates. This is an optimization of ProjectiveTransform for a common case.
Note: we do not provide two-dimensional specialization because AffineTransform2D should be used in such case.
Since:
0.7
Version:
1.0
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serial number for inter-operability with different versions.
      See Also:
    • factors

      private final double[] factors
      Multiplication factors, to be applied in the same order than coordinate values. The length of this array is the number of target dimensions.
    • errors

      private final double[] errors
      The error terms in double-double arithmetic, or null if none. May be shorter than factors if all remaining errors are zero.
    • numDroppedDimensions

      private final int numDroppedDimensions
      Number of coordinate values to drop after the values that we multiplied. Values to drop happen for example in Geographic 3D to 2D conversions.
  • Constructor Details

    • ScaleTransform

      ScaleTransform(double[] factors)
      Constructs a scale transform for the given scale factors.
    • ScaleTransform

      ScaleTransform(int numRow, int numCol, double[] elements)
      Constructs a scale transform from a matrix having the given elements. This constructors assumes that the matrix is affine and contains only scale coefficients (this is not verified).
  • Method Details

    • getExtendedElements

      public double[] getExtendedElements()
      Returns a copy of matrix elements, including error terms if any.
      Specified by:
      getExtendedElements in interface ExtendedPrecisionMatrix
      Returns:
      a copy of matrix elements, potentially followed by error terms.
    • getSourceDimensions

      public int getSourceDimensions()
      Gets the dimension of input points.
      Specified by:
      getSourceDimensions in interface org.opengis.referencing.operation.MathTransform
      Specified by:
      getSourceDimensions in class AbstractMathTransform
      Returns:
      the number of dimensions of input points.
      See Also:
    • getTargetDimensions

      public int getTargetDimensions()
      Gets the dimension of output points.
      Specified by:
      getTargetDimensions in interface org.opengis.referencing.operation.MathTransform
      Specified by:
      getTargetDimensions in class AbstractMathTransform
      Returns:
      the number of dimensions of output points.
      See Also:
    • getElement

      public double getElement(int row, int column)
      Returns the matrix element at the given index.
      Specified by:
      getElement in interface org.opengis.referencing.operation.Matrix
    • isIdentity

      public boolean isIdentity()
      Tests whether this transform does not move any points.
      Specified by:
      isIdentity in interface org.opengis.referencing.operation.MathTransform
      Specified by:
      isIdentity in interface org.opengis.referencing.operation.Matrix
      Overrides:
      isIdentity in class AbstractMathTransform
    • transform

      public org.opengis.referencing.operation.Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate)
      Converts a single position in a list of coordinate values, and optionally computes the derivative at that location.
      Specified by:
      transform in class AbstractMathTransform
      Parameters:
      srcPts - the array containing the source coordinates (cannot be null).
      srcOff - the offset to the point to be transformed in the source array.
      dstPts - the array into which the transformed coordinates is returned. May be the same than srcPts. May be null if only the derivative matrix is desired.
      dstOff - the offset to the location of the transformed point that is stored in the destination array.
      derivate - true for computing the derivative, or false if not needed.
      Returns:
      the matrix of the transform derivative at the given source position, or null if the derivate argument is false.
      See Also:
    • transform

      public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
      Transforms an array of floating point coordinates by this matrix. Point coordinates must have a dimension equal to Matrix.getNumCol()-1. For example, for square matrix of size 4×4, coordinate points are three-dimensional and stored in the arrays starting at the specified offset (srcOff) in the order [x₀, y₀, z₀, x₁, y₁, z₁..., xn, yn, zn].
      Specified by:
      transform in interface org.opengis.referencing.operation.MathTransform
      Overrides:
      transform in class AbstractMathTransform
      Parameters:
      srcPts - the array containing the source point coordinates.
      srcOff - the offset to the first point to be transformed in the source array.
      dstPts - the array into which the transformed point coordinates are returned.
      dstOff - the offset to the location of the first transformed point that is stored in the destination array. The source and destination array sections can overlap.
      numPts - the number of points to be transformed.
    • transform

      public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
      Transforms an array of floating point coordinates by this matrix. Point coordinates must have a dimension equal to Matrix.getNumCol() - 1. For example, for square matrix of size 4×4, coordinate points are three-dimensional and stored in the arrays starting at the specified offset (srcOff) in the order [x₀, y₀, z₀, x₁, y₁, z₁..., xn, yn, zn].
      Specified by:
      transform in interface org.opengis.referencing.operation.MathTransform
      Overrides:
      transform in class AbstractMathTransform
      Parameters:
      srcPts - the array containing the source point coordinates.
      srcOff - the offset to the first point to be transformed in the source array.
      dstPts - the array into which the transformed point coordinates are returned.
      dstOff - the offset to the location of the first transformed point that is stored in the destination array. The source and destination array sections can overlap.
      numPts - the number of points to be transformed.
    • transform

      public void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
      Transforms an array of floating point coordinates by this matrix.
      Specified by:
      transform in interface org.opengis.referencing.operation.MathTransform
      Overrides:
      transform in class AbstractMathTransform
      Parameters:
      srcPts - the array containing the source point coordinates.
      srcOff - the offset to the first point to be transformed in the source array.
      dstPts - the array into which the transformed point coordinates are returned.
      dstOff - the offset to the location of the first transformed point that is stored in the destination array.
      numPts - the number of points to be transformed.
    • transform

      public void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
      Transforms an array of floating point coordinates by this matrix.
      Specified by:
      transform in interface org.opengis.referencing.operation.MathTransform
      Overrides:
      transform in class AbstractMathTransform
      Parameters:
      srcPts - the array containing the source point coordinates.
      srcOff - the offset to the first point to be transformed in the source array.
      dstPts - the array into which the transformed point coordinates are returned.
      dstOff - the offset to the location of the first transformed point that is stored in the destination array.
      numPts - the number of points to be transformed.
    • derivative

      public org.opengis.referencing.operation.Matrix derivative(org.opengis.geometry.DirectPosition point)
      Gets the derivative of this transform at a point. For a matrix transform, the derivative is the same everywhere.
      Specified by:
      derivative in interface org.opengis.referencing.operation.MathTransform
      Overrides:
      derivative in class AbstractMathTransform
      Parameters:
      point - ignored (can be null).
      Returns:
      the derivative at the specified point (never null).
    • computeHashCode

      protected int computeHashCode()
      Computes a hash value for this transform. This method is invoked by AbstractMathTransform.hashCode() when first needed.
      Overrides:
      computeHashCode in class AbstractMathTransform
      Returns:
      the hash code value. This value may change between different execution of the Apache SIS library.
    • equalsSameClass

      protected boolean equalsSameClass(Object object)
      Compares this math transform with an object which is known to be an instance of the same class.
      Specified by:
      equalsSameClass in class AbstractLinearTransform
      Parameters:
      object - the object to compare with this transform.
      Returns:
      true if the given object is considered equals to this math transform.