Class TranslationTransform
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.operation.transform.AbstractMathTransform
org.apache.sis.referencing.operation.transform.AbstractLinearTransform
org.apache.sis.referencing.operation.transform.TranslationTransform
- All Implemented Interfaces:
Serializable,ExtendedPrecisionMatrix,Parameterized,LinearTransform,LenientComparable,org.opengis.referencing.operation.MathTransform,org.opengis.referencing.operation.Matrix
An affine transform that translate the coordinate values by constant values.
Note: we do not provide two-dimensional specialization because
AffineTransform2D should be used in such case.- Since:
- 1.0
- Version:
- 1.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
AbstractMathTransform.Inverse -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double[]The error terms in double-double arithmetic, ornullif none.private final double[]Translation terms, to be applied in the same order than coordinate values.private static final longSerial number for inter-operability with different versions.Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractLinearTransform
inverseFields inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
MAXIMUM_BUFFER_SIZE, MAXIMUM_FAILURESFields inherited from interface org.apache.sis.internal.referencing.ExtendedPrecisionMatrix
IDENTITY, ZERO -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)TranslationTransform(double[] offsets) Constructs a translation transform for the given offset vector.(package private)TranslationTransform(int dimension, double offset) Constructs an uniform translation transform for the given offset applied on all dimensions.(package private)TranslationTransform(int size, double[] elements) Constructs a translation transform from a matrix having the given elements.privateCreates a transform as the inverse of the given transform. -
Method Summary
Modifier and TypeMethodDescriptionprotected intComputes a hash value for this transform.(package private) final LinearTransformInvoked byAbstractLinearTransform.inverse()the first time that the inverse transform needs to be computed.org.opengis.referencing.operation.Matrixderivative(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point.protected booleanequalsSameClass(Object object) Compares this math transform with an object which is known to be an instance of the same class.doublegetElement(int row, int column) Returns the matrix element at the given index.double[]Returns a copy of matrix elements, including error terms if any.intGets the dimension of input points.intGets the dimension of output points.booleanTests whether this transform does not move any points.private static double[]negate(double[] array) Returns a new array with negative values of given array (can benull).org.opengis.referencing.operation.Matrixtransform(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.voidtransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.voidtransform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.voidtransform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.voidtransform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.Methods inherited from class org.apache.sis.referencing.operation.transform.AbstractLinearTransform
clone, deltaTransform, equals, getMatrix, getNumCol, getNumRow, getParameterDescriptors, getParameterValues, inverse, isAffine, setElement, toString, tryConcatenateMethods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
beforeFormat, equals, formatTo, getContextualParameters, getDomain, hashCode, isInverseEquals, mismatchedDimension, transformMethods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toWKTMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opengis.referencing.operation.MathTransform
toWKT, transformMethods inherited from interface org.opengis.referencing.operation.Matrix
clone, getNumCol, getNumRow, setElement
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
offsets
private final double[] offsetsTranslation terms, 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[] errorsThe error terms in double-double arithmetic, ornullif none. May be shorter thanoffsetsif all remaining errors are zero.
-
-
Constructor Details
-
TranslationTransform
TranslationTransform(int dimension, double offset) Constructs an uniform translation transform for the given offset applied on all dimensions. -
TranslationTransform
TranslationTransform(double[] offsets) Constructs a translation transform for the given offset vector. -
TranslationTransform
Creates a transform as the inverse of the given transform. -
TranslationTransform
TranslationTransform(int size, double[] elements) Constructs a translation transform from a matrix having the given elements. This constructors assumes that the matrix is square, affine and contains only translation terms (this is not verified).
-
-
Method Details
-
negate
private static double[] negate(double[] array) Returns a new array with negative values of given array (can benull). -
getExtendedElements
public double[] getExtendedElements()Returns a copy of matrix elements, including error terms if any.- Specified by:
getExtendedElementsin interfaceExtendedPrecisionMatrix- Returns:
- a copy of matrix elements, potentially followed by error terms.
-
getSourceDimensions
public int getSourceDimensions()Gets the dimension of input points.- Specified by:
getSourceDimensionsin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
getSourceDimensionsin classAbstractMathTransform- Returns:
- the number of dimensions of input points.
- See Also:
-
getTargetDimensions
public int getTargetDimensions()Gets the dimension of output points.- Specified by:
getTargetDimensionsin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
getTargetDimensionsin classAbstractMathTransform- 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:
getElementin interfaceorg.opengis.referencing.operation.Matrix
-
isIdentity
public boolean isIdentity()Tests whether this transform does not move any points.- Specified by:
isIdentityin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
isIdentityin interfaceorg.opengis.referencing.operation.Matrix- Overrides:
isIdentityin classAbstractMathTransform
-
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:
transformin classAbstractMathTransform- 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 an array of floating point coordinates by this matrix. Point coordinates must have a dimension equal to. For example, for square matrix of size 4×4, coordinate points are three-dimensional and stored in the arrays starting at the specified offset (Matrix.getNumCol()-1srcOff) in the order[x₀, y₀, z₀, x₁, y₁, z₁..., xn, yn, zn].- 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. 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. For example, for square matrix of size 4×4, coordinate points are three-dimensional and stored in the arrays starting at the specified offset (Matrix.getNumCol()- 1srcOff) in the order[x₀, y₀, z₀, x₁, y₁, z₁..., xn, yn, zn].- 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. 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:
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 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:
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 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:
derivativein interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
derivativein classAbstractMathTransform- Parameters:
point- ignored (can benull).- Returns:
- the derivative at the specified point (never
null).
-
createInverse
Invoked byAbstractLinearTransform.inverse()the first time that the inverse transform needs to be computed.- Overrides:
createInversein classAbstractLinearTransform
-
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.
-
equalsSameClass
Compares this math transform with an object which is known to be an instance of the same class.- Specified by:
equalsSameClassin classAbstractLinearTransform- Parameters:
object- the object to compare with this transform.- Returns:
trueif the given object is considered equals to this math transform.
-