Class AffineTransformationBuilder
- java.lang.Object
-
- org.locationtech.jts.geom.util.AffineTransformationBuilder
-
public class AffineTransformationBuilder extends java.lang.Object
Builds anAffineTransformation
defined by a set of control vectors. A control vector consists of a source point and a destination point, which is the image of the source point under the desired transformation.A transformation is well-defined by a set of three control vectors if and only if the source points are not collinear. (In particular, the degenerate situation where two or more source points are identical will not produce a well-defined transformation). A well-defined transformation exists and is unique. If the control vectors are not well-defined, the system of equations defining the transformation matrix entries is not solvable, and no transformation can be determined.
No such restriction applies to the destination points. However, if the destination points are collinear or non-unique, a non-invertible transformations will be generated.
This technique of recovering a transformation from its effect on known points is used in the Bilinear Interpolated Triangulation algorithm for warping planar surfaces.
-
-
Field Summary
Fields Modifier and Type Field Description private Coordinate
dest0
private Coordinate
dest1
private Coordinate
dest2
private double
m00
private double
m01
private double
m02
private double
m10
private double
m11
private double
m12
private Coordinate
src0
private Coordinate
src1
private Coordinate
src2
-
Constructor Summary
Constructors Constructor Description AffineTransformationBuilder(Coordinate src0, Coordinate src1, Coordinate src2, Coordinate dest0, Coordinate dest1, Coordinate dest2)
Constructs a new builder for the transformation defined by the given set of control point mappings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
compute()
Computes the transformation matrix by solving the two systems of linear equations defined by the control point mappings, if this is possible.AffineTransformation
getTransformation()
Computes theAffineTransformation
determined by the control point mappings, ornull
if the control vectors do not determine a well-defined transformation.private double[]
solve(double[] b)
Solves the transformation matrix system of linear equations for the given right-hand side vector.
-
-
-
Field Detail
-
src0
private Coordinate src0
-
src1
private Coordinate src1
-
src2
private Coordinate src2
-
dest0
private Coordinate dest0
-
dest1
private Coordinate dest1
-
dest2
private Coordinate dest2
-
m00
private double m00
-
m01
private double m01
-
m02
private double m02
-
m10
private double m10
-
m11
private double m11
-
m12
private double m12
-
-
Constructor Detail
-
AffineTransformationBuilder
public AffineTransformationBuilder(Coordinate src0, Coordinate src1, Coordinate src2, Coordinate dest0, Coordinate dest1, Coordinate dest2)
Constructs a new builder for the transformation defined by the given set of control point mappings.- Parameters:
src0
- a control pointsrc1
- a control pointsrc2
- a control pointdest0
- the image of control point 0 under the required transformationdest1
- the image of control point 1 under the required transformationdest2
- the image of control point 2 under the required transformation
-
-
Method Detail
-
getTransformation
public AffineTransformation getTransformation()
Computes theAffineTransformation
determined by the control point mappings, ornull
if the control vectors do not determine a well-defined transformation.- Returns:
- an affine transformation
-
compute
private boolean compute()
Computes the transformation matrix by solving the two systems of linear equations defined by the control point mappings, if this is possible.- Returns:
- true if the transformation matrix is solvable
-
solve
private double[] solve(double[] b)
Solves the transformation matrix system of linear equations for the given right-hand side vector.- Parameters:
b
- the vector for the right-hand side of the system- Returns:
- the solution vector
-
-