Package com.irurueta.geometry
Class AffineParameters2D
java.lang.Object
com.irurueta.geometry.AffineParameters2D
- All Implemented Interfaces:
Serializable
This class defines additional parameters that can be defined on affine
2D transformations.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault scale value having no effect on transformations.static final doubleDefault skewness value having no effect on transformations.private static final doubleDefault threshold to determine whether a matrix is a valid 2x2 upper triangular one.static final intNumber of inhomogeneous coordinates in 2D space.private doubleHorizontal scale.private doubleVertical scale.private doubleSkewness factor. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.AffineParameters2D(double scale) Constructor with scale.AffineParameters2D(double scale, double skewness) Constructor with scale and skewness.AffineParameters2D(double scaleX, double scaleY, double skewness) Constructor with horizontal scale, vertical scale and skewness.AffineParameters2D(com.irurueta.algebra.Matrix m) Constructor with matrix.AffineParameters2D(com.irurueta.algebra.Matrix m, double threshold) Constructor with matrix and threshold. -
Method Summary
Modifier and TypeMethodDescriptioncom.irurueta.algebra.MatrixasMatrix()Converts this affine parameters instance into matrix representation.voidasMatrix(com.irurueta.algebra.Matrix m) Converts this affine parameters instance into matrix representation and stores the result into provided matrix.final voidfromMatrix(com.irurueta.algebra.Matrix m) Sets parameters of this instance from provided matrix.final voidfromMatrix(com.irurueta.algebra.Matrix m, double threshold) Sets parameters of this instance from provided matrix.doubleReturns horizontal scale.doubleReturns vertical scale.doubleReturns skewness value.static booleanisValidMatrix(com.irurueta.algebra.Matrix m) Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters from.static booleanisValidMatrix(com.irurueta.algebra.Matrix m, double threshold) Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters form.voidsetScale(double scale) Sets overall scale (both, horizontal and vertical).voidsetScaleX(double scaleX) Sets horizontal scale.voidsetScaleY(double scaleY) Sets vertical scale.voidsetSkewness(double skewness) Sets skewness value.
-
Field Details
-
DEFAULT_SCALE
public static final double DEFAULT_SCALEDefault scale value having no effect on transformations.- See Also:
-
DEFAULT_SKEWNESS
public static final double DEFAULT_SKEWNESSDefault skewness value having no effect on transformations.- See Also:
-
INHOM_COORDS
public static final int INHOM_COORDSNumber of inhomogeneous coordinates in 2D space.- See Also:
-
DEFAULT_VALID_THRESHOLD
private static final double DEFAULT_VALID_THRESHOLDDefault threshold to determine whether a matrix is a valid 2x2 upper triangular one.- See Also:
-
scaleX
private double scaleXHorizontal scale. -
scaleY
private double scaleYVertical scale. -
skewness
private double skewnessSkewness factor. If 0.0, horizontal and vertical axes remain orthogonal, otherwise they get slanted.
-
-
Constructor Details
-
AffineParameters2D
public AffineParameters2D()Constructor. Sets default scale and skewness -
AffineParameters2D
public AffineParameters2D(double scale) Constructor with scale. Sets default skewness and provided scale.- Parameters:
scale- Scale to be set (both, horizontal and vertical). A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.
-
AffineParameters2D
public AffineParameters2D(double scale, double skewness) Constructor with scale and skewness.- Parameters:
scale- Scale to be set (both, horizontal and vertical). A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.skewness- Skewness to be set.
-
AffineParameters2D
public AffineParameters2D(double scaleX, double scaleY, double skewness) Constructor with horizontal scale, vertical scale and skewness.- Parameters:
scaleX- Horizontal scale to be set. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.scaleY- Vertical scale to be set. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.skewness- Skewness to be set.
-
AffineParameters2D
public AffineParameters2D(com.irurueta.algebra.Matrix m, double threshold) Constructor with matrix and threshold.- Parameters:
m- Upper triangular matrix to extract affine parameters from.threshold- Threshold to determine whether provided matrix is a valid upper triangular one.- Throws:
IllegalArgumentException- Raised if provided matrix is not 2x2 or if it is not upper triangular, or if threshold is negative.
-
AffineParameters2D
public AffineParameters2D(com.irurueta.algebra.Matrix m) Constructor with matrix.- Parameters:
m- Upper triangular matrix to extract affine parameters from.- Throws:
IllegalArgumentException- Raised if provided matrix is not 2x2 or if it is not upper triangular.
-
-
Method Details
-
getScaleX
public double getScaleX()Returns horizontal scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.- Returns:
- Horizontal scale.
-
setScaleX
public void setScaleX(double scaleX) Sets horizontal scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.- Parameters:
scaleX- Horizontal scale to be set.
-
getScaleY
public double getScaleY()Returns vertical scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.- Returns:
- Vertical scale.
-
setScaleY
public void setScaleY(double scaleY) Sets vertical scale. A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.- Parameters:
scaleY- Vertical scale to be set.
-
setScale
public void setScale(double scale) Sets overall scale (both, horizontal and vertical). A value between 0.0 and 1.0 will reduce objects size, a value larger than 1.0 will enlarge objects size, and negative values will reverse objects.- Parameters:
scale- Horizontal and vertical scale to be set.
-
getSkewness
public double getSkewness()Returns skewness value. A value of 0.0 indicates that horizontal and vertical axis are orthogonal, otherwise they are slanted to each other.- Returns:
- Skewness value.
-
setSkewness
public void setSkewness(double skewness) Sets skewness value. A value of 0.0 indicates that horizontal and vertical axis are orthogonal, otherwise they are slanted to each other.- Parameters:
skewness- Skewness to be set.
-
asMatrix
public com.irurueta.algebra.Matrix asMatrix()Converts this affine parameters instance into matrix representation.- Returns:
- A matrix representation of this instance.
-
asMatrix
public void asMatrix(com.irurueta.algebra.Matrix m) Converts this affine parameters instance into matrix representation and stores the result into provided matrix.- Parameters:
m- Matrix where representation of this instance will be stored.- Throws:
IllegalArgumentException- Raised if provided matrix is not 2x2.
-
fromMatrix
public final void fromMatrix(com.irurueta.algebra.Matrix m) Sets parameters of this instance from provided matrix.- Parameters:
m- Matrix to set parameters from. Provided matrix must be 2x2 and upper triangular.- Throws:
IllegalArgumentException- Raised if provided matrix is not 2x2 or if it is not upper triangular.
-
fromMatrix
public final void fromMatrix(com.irurueta.algebra.Matrix m, double threshold) Sets parameters of this instance from provided matrix.- Parameters:
m- Matrix to set parameters from. Provided matrix must be 2x2 and upper triangular up to provided threshold.threshold- Threshold to determine whether provided matrix is upper triangular. Matrix will be considered upper triangular if its lower triangular elements are smaller or equal than provided threshold.- Throws:
IllegalArgumentException- Raised if provided matrix is not 2x2 or if it is not upper triangular or if threshold is negative.
-
isValidMatrix
public static boolean isValidMatrix(com.irurueta.algebra.Matrix m) Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters from. Valid matrices need to be 2x2 and upper triangular.- Parameters:
m- A matrix to determine whether it is valid to set affine parameters from.- Returns:
- True if matrix is valid, false otherwise.
-
isValidMatrix
public static boolean isValidMatrix(com.irurueta.algebra.Matrix m, double threshold) Returns boolean indicating whether provided matrix is a valid matrix to set affine parameters form. Valid matrices need to be 2x2 and upper triangular up to provided threshold. In Layman terms, a valid matrix lower triangular elements need to be smaller or equal than provided threshold.- Parameters:
m- A matrix to determine whether it is valid to set affine parameters from.threshold- A threshold to determine whether provided matrix is upper triangular. Matrix will be considered upper triangular if its lower triangular elements are smaller or equal than provided threshold (without taking into account the sign of the elements).- Returns:
- True if matrix is valid, false otherwise.
- Throws:
IllegalArgumentException- Raised if provided threshold is negative.
-