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 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 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 expanded.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–2015 The Apache Software Foundation. All rights reserved.