org.geotoolkit.referencing.operation.transform
Class LinearTransform1D

Object
  extended by FormattableObject
      extended by AbstractMathTransform
          extended by AbstractMathTransform1D
              extended by LinearTransform1D
All Implemented Interfaces:
Serializable, Formattable, LinearTransform, Parameterized, LenientComparable, MathTransform, MathTransform1D

@Immutable
public class LinearTransform1D
extends AbstractMathTransform1D
implements LinearTransform, Serializable

A one dimensional, linear transform. Input values x are converted into output values y using the following equation:

y  =  x × scale + offset
This class is the same as a 2×2 affine transform. However, this specialized LinearTransform1D class is faster. This kind of transform is extensively used by GridCoverage2D.

See any of the following providers for a list of programmatic parameters:

Since:
2.0
Version:
3.18
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
LogarithmicTransform1D, ExponentialTransform1D, Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class AbstractMathTransform
AbstractMathTransform.Inverse
 
Field Summary
static LinearTransform1D IDENTITY
          The identity transform.
 double offset
          The value to add to input values.
 double scale
          The value which is multiplied to input values.
 
Fields inherited from class FormattableObject
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE
 
Constructor Summary
protected LinearTransform1D(double scale, double offset)
          Constructs a new linear transform.
 
Method Summary
protected  int computeHashCode()
          Computes a hash value for this transform.
static LinearTransform1D create(double scale, double offset)
          Constructs a new linear transform.
 Matrix derivative(DirectPosition point)
          Gets the derivative of this transform at a point.
 double derivative(double value)
          Gets the derivative of this function at a value.
 boolean equals(Object object, ComparisonMode mode)
          Compares the specified object with this math transform for equality.
 Matrix getMatrix()
          Returns this transform as an affine transform matrix.
 ParameterDescriptorGroup getParameterDescriptors()
          Returns the parameter descriptors for this math transform.
 ParameterValueGroup getParameterValues()
          Returns the matrix elements as a group of parameters values.
 MathTransform1D inverse()
          Creates the inverse transform of this object.
 boolean isIdentity()
          Tests whether this transform does not move any points.
 boolean isIdentity(double tolerance)
          Tests whether this transform does not move any points by using the provided tolerance.
 double transform(double value)
          Transforms the specified value.
protected  void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff)
          Transforms a single coordinate in a list of ordinal values.
 void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 
Methods inherited from class AbstractMathTransform1D
getSourceDimensions, getTargetDimensions
 
Methods inherited from class AbstractMathTransform
createTransformedShape, derivative, ensureNonNull, equals, formatWKT, getName, hashCode, rollLongitude, transform, transform
 
Methods inherited from class FormattableObject
getDefaultIndentation, print, setDefaultIndentation, toString, toWKT, toWKT, toWKT
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface MathTransform
getSourceDimensions, getTargetDimensions, toWKT, transform
 
Methods inherited from interface LenientComparable
equals
 

Field Detail

IDENTITY

public static final LinearTransform1D IDENTITY
The identity transform.


scale

public final double scale
The value which is multiplied to input values.


offset

public final double offset
The value to add to input values.

Constructor Detail

LinearTransform1D

protected LinearTransform1D(double scale,
                            double offset)
Constructs a new linear transform. This constructor is provided for subclasses only. Instances should be created using the factory method, which may returns optimized implementations for some particular argument values.

Parameters:
scale - The scale term in the linear equation.
offset - The offset term in the linear equation.
Method Detail

create

public static LinearTransform1D create(double scale,
                                       double offset)
Constructs a new linear transform.

Parameters:
scale - The scale term in the linear equation.
offset - The offset term in the linear equation.
Returns:
The linear transform for the given scale and offset.

getParameterDescriptors

public ParameterDescriptorGroup getParameterDescriptors()
Returns the parameter descriptors for this math transform.

Specified by:
getParameterDescriptors in interface Parameterized
Overrides:
getParameterDescriptors in class AbstractMathTransform
Returns:
The parameter descriptors for this math transform, or null.
See Also:
OperationMethod.getParameters()

getParameterValues

public ParameterValueGroup getParameterValues()
Returns the matrix elements as a group of parameters values. The number of parameters depends on the matrix size. Only matrix elements different from their default value will be included in this group.

Specified by:
getParameterValues in interface Parameterized
Overrides:
getParameterValues in class AbstractMathTransform
Returns:
A copy of the parameter values for this math transform.
See Also:
SingleOperation.getParameterValues()

getMatrix

public Matrix getMatrix()
Returns this transform as an affine transform matrix.

Specified by:
getMatrix in interface LinearTransform
Returns:
A copy of the underlying matrix.

inverse

public MathTransform1D inverse()
                        throws NoninvertibleTransformException
Creates the inverse transform of this object.

Specified by:
inverse in interface MathTransform
Specified by:
inverse in interface MathTransform1D
Overrides:
inverse in class AbstractMathTransform1D
Throws:
NoninvertibleTransformException

isIdentity

public boolean isIdentity()
Tests whether this transform does not move any points.

Specified by:
isIdentity in interface MathTransform
Overrides:
isIdentity in class AbstractMathTransform

isIdentity

public boolean isIdentity(double tolerance)
Tests whether this transform does not move any points by using the provided tolerance.

Specified by:
isIdentity in interface LinearTransform
Parameters:
tolerance - The tolerance factor.
Returns:
true if this transform is the identity one
Since:
2.3.1
See Also:
XMatrix.isIdentity(double)

derivative

public Matrix derivative(DirectPosition point)
                  throws TransformException
Gets the derivative of this transform at a point.

Specified by:
derivative in interface MathTransform
Overrides:
derivative in class AbstractMathTransform1D
Parameters:
point - Ignored for a linear transform. Can be null.
Returns:
The derivative at the given point.
Throws:
TransformException - if the derivative can't be evaluated at the specified point.

derivative

public double derivative(double value)
Gets the derivative of this function at a value.

Specified by:
derivative in interface MathTransform1D
Parameters:
value - Ignored for a linear transform. Can be NaN.
Returns:
The derivative at the given point.

transform

public double transform(double value)
Transforms the specified value.

Specified by:
transform in interface MathTransform1D

transform

protected void transform(double[] srcPts,
                         int srcOff,
                         double[] dstPts,
                         int dstOff)
Transforms a single coordinate in a list of ordinal values.

Overrides:
transform in class AbstractMathTransform1D
Parameters:
srcPts - The array containing the source point coordinates.
srcOff - The offset to the point to be transformed in the source array.
dstPts - the array into which the transformed point coordinate are returned. May be the same than srcPts.
dstOff - The offset to the location of the transformed point that is stored in the destination array.

transform

public void transform(double[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
Transforms many coordinates in a list of ordinal values.

Specified by:
transform in interface 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. May be the same than srcPts.
dstOff - The offset to the location of the first transformed point that is stored in the destination array.
numPts - The number of point objects to be transformed.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
Transforms many coordinates in a list of ordinal values.

Specified by:
transform in interface 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. May be the same than srcPts.
dstOff - The offset to the location of the first transformed point that is stored in the destination array.
numPts - The number of point objects to be transformed.

transform

public void transform(double[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
Transforms many coordinates in a list of ordinal values.

Specified by:
transform in interface 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 point objects to be transformed.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
Transforms many coordinates in a list of ordinal values.

Specified by:
transform in interface 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 point objects to be transformed.

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 Geotk library.

equals

public boolean equals(Object object,
                      ComparisonMode mode)
Compares the specified object with this math transform for equality. The default implementation returns true if the following conditions are meet:

The parameter values are not compared because subclasses can typically compare those values more efficiently by accessing to their member fields.

Specified by:
equals in interface LinearTransform
Specified by:
equals in interface LenientComparable
Overrides:
equals in class AbstractMathTransform
Parameters:
object - The object to compare with this transform.
mode - The strictness level of the comparison. Default to STRICT.
Returns:
true if the given object is a transform of the same class and if, given identical source position, the transformed position would be the equals.


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.