Package com.irurueta.geometry
Class Rotation2D
java.lang.Object
com.irurueta.geometry.Rotation2D
- All Implemented Interfaces:
Serializable
This class defines the amount of rotation for 2D points or lines.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault threshold to determine if two instances are equal.static final doubleConstant defining threshold to determine whether a matrix is orthogonal or not and has determinant equal to 1.static final doubleConstant defining minimum allowed comparison threshold.static final doubleConstant defining minimum allowed threshold.static final intConstant defining the number of columns on a 2D rotation matrix expressed in homogeneous coordinates.static final intConstant defining the number of rows on a 2D rotation matrix expressed in homogeneous coordinates.static final intConstant defining the number of columns on a 2D rotation matrix expressed in inhomogeneous coordinates.static final intConstant defining the number of rows on a 2D rotation matrix expressed in inhomogeneous coordinates.private doublePrivate member containing amount of rotation expressed in radians. -
Constructor Summary
ConstructorsConstructorDescriptionEmpty Constructor.Rotation2D(double theta) Constructor.Rotation2D(com.irurueta.algebra.Matrix m) Constructor.Rotation2D(com.irurueta.algebra.Matrix m, double threshold) Constructor.Rotation2D(Rotation2D rotation) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptioncom.irurueta.algebra.MatrixReturns this 2D rotation instance expressed as a 3x3 homogeneous matrix.voidasHomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 2D rotation expressed as a 3x3 homogeneous matrix.com.irurueta.algebra.MatrixReturns this 2D rotation instance expressed as a 2x2 inhomogeneous matrix.voidasInhomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 2D rotation expressed as a 2x2 inhomogeneous matrix.voidcombine(Rotation2D rotation) Combines provided rotation into this rotation resulting in the sum of both rotations.static voidcombine(Rotation2D rot1, Rotation2D rot2, Rotation2D result) Combines the rotation of instances rot1 and rot1 into provided result instance.combineAndReturnNew(Rotation2D rotation) Combines provided rotation with this rotation and returns the result as a new Rotation2D instance.booleanequals(Rotation2D other) Determines if two Rotation2D instances are equal or not (i.e. have the same rotation).booleanequals(Rotation2D other, double threshold) Determines if two Rotation2D instances are equal up to provided threshold or not (i.e. have the same rotation).booleanDetermines if two Rotation2D instances are equal or not (i.e. have the same rotation).voidfromHomogeneousMatrix(com.irurueta.algebra.Matrix m) Sets amount of rotation from provided homogeneous rotation matrix.voidfromHomogeneousMatrix(com.irurueta.algebra.Matrix m, double threshold) Sets amount of rotation from provided homogeneous rotation matrix.voidfromInhomogeneousMatrix(com.irurueta.algebra.Matrix m) Sets amount of rotation from provided inhomogeneous rotation matrix.voidfromInhomogeneousMatrix(com.irurueta.algebra.Matrix m, double threshold) Sets amount of rotation from provided inhomogeneous rotation matrix.final voidfromMatrix(com.irurueta.algebra.Matrix m) Sets amount of rotation from provided rotation matrix.final voidfromMatrix(com.irurueta.algebra.Matrix m, double threshold) Sets amount of rotation from provided rotation matrix.doublegetTheta()Returns rotation amount expressed in radians.inthashCode()Hash code to compare instances.Returns a 2D rotation which is inverse to this instance.voidinverseRotation(Rotation2D result) Sets into provided Rotation2D instance a rotation inverse to this instance.static booleanisValidRotationMatrix(com.irurueta.algebra.Matrix m) Returns boolean indicating whether provided matrix is a valid matrix for a rotation.static booleanisValidRotationMatrix(com.irurueta.algebra.Matrix m, double threshold) Returns boolean indicating whether provided matrix is a valid matrix for a rotation.Returns a line containing a rotated version of provided line.voidRotates a line using the origin of coordinates as the axis of rotation.Returns a 2D point containing a rotated version of provided point.voidRotates a 2D point using the origin of coordinates as the axis of rotation.voidsetTheta(double theta) Sets rotation amount expressed in radians.
-
Field Details
-
ROTATION2D_INHOM_MATRIX_ROWS
public static final int ROTATION2D_INHOM_MATRIX_ROWSConstant defining the number of rows on a 2D rotation matrix expressed in inhomogeneous coordinates.- See Also:
-
ROTATION2D_INHOM_MATRIX_COLS
public static final int ROTATION2D_INHOM_MATRIX_COLSConstant defining the number of columns on a 2D rotation matrix expressed in inhomogeneous coordinates.- See Also:
-
ROTATION2D_HOM_MATRIX_ROWS
public static final int ROTATION2D_HOM_MATRIX_ROWSConstant defining the number of rows on a 2D rotation matrix expressed in homogeneous coordinates.- See Also:
-
ROTATION2D_HOM_MATRIX_COLS
public static final int ROTATION2D_HOM_MATRIX_COLSConstant defining the number of columns on a 2D rotation matrix expressed in homogeneous coordinates.- See Also:
-
MATRIX_VALID_THRESHOLD
public static final double MATRIX_VALID_THRESHOLDConstant defining threshold to determine whether a matrix is orthogonal or not and has determinant equal to 1. Rotation matrices must fulfill those requirements.- See Also:
-
MIN_THRESHOLD
public static final double MIN_THRESHOLDConstant defining minimum allowed threshold.- See Also:
-
DEFAULT_COMPARISON_THRESHOLD
public static final double DEFAULT_COMPARISON_THRESHOLDDefault threshold to determine if two instances are equal.- See Also:
-
MIN_COMPARISON_THRESHOLD
public static final double MIN_COMPARISON_THRESHOLDConstant defining minimum allowed comparison threshold.- See Also:
-
theta
private double thetaPrivate member containing amount of rotation expressed in radians.
-
-
Constructor Details
-
Rotation2D
public Rotation2D()Empty Constructor. Initializes rotation to zero radians. -
Rotation2D
Copy constructor. Copies provided rotation into this instance.- Parameters:
rotation- Instance to be copied.
-
Rotation2D
Constructor. Creates a 2D rotation using provided matrix. Provided matrix can be expressed in either homogeneous or inhomogeneous coordinates, and it must also be orthogonal and having determinant equal to 1. The threshold to determine whether provided matrix is orthonormal will be MATRIX_VALID_THRESHOLD.- Parameters:
m- Matrix to create rotation from.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (its size is wrong, or it is not orthonormal).- See Also:
-
Rotation2D
public Rotation2D(com.irurueta.algebra.Matrix m, double threshold) throws InvalidRotationMatrixException Constructor. Creates a 2D rotation using provided matrix. Provided matrix can be expressed in either homogeneous or inhomogeneous coordinates, and it must also be orthogonal up to provided threshold, and must have determinant equal to 1.- Parameters:
m- Matrix to create rotation from.threshold- Threshold to determine whether matrix is orthonormal.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (its size is wrong, or it is not orthonormal).IllegalArgumentException- Raised if provided threshold is negative- See Also:
-
Rotation2D
public Rotation2D(double theta) Constructor. Creates a 2D rotation using provided rotation value expressed in radians- Parameters:
theta- Rotation amount expressed in radians.
-
-
Method Details
-
getTheta
public double getTheta()Returns rotation amount expressed in radians.- Returns:
- Rotation amount expressed in radians.
-
setTheta
public void setTheta(double theta) Sets rotation amount expressed in radians.- Parameters:
theta- rotation angle.
-
inverseRotation
Returns a 2D rotation which is inverse to this instance. In other words, the combination of this rotation with its inverse produces no change.- Returns:
- Inverse 2D rotation.
-
inverseRotation
Sets into provided Rotation2D instance a rotation inverse to this instance. The combination of this rotation with its inverse produces no change.- Parameters:
result- Instance where inverse rotation will be set.
-
asInhomogeneousMatrix
public com.irurueta.algebra.Matrix asInhomogeneousMatrix()Returns this 2D rotation instance expressed as a 2x2 inhomogeneous matrix.- Returns:
- Rotation matrix expressed in inhomogeneous coordinates.
-
asInhomogeneousMatrix
public void asInhomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 2D rotation expressed as a 2x2 inhomogeneous matrix.- Parameters:
result- Matrix where rotation will be set.- Throws:
IllegalArgumentException- Raised if provided instance does not have size 2x2.
-
asHomogeneousMatrix
public com.irurueta.algebra.Matrix asHomogeneousMatrix()Returns this 2D rotation instance expressed as a 3x3 homogeneous matrix.- Returns:
- Rotation matrix expressed in homogeneous coordinates.
-
asHomogeneousMatrix
public void asHomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 2D rotation expressed as a 3x3 homogeneous matrix.- Parameters:
result- Matrix where rotation will be set.- Throws:
IllegalArgumentException- Raised if provided instance does not have size 3x3.
-
fromMatrix
public final void fromMatrix(com.irurueta.algebra.Matrix m, double threshold) throws InvalidRotationMatrixException Sets amount of rotation from provided rotation matrix. Provided matrix must be orthogonal (i.e. squared, non-singular, it's transpose must be its inverse) and must have determinant equal to 1. Provided matrix can be expressed in either inhomogeneous (2x2) or homogeneous (3x3) coordinates.- Parameters:
m- Provided rotation matrix.threshold- Threshold to determine whether matrix is orthonormal.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (has wrong size, or it is not orthonormal).IllegalArgumentException- Raised if provided threshold is negative- See Also:
-
fromMatrix
Sets amount of rotation from provided rotation matrix. Provided matrix must be orthogonal (i.e. squared, non-singular, it's transpose must be its inverse) and must have determinant equal to 1. Provided matrix can be expressed in either inhomogeneous (2x2) or homogeneous (3x3) coordinates. Because threshold is not provided it is used MATRIX_VALID_THRESHOLD instead.- Parameters:
m- Provided rotation matrix.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (has wrong size, or it is not orthonormal).- See Also:
-
fromInhomogeneousMatrix
public void fromInhomogeneousMatrix(com.irurueta.algebra.Matrix m, double threshold) throws InvalidRotationMatrixException Sets amount of rotation from provided inhomogeneous rotation matrix. Provided matrix must be orthogonal (i.e. squared, non-singular, it's transpose must be its inverse) and must have determinant equal to 1. Provided matrix must also have size 2x2.- Parameters:
m- Provided rotation matrix.threshold- Threshold to determine whether matrix is orthonormal.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (has wrong size, or it is not orthonormal).IllegalArgumentException- Raised if provided threshold is negative.- See Also:
-
fromInhomogeneousMatrix
public void fromInhomogeneousMatrix(com.irurueta.algebra.Matrix m) throws InvalidRotationMatrixException Sets amount of rotation from provided inhomogeneous rotation matrix. Provided matrix must be orthogonal (i.e. squared, non-singular, it's transpose must be its inverse) and must have determinant equal to 1. Provided matrix must also have size 2x2. Because threshold is not provided it is used MATRIX_VALID_THRESHOLD instead.- Parameters:
m- Provided rotation matrix.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (has wrong size, or it is not orthonormal).- See Also:
-
fromHomogeneousMatrix
public void fromHomogeneousMatrix(com.irurueta.algebra.Matrix m, double threshold) throws InvalidRotationMatrixException Sets amount of rotation from provided homogeneous rotation matrix. Provided matrix must be orthogonal (i.e. squared, non-singular, it's transpose must be its inverse) and must have determinant equal to 1. Provided matrix must also have size 3x3, and its last row and column must be zero, except for element in last row and column which must be 1.- Parameters:
m- Provided rotation matrix.threshold- Threshold to determine whether matrix is orthonormal.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (has wrong size, or it is not orthonormal).IllegalArgumentException- Raised if provided threshold is negative.- See Also:
-
fromHomogeneousMatrix
public void fromHomogeneousMatrix(com.irurueta.algebra.Matrix m) throws InvalidRotationMatrixException Sets amount of rotation from provided homogeneous rotation matrix. Provided matrix must be orthogonal (i.e. squared, non-singular), its transpose must be its inverse and must have determinant equal to 1. Provided matrix must also have size 3x3, and its last row and column must be zero, except for element in last row and column which must be 1 Because threshold is not provided it is used MATRIX_VALID_THRESHOLD instead.- Parameters:
m- Provided rotation matrix.- Throws:
InvalidRotationMatrixException- Raised if provided matrix is not valid (has wrong size, or it is not orthonormal).- See Also:
-
rotate
Rotates a 2D point using the origin of coordinates as the axis of rotation. Point will be rotated by the amount of rotation contained in this instance.- Parameters:
inputPoint- Input point to be rotated.resultPoint- Rotated point.
-
rotate
Returns a 2D point containing a rotated version of provided point. Point will be rotated using the origin of the coordinates as the axis of rotation. Point will be rotated by the amount of rotation contained in this instance.- Parameters:
point- Point to be rotated.- Returns:
- Rotated point.
-
rotate
Rotates a line using the origin of coordinates as the axis of rotation. Line2D will be rotated by the amount of rotation contained in this instance.- Parameters:
inputLine- Input line to be rotated.resultLine- Rotated line.
-
rotate
Returns a line containing a rotated version of provided line. Line2D will be rotated using the origin of the coordinates as the axis of rotation. Line2D will be rotated by the amount of rotation contained in this instance.- Parameters:
line- Line2D to be rotated.- Returns:
- Rotated line.
-
isValidRotationMatrix
public static boolean isValidRotationMatrix(com.irurueta.algebra.Matrix m, double threshold) Returns boolean indicating whether provided matrix is a valid matrix for a rotation. Rotation matrices must be orthogonal and must have determinant equal to 1.- Parameters:
m- Input matrix to be checked.threshold- Threshold to determine whether matrix is orthogonal and whether determinant is one.- Returns:
- True if matrix is valid, false otherwise.
- Throws:
IllegalArgumentException- Raised if provided threshold is negative.
-
isValidRotationMatrix
public static boolean isValidRotationMatrix(com.irurueta.algebra.Matrix m) Returns boolean indicating whether provided matrix is a valid matrix for a rotation. Rotation matrices must be orthogonal and must have determinant equal to 1 Because threshold is not provided, it is used MATRIX_VALID_THRESHOLD instead.- Parameters:
m- Input matrix to be checked.- Returns:
- True if matrix is valid, false otherwise.
- Throws:
IllegalArgumentException- Raised if provided threshold is negative.
-
combineAndReturnNew
Combines provided rotation with this rotation and returns the result as a new Rotation2D instance.- Parameters:
rotation- Input rotation to be combined.- Returns:
- Combined rotation, which is equal to the sum of provided rotation with this rotation.
-
combine
Combines provided rotation into this rotation resulting in the sum of both rotations.- Parameters:
rotation- Input rotation to be combined.
-
combine
Combines the rotation of instances rot1 and rot1 into provided result instance.- Parameters:
rot1- 1st input rotation.rot2- 2nd input rotation.result- Combined rotation, which is equal to the sum of provided input rotations.
-
equals
Determines if two Rotation2D instances are equal up to provided threshold or not (i.e. have the same rotation).- Parameters:
other- other rotation to compare.threshold- threshold to determine if they are equal.- Returns:
- true if they are equal, false otherwise.
- Throws:
IllegalArgumentException- if threshold is negative.
-
equals
Determines if two Rotation2D instances are equal or not (i.e. have the same rotation).- Parameters:
other- other object to compare.- Returns:
- true if they are equal, false otherwise.
-
equals
Determines if two Rotation2D instances are equal or not (i.e. have the same rotation). -
hashCode
public int hashCode()Hash code to compare instances.
-