Class ProjectiveTransform
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.ProjectiveTransform
- All Implemented Interfaces:
Serializable
,ExtendedPrecisionMatrix
,Parameterized
,LinearTransform
,LenientComparable
,org.opengis.referencing.operation.MathTransform
,org.opengis.referencing.operation.Matrix
- Direct Known Subclasses:
ProjectiveTransform2D
A usually affine, or otherwise a projective transform for the generic cases.
This implementation is used for cases other than identity, 1D, 2D or axis swapping.
A projective transform is capable of mapping an arbitrary quadrilateral into another arbitrary quadrilateral, while preserving the straightness of lines. In the special case where the transform is affine, the parallelism of lines in the source is preserved in the output.
- Since:
- 0.5
- Version:
- 1.2
- 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[]
Elements of the matrix.private final int
The number of columns.private final int
The number of rows.private static final long
Serial number for inter-operability with different versions.Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractLinearTransform
inverse
Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
MAXIMUM_BUFFER_SIZE, MAXIMUM_FAILURES
Fields inherited from interface org.apache.sis.internal.referencing.ExtendedPrecisionMatrix
IDENTITY, ZERO
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ProjectiveTransform
(org.opengis.referencing.operation.Matrix matrix) Constructs a transform from the specified matrix. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Computes a hash value for this transform.final org.opengis.referencing.operation.Matrix
derivative
(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point.protected boolean
equalsSameClass
(Object object) Compares this math transform with an object which is known to be an instance of the same class.final double
getElement
(int row, int column) Returns the matrix element at the given index.final double[]
Returns a copy of matrix elements, including error terms if any.final int
Gets the number of columns in the matrix.final int
Gets the number of rows in the matrix.final int
Gets the dimension of input points.final int
Gets the dimension of output points.final boolean
Tests whether this transform does not move any points.(package private) final LinearTransform
optimize()
If a more efficient implementation of this math transform can be used, returns it.final org.opengis.referencing.operation.Matrix
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) Converts a single coordinate tuple in a list of coordinate values, and optionally computes the derivative at that location.final void
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.final void
transform
(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.final void
transform
(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.final void
transform
(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, createInverse, deltaTransform, equals, getMatrix, getParameterDescriptors, getParameterValues, inverse, isAffine, setElement, toString, tryConcatenate
Methods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
beforeFormat, equals, formatTo, getContextualParameters, getDomain, hashCode, isInverseEquals, mismatchedDimension, transform
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toWKT
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opengis.referencing.operation.MathTransform
toWKT, transform
Methods inherited from interface org.opengis.referencing.operation.Matrix
clone, setElement
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
numRow
private final int numRowThe number of rows. -
numCol
private final int numColThe number of columns. -
elt
private final double[] elt
-
-
Constructor Details
-
ProjectiveTransform
protected ProjectiveTransform(org.opengis.referencing.operation.Matrix matrix) Constructs a transform from the specified matrix. The matrix is usually square and affine, but this is not enforced.- Parameters:
matrix
- the matrix.
-
-
Method Details
-
optimize
If a more efficient implementation of this math transform can be used, returns it. Otherwise returnsthis
unchanged. -
getSourceDimensions
public final int getSourceDimensions()Gets the dimension of input points.- Specified by:
getSourceDimensions
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
getSourceDimensions
in classAbstractMathTransform
- Returns:
- the number of dimensions of input points.
- See Also:
-
getTargetDimensions
public final int getTargetDimensions()Gets the dimension of output points.- Specified by:
getTargetDimensions
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
getTargetDimensions
in classAbstractMathTransform
- Returns:
- the number of dimensions of output points.
- See Also:
-
getNumRow
public final int getNumRow()Gets the number of rows in the matrix.- Specified by:
getNumRow
in interfaceorg.opengis.referencing.operation.Matrix
- Overrides:
getNumRow
in classAbstractLinearTransform
-
getNumCol
public final int getNumCol()Gets the number of columns in the matrix.- Specified by:
getNumCol
in interfaceorg.opengis.referencing.operation.Matrix
- Overrides:
getNumCol
in classAbstractLinearTransform
-
getExtendedElements
public final double[] getExtendedElements()Returns a copy of matrix elements, including error terms if any.- Specified by:
getExtendedElements
in interfaceExtendedPrecisionMatrix
- Returns:
- a copy of matrix elements, potentially followed by error terms.
-
getElement
public final double getElement(int row, int column) Returns the matrix element at the given index.- Specified by:
getElement
in interfaceorg.opengis.referencing.operation.Matrix
-
isIdentity
public final 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:
isIdentity
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
isIdentity
in interfaceorg.opengis.referencing.operation.Matrix
- Overrides:
isIdentity
in classAbstractMathTransform
-
transform
public final org.opengis.referencing.operation.Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) Converts a single coordinate tuple in a list of coordinate values, and optionally computes the derivative at that location.- Specified by:
transform
in 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 benull
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, orfalse
if not needed.- Returns:
- the matrix of the transform derivative at the given source position,
or
null
if thederivate
argument isfalse
. - See Also:
-
transform
public final 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:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in 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 final 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:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in 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 final 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 interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in 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 final 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 interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in 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 final org.opengis.referencing.operation.Matrix derivative(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point. For an affine transform, the derivative is the same everywhere and the given point is ignored. For a perspective transform, the given point is used.- Specified by:
derivative
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
derivative
in classAbstractMathTransform
- Parameters:
point
- the coordinate tuple where to evaluate the derivative.- Returns:
- the derivative at the specified point (never
null
).
-
computeHashCode
protected int computeHashCode()Computes a hash value for this transform. This method is invoked byAbstractMathTransform.hashCode()
when first needed.- Overrides:
computeHashCode
in 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:
equalsSameClass
in classAbstractLinearTransform
- Parameters:
object
- the object to compare with this transform.- Returns:
true
if the given object is considered equals to this math transform.
-