Class LinearTransform1D
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.operation.transform.AbstractMathTransform
org.apache.sis.referencing.operation.transform.AbstractMathTransform1D
org.apache.sis.referencing.operation.transform.LinearTransform1D
- All Implemented Interfaces:
Serializable,Parameterized,LinearTransform,LenientComparable,org.opengis.referencing.operation.MathTransform,org.opengis.referencing.operation.MathTransform1D
- Direct Known Subclasses:
ConstantTransform1D,IdentityTransform1D
A one dimensional, linear transform.
Input values x are converted into output values y using the following equation:
y = x × scale + offsetThis 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 org.apache.sis.coverage.grid.GridCoverage2D.- Since:
- 0.5
- Version:
- 0.7
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform1D
AbstractMathTransform1D.Inverse -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.opengis.referencing.operation.MathTransform1DThe inverse of this transform.(package private) static final LinearTransform1DA transform that just reverse the sign of input values.(package private) final doubleThe value to add to input values.(package private) final doubleThe value which is multiplied to input values.private static final longSerial number for inter-operability with different versions.Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
MAXIMUM_BUFFER_SIZE, MAXIMUM_FAILURES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLinearTransform1D(double scale, double offset) Constructs a new linear transform. -
Method Summary
Modifier and TypeMethodDescriptionprotected intComputes a hash value for this transform.(package private) static LinearTransform1Dconstant(double x, double y) Creates a constant function having value y, and for which the inverse is x.static LinearTransform1Dcreate(double scale, double offset) Constructs a new linear transform.voiddeltaTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms many distance vectors in a list of coordinate values.doublederivative(double value) Gets the derivative of this function at a value.org.opengis.referencing.operation.Matrixderivative(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point.booleanequals(Object object, ComparisonMode mode) Compares the specified object with this math transform for equality.org.opengis.referencing.operation.MatrixReturns this transform as an affine transform matrix.org.opengis.parameter.ParameterDescriptorGroupReturns the parameter descriptors for this math transform.org.opengis.parameter.ParameterValueGroupReturns the matrix elements as a group of parameter values.inverse()Creates the inverse transform of this object.booleanisAffine()Returnstruesince this transform is affine.booleanTests whether this transform does not move any points.toString()Returns a string representation of this transform as a matrix, for consistency with otherLinearTransformimplementations in Apache SIS.doubletransform(double value) Transforms the specified value.org.opengis.referencing.operation.Matrixtransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) Transforms a single point in the given array and opportunistically computes its derivative if requested.voidtransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms many positions in a list of coordinate values.voidtransform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms many positions in a list of coordinate values.voidtransform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms many positions in a list of coordinate values.voidtransform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms many positions in a list of coordinate values.Methods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform1D
getSourceDimensions, getTargetDimensionsMethods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
beforeFormat, equals, formatTo, getContextualParameters, getDomain, hashCode, isInverseEquals, mismatchedDimension, transform, tryConcatenateMethods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toWKTMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opengis.referencing.operation.MathTransform
getSourceDimensions, getTargetDimensions, toWKT, transform
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
NEGATE
A transform that just reverse the sign of input values. -
scale
final double scaleThe value which is multiplied to input values. -
offset
final double offsetThe value to add to input values. -
inverse
private transient org.opengis.referencing.operation.MathTransform1D inverseThe inverse of this transform. Created only when first needed.
-
-
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.- See Also:
-
-
Method Details
-
create
Constructs a new linear transform.- Parameters:
scale- thescaleterm in the linear equation.offset- theoffsetterm in the linear equation.- Returns:
- the linear transform for the given scale and offset.
- See Also:
-
constant
Creates a constant function having value y, and for which the inverse is x.- Since:
- 0.7
-
getParameterDescriptors
public org.opengis.parameter.ParameterDescriptorGroup getParameterDescriptors()Returns the parameter descriptors for this math transform.- Specified by:
getParameterDescriptorsin interfaceParameterized- Overrides:
getParameterDescriptorsin classAbstractMathTransform- Returns:
- the parameter descriptors for this math transform, or
nullif unspecified. - See Also:
-
getParameterValues
public org.opengis.parameter.ParameterValueGroup getParameterValues()Returns the matrix elements as a group of parameter 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:
getParameterValuesin interfaceParameterized- Overrides:
getParameterValuesin classAbstractMathTransform- Returns:
- the parameter values for this math transform.
- See Also:
-
getMatrix
public org.opengis.referencing.operation.Matrix getMatrix()Returns this transform as an affine transform matrix.- Specified by:
getMatrixin interfaceLinearTransform- Returns:
- the coefficients of this linear transform as a matrix.
- See Also:
-
inverse
public LinearTransform1D inverse() throws org.opengis.referencing.operation.NoninvertibleTransformExceptionCreates the inverse transform of this object.- Specified by:
inversein interfaceLinearTransform- Specified by:
inversein interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
inversein interfaceorg.opengis.referencing.operation.MathTransform1D- Overrides:
inversein classAbstractMathTransform1D- Returns:
- the inverse transform.
- Throws:
org.opengis.referencing.operation.NoninvertibleTransformException- if the transform cannot be inverted.- See Also:
-
isAffine
public boolean isAffine()Returnstruesince this transform is affine.- Specified by:
isAffinein interfaceLinearTransform- Returns:
trueif this transform is affine.- See Also:
-
isIdentity
public boolean isIdentity()Tests whether this transform does not move any points.Note: this method should always returnsfalse, sinceMathTransforms.linear(…)should have created specialized implementations for identity cases. Nevertheless we perform the full check as a safety, in case someone instantiated this class directly instead of using a factory method.- Specified by:
isIdentityin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
isIdentityin classAbstractMathTransform
-
derivative
public org.opengis.referencing.operation.Matrix derivative(org.opengis.geometry.DirectPosition point) throws org.opengis.referencing.operation.TransformException Gets the derivative of this transform at a point.- Specified by:
derivativein interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
derivativein classAbstractMathTransform1D- Parameters:
point- ignored for a linear transform. Can be null.- Returns:
- the derivative at the given point.
- Throws:
org.opengis.referencing.operation.TransformException- if the derivative cannot be evaluated at the specified point.
-
derivative
public double derivative(double value) Gets the derivative of this function at a value.- Specified by:
derivativein interfaceorg.opengis.referencing.operation.MathTransform1D- Specified by:
derivativein classAbstractMathTransform1D- Parameters:
value- ignored for a linear transform. Can beNaN.- Returns:
- the derivative at the given point.
-
transform
public double transform(double value) Transforms the specified value.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform1D- Specified by:
transformin classAbstractMathTransform1D- Parameters:
value- the value to transform.- Returns:
- the transformed value.
-
transform
public org.opengis.referencing.operation.Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) Transforms a single point in the given array and opportunistically computes its derivative if requested. The default implementation computes all those values from thescaleandoffsetcoefficients.- Overrides:
transformin classAbstractMathTransform1D- Parameters:
srcPts- the array containing the source coordinates (cannot benull).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 thansrcPts. May benullif only the derivative matrix is desired.dstOff- the offset to the location of the transformed point that is stored in the destination array.derivate-truefor computing the derivative, orfalseif not needed.- Returns:
- the matrix of the transform derivative at the given source position,
or
nullif thederivateargument isfalse. - See Also:
-
transform
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms many positions in a list of coordinate values. The default implementation computes the values from thescaleandoffsetcoefficients.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- 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(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms many positions in a list of coordinate values. The default implementation computes the values from thescaleandoffsetcoefficients using thedoubleprecision, then casts the result to thefloattype.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- 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, float[] dstPts, int dstOff, int numPts) Transforms many positions in a list of coordinate values. The default implementation computes the values from thescaleandoffsetcoefficients using thedoubleprecision, then casts the result to thefloattype.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- 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.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 positions in a list of coordinate values. The default implementation computes the values from thescaleandoffsetcoefficients.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- 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.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.
-
deltaTransform
public void deltaTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms many distance vectors in a list of coordinate values. The default implementation computes the values from thescalecoefficient only.- Specified by:
deltaTransformin interfaceLinearTransform- Parameters:
srcPts- the array containing the source vectors.srcOff- the offset to the first vector to be transformed in the source array.dstPts- the array into which the transformed vectors are returned. Can be the same thansrcPts.dstOff- the offset to the location of the first transformed vector that is stored in the destination array.numPts- the number of vector objects to be transformed.- Since:
- 0.7
- See Also:
-
computeHashCode
protected int computeHashCode()Computes a hash value for this transform. This method is invoked byAbstractMathTransform.hashCode()when first needed.- Overrides:
computeHashCodein classAbstractMathTransform- Returns:
- the hash code value. This value may change between different execution of the Apache SIS library.
-
equals
Compares the specified object with this math transform for equality. Two math transforms are considered equal if, given identical source positions, their transformed positions would be equal orapproximatelyequal. This method may conservatively returnsfalseif unsure.The default implementation returns
trueif the following conditions are met:objectis an instance of the same class thanthis. We require the same class because there is no interface for the various kinds of transform.- If the hash code value has already been computed for both instances, their values are the same (opportunist performance enhancement).
- The contextual parameters are equal according the given comparison mode.
- Specified by:
equalsin interfaceLenientComparable- Overrides:
equalsin classAbstractMathTransform- Parameters:
object- the object to compare with this transform.mode- the strictness level of the comparison. Default toSTRICT.- Returns:
trueif the given object is considered equals to this math transform.- See Also:
-
toString
Returns a string representation of this transform as a matrix, for consistency with otherLinearTransformimplementations in Apache SIS.- Overrides:
toStringin classFormattableObject- Returns:
- the Well Known Text (WKT) or an alternative representation of this object.
-