Class LinearTransform1D
Object
Formattable
AbstractMathTransform
LinearTransform1D
- All Implemented Interfaces:
Serializable,MathTransform,MathTransform1D,LinearTransform
public class LinearTransform1D
extends AbstractMathTransform
implements MathTransform1D, LinearTransform, Serializable
A one dimensional, linear transform. Input values x are converted into output values y using
the following equation:
y = offset + scale×x This class
is the same as a 2×2 affine transform. However, this specialized LinearTransform1D class is faster. It
is defined there because extensively used by GridCoverage2D.
- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMathTransform
AbstractMathTransform.Inverse -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LinearTransform1DThe identity transform.final doubleThe value to add to input values.final doubleThe value which is multiplied to input values.Fields inherited from class Formattable
SINGLE_LINE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLinearTransform1D(double scale, double offset) Constructs a new linear transform. -
Method Summary
Modifier and TypeMethodDescriptionstatic LinearTransform1Dcreate(double scale, double offset) Constructs a new linear transform.doublederivative(double value) Gets the derivative of this function at a value.derivative(Position point) Gets the derivative of this transform at a point.booleanCompares the specified object with this math transform for equality.Returns this transform as an affine transform matrix.Returns the parameter descriptors for this math transform.Returns the matrix elements as a group of parameters values.intGets the dimension of input points, which is 1.intGets the dimension of output points, which is 1.inthashCode()Returns a hash value for this transform.inverse()Creates the inverse transform of this object.booleanTests whether this transform does not move any points.booleanisIdentity(double tolerance) Tests whether this transform does not move any points by using the provided tolerance.doubletransform(double value) Transforms the specified value.voidtransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.voidtransform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.Methods inherited from class AbstractMathTransform
createTransformedShape, derivative, ensureNonNull, formatWKT, getName, needCopy, normalizeAngle, rollLongitude, transform, transform, transform, transformMethods inherited from class Formattable
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKTMethods inherited from interface MathTransform
toWKT, transform, transform, transform
-
Field Details
-
IDENTITY
The identity transform. -
scale
public final double scaleThe value which is multiplied to input values. -
offset
public final double offsetThe value to add to input values.
-
-
Constructor Details
-
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- Thescaleterm in the linear equation.offset- Theoffsetterm in the linear equation.
-
-
Method Details
-
create
Constructs a new linear transform.- Parameters:
scale- Thescaleterm in the linear equation.offset- Theoffsetterm in the linear equation.
-
getParameterDescriptors
Returns the parameter descriptors for this math transform.- Overrides:
getParameterDescriptorsin classAbstractMathTransform- Returns:
- The parameter descriptors for this math transform, or
null. - See Also:
-
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.- Overrides:
getParameterValuesin classAbstractMathTransform- Returns:
- A copy of the parameter values for this math transform.
- See Also:
-
getSourceDimensions
public int getSourceDimensions()Gets the dimension of input points, which is 1.- Specified by:
getSourceDimensionsin interfaceMathTransform- Specified by:
getSourceDimensionsin classAbstractMathTransform- Returns:
- The dimension of input points.
-
getTargetDimensions
public int getTargetDimensions()Gets the dimension of output points, which is 1.- Specified by:
getTargetDimensionsin interfaceMathTransform- Specified by:
getTargetDimensionsin classAbstractMathTransform- Returns:
- The dimension of output points.
-
getMatrix
Returns this transform as an affine transform matrix.- Specified by:
getMatrixin interfaceLinearTransform- Returns:
- A copy of the underlying matrix.
-
inverse
Creates the inverse transform of this object.- Specified by:
inversein interfaceMathTransform- Specified by:
inversein interfaceMathTransform1D- Overrides:
inversein classAbstractMathTransform- Returns:
- The inverse transform.
- Throws:
NoninvertibleTransformException- if the transform can't be inversed.
-
isIdentity
public boolean isIdentity()Tests whether this transform does not move any points.- Specified by:
isIdentityin interfaceMathTransform- Overrides:
isIdentityin classAbstractMathTransform- Returns:
trueif thisMathTransformis an identity transform;falseotherwise.
-
isIdentity
public boolean isIdentity(double tolerance) Tests whether this transform does not move any points by using the provided tolerance. This method work in the same way thanXMatrix.isIdentity(double).- Specified by:
isIdentityin interfaceLinearTransform- Parameters:
tolerance- The tolerance factor.- Returns:
trueif this transform is the identity one- Since:
- 2.3.1
-
derivative
Gets the derivative of this transform at a point. This implementation is different from the defaultAbstractMathTransform.derivative(java.awt.geom.Point2D)implementation in that no coordinate point is required andDouble.NaNmay be a legal output value for some users.- Specified by:
derivativein interfaceMathTransform- Overrides:
derivativein classAbstractMathTransform- Parameters:
point- The coordinate point where to evaluate the derivative.- Returns:
- The derivative at the specified point (never
null). - 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:
derivativein interfaceMathTransform1D- Parameters:
value- The value where to evaluate the derivative.- Returns:
- The derivative at the specified point.
-
transform
public double transform(double value) Transforms the specified value.- Specified by:
transformin interfaceMathTransform1D- Parameters:
value- The value to transform.- Returns:
- the transformed value.
-
transform
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.- Specified by:
transformin interfaceMathTransform- Overrides:
transformin classAbstractMathTransform- 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 thansrcPts.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, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.- Specified by:
transformin interfaceMathTransform- 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 thansrcPts.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.
-
hashCode
public int hashCode()Returns a hash value for this transform. This value need not remain consistent between different implementations of the same class.- Overrides:
hashCodein classAbstractMathTransform
-
equals
Compares the specified object with this math transform for equality.- Overrides:
equalsin classAbstractMathTransform- Parameters:
object- The object to compare with this transform.- Returns:
trueif the given object is a transform of the same class and if, given identical source position, the transformed position would be the equals.
-