public final class MathTransforms extends Static
MathTransform
instances.
This class centralizes in one place some of the most commonly used functions this package.
The MathTransforms
class provides the following services:
MathTransform
.MathTransformFactory
interface. However users seeking for more implementation neutrality are encouraged to limit themselves to the
GeoAPI factory interfaces instead.MathTransformFactory
Defined in the sis-referencing
module
Modifier and Type | Method and Description |
---|---|
static MathTransform |
compound(MathTransform... transforms)
Puts together a list of independent math transforms, each of them operating on a subset of ordinate values.
|
static MathTransform1D |
concatenate(MathTransform1D tr1,
MathTransform1D tr2)
Concatenates the given one-dimensional transforms.
|
static MathTransform1D |
concatenate(MathTransform1D tr1,
MathTransform1D tr2,
MathTransform1D tr3)
Concatenates the three given one-dimensional transforms.
|
static MathTransform2D |
concatenate(MathTransform2D tr1,
MathTransform2D tr2)
Concatenates the given two-dimensional transforms.
|
static MathTransform2D |
concatenate(MathTransform2D tr1,
MathTransform2D tr2,
MathTransform2D tr3)
Concatenates the three given two-dimensional transforms.
|
static MathTransform |
concatenate(MathTransform tr1,
MathTransform tr2)
Concatenates the two given transforms.
|
static MathTransform |
concatenate(MathTransform tr1,
MathTransform tr2,
MathTransform tr3)
Concatenates the three given transforms.
|
static Matrix |
derivativeAndTransform(MathTransform transform,
double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff)
A buckle method for calculating derivative and coordinate transformation in a single step.
|
static Matrix |
getMatrix(MathTransform transform)
If the given transform is linear, returns its coefficients as a matrix.
|
static List<MathTransform> |
getSteps(MathTransform transform)
Returns all single components of the given (potentially concatenated) transform.
|
static LinearTransform |
identity(int dimension)
Returns an identity transform of the specified dimension.
|
static MathTransform1D |
interpolate(double[] preimage,
double[] values)
Creates a transform for the y=f(x) function where y are computed by a linear interpolation.
|
static LinearTransform |
linear(double scale,
double offset)
Creates a one-dimensional affine transform for the given coefficients.
|
static LinearTransform |
linear(Matrix matrix)
Creates an arbitrary linear transform from the specified matrix.
|
public static LinearTransform identity(int dimension)
Special cases:
dimension == 1
, then the returned transform implements MathTransform1D
.dimension == 2
, then the returned transform implements MathTransform2D
.dimension
- the dimension of the transform to be returned.public static LinearTransform linear(double scale, double offset)
y = x ⋅scale
+offset
scale
- the scale
term in the linear equation.offset
- the offset
term in the linear equation.public static LinearTransform linear(Matrix matrix)
If the transform input dimension is M
, and output dimension is N
,
then the given matrix shall have size [N+1][M+1]
.
The +1 in the matrix dimensions allows the matrix to do a shift, as well as a rotation.
The [M][j]
element of the matrix will be the j'th ordinate of the moved origin.
matrix
- the matrix used to define the linear transform.getMatrix(MathTransform)
,
DefaultMathTransformFactory.createAffineTransform(Matrix)
public static MathTransform1D interpolate(double[] preimage, double[] values)
preimage
(the x) and values
(the y) arguments can be null:
preimage
and values
arrays are non-null, then the must have the same length.preimage
and values
arrays are null, then this method returns the identity transform.preimage
is null, then the x values are taken as {0, 1, 2, …, values.length
- 1}.values
is null, then the y values are taken as {0, 1, 2, …, preimage.length
- 1}.preimage
elements shall be real numbers (not NaN) sorted in increasing or decreasing order.
Elements in the values
array do not need to be ordered, but the returned transform will be invertible
only if all values are real numbers sorted in increasing or decreasing order.
Furthermore the returned transform is affine (i.e. implement the LinearTransform
interface)
if the interval between each preimage
and values
element is constant.
The current implementation uses linear interpolation. This may be changed in a future SIS version.
preimage
- the input values (x) in the function domain, or null
.values
- the output values (y) in the function range, or null
.public static MathTransform compound(MathTransform... transforms)
Invariants:
transforms
- the transforms to aggregate in a single transform, in the given order.null
if the given transforms
array was empty.PassThroughTransform
,
DefaultCompoundCRS
public static MathTransform concatenate(MathTransform tr1, MathTransform tr2) throws MismatchedDimensionException
MathTransform1D
or MathTransform2D
if the dimensions of the
concatenated transform are equal to 1 or 2 respectively.tr1
- the first math transform.tr2
- the second math transform.MismatchedDimensionException
- if the output dimension of the first transform
does not match the input dimension of the second transform.DefaultMathTransformFactory.createConcatenatedTransform(MathTransform, MathTransform)
public static MathTransform1D concatenate(MathTransform1D tr1, MathTransform1D tr2) throws MismatchedDimensionException
concatenate(MathTransform, MathTransform)
and casting the
result to a MathTransform1D
instance.tr1
- the first math transform.tr2
- the second math transform.MismatchedDimensionException
- if the output dimension of the first transform
does not match the input dimension of the second transform.public static MathTransform2D concatenate(MathTransform2D tr1, MathTransform2D tr2) throws MismatchedDimensionException
concatenate(MathTransform, MathTransform)
and casting the
result to a MathTransform2D
instance.tr1
- the first math transform.tr2
- the second math transform.MismatchedDimensionException
- if the output dimension of the first transform
does not match the input dimension of the second transform.public static MathTransform concatenate(MathTransform tr1, MathTransform tr2, MathTransform tr3) throws MismatchedDimensionException
tr1
- the first math transform.tr2
- the second math transform.tr3
- the third math transform.MismatchedDimensionException
- if the output dimension of a transform
does not match the input dimension of next transform.public static MathTransform1D concatenate(MathTransform1D tr1, MathTransform1D tr2, MathTransform1D tr3) throws MismatchedDimensionException
concatenate(MathTransform, MathTransform, MathTransform)
and
casting the result to a MathTransform1D
instance.tr1
- the first math transform.tr2
- the second math transform.tr3
- the third math transform.MismatchedDimensionException
- if the output dimension of a transform
does not match the input dimension of next transform.public static MathTransform2D concatenate(MathTransform2D tr1, MathTransform2D tr2, MathTransform2D tr3) throws MismatchedDimensionException
concatenate(MathTransform, MathTransform, MathTransform)
and
casting the result to a MathTransform2D
instance.tr1
- the first math transform.tr2
- the second math transform.tr3
- the third math transform.MismatchedDimensionException
- if the output dimension of a transform
does not match the input dimension of next transform.public static List<MathTransform> getSteps(MathTransform transform)
transform
is null
, returns an empty list.transform
is the result of a call to a concatenate(…)
method,
returns all components. All nested concatenated transforms (if any) will be flattened.transform
- the transform for which to get the components, or null
.public static Matrix getMatrix(MathTransform transform)
LinearTransform
,
returns LinearTransform.getMatrix()
.AffineTransform
,
returns its coefficients in a Matrix3
instance.null
.transform
- the transform for which to get the matrix, or null
.null
if none.linear(Matrix)
,
LinearTransform.getMatrix()
public static Matrix derivativeAndTransform(MathTransform transform, double[] srcPts, int srcOff, double[] dstPts, int dstOff) throws TransformException
MathTransform
implementations:
DirectPosition ptSrc = ...; DirectPosition ptDst = ...; Matrix matrixDst = derivative(ptSrc); ptDst = transform(ptSrc, ptDst);
transform
- the transform to use.srcPts
- the array containing the source coordinate.srcOff
- the offset to the point to be transformed in the source array.dstPts
- the array into which the transformed coordinate is returned.dstOff
- the offset to the location of the transformed point that is stored in the destination array.TransformException
- if the point can't be transformed or if a problem occurred
while calculating the derivative.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.