Package qupath.lib.awt.common
Class AffineTransforms
java.lang.Object
qupath.lib.awt.common.AffineTransforms
Helper class for working with affine transforms.
 
 QuPath's core dependencies have two affine transform implementations: AffineTransform from Java itself 
 and AffineTransformation from Java Topology Suite.
 Inconveniently, both are initialized from flattened double arrays using a different ordering (assuming 
 columns-first or rows-first) - so it is easy to make mistakes.
 
 QuPath primarily uses AffineTransform from Java.
 This class exists to make creating a transform more explicit, and facilitate conversion when needed.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic AffineTransformfrom2D(double[][] mat) Create an affine transform from a 2x3 double array, or 3x3 if the last row has the values [0, 0, 1] only.static AffineTransformfromColumns(double... mat) Create an affine transform from a flat matrix with 6 elements, assumed to be in the order[[0, 2, 4], [1, 3, 5]].static AffineTransformfromJTS(AffineTransformation transform) Create a Java affine transform from a Java Topology Suite representation.static AffineTransformfromRows(double... mat) Create an affine transform from a flat matrix with 6 elements, assumed to be in the order[[0, 1, 2], [3, 4, 5]].static AffineTransformfromScale(double scale) Create an affine transform representing scaling, using the same scale for x and y.static AffineTransformfromScale(double scaleX, double scaleY) Create an affine transform representing scaling, optionally using a different scale for x and y.static AffineTransformidentity()Create an affine transform representing the identity transform.static AffineTransformationtoJTS(AffineTransform transform) Create a Java Topology Suite affine transformation from a Java affine transform.
- 
Constructor Details- 
AffineTransformspublic AffineTransforms()
 
- 
- 
Method Details- 
from2DCreate an affine transform from a 2x3 double array, or 3x3 if the last row has the values [0, 0, 1] only.- Parameters:
- mat-
- Returns:
- Throws:
- IllegalArgumentException- if the input has the wrong shape
 
- 
fromRowsCreate an affine transform from a flat matrix with 6 elements, assumed to be in the order[[0, 1, 2], [3, 4, 5]].- Parameters:
- mat-
- Returns:
- Throws:
- IllegalArgumentException- if the input has the wrong length
 
- 
fromColumnsCreate an affine transform from a flat matrix with 6 elements, assumed to be in the order[[0, 2, 4], [1, 3, 5]].- Parameters:
- mat-
- Returns:
- Throws:
- IllegalArgumentException- if the input has the wrong length
 
- 
fromScaleCreate an affine transform representing scaling, optionally using a different scale for x and y.- Parameters:
- scaleX-
- scaleY-
- Returns:
 
- 
fromScaleCreate an affine transform representing scaling, using the same scale for x and y.- Parameters:
- scale-
- Returns:
 
- 
identityCreate an affine transform representing the identity transform.- Returns:
 
- 
fromJTSCreate a Java affine transform from a Java Topology Suite representation.- Parameters:
- transform-
- Returns:
 
- 
toJTSCreate a Java Topology Suite affine transformation from a Java affine transform.- Parameters:
- transform-
- Returns:
 
 
-