Package com.irurueta.geometry
Class AxisRotation3D
java.lang.Object
com.irurueta.geometry.Rotation3D
com.irurueta.geometry.AxisRotation3D
- All Implemented Interfaces:
Serializable
This class defines the amount of rotation for 3D points or planes.
Rotation is defined internally as axis coordinates and rotation angle,
following Rodrigues formulas.
This class is based in:
http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/sfrotation_java.htm
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intNumber of parameters defining a rotation axis.private doublex element of axis angle.private doubley element of axis angle.private doublez element of axis angle.static final doubleConstant defining machine precision.private doubleangle element of axis angle.Fields inherited from class com.irurueta.geometry.Rotation3D
DEFAULT_COMPARISON_THRESHOLD, DEFAULT_TYPE, DEFAULT_VALID_THRESHOLD, HOM_COORDS, INHOM_COORDS, MIN_THRESHOLD -
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor.AxisRotation3D(double[] axis, double theta) Constructor where array of axis values and rotation angle are provided For better accuracy, axis values should be normalized.AxisRotation3D(double axisX, double axisY, double axisZ, double theta) Constructor which allows initial value to be supplied as axis and angle.AxisRotation3D(AxisRotation3D rotation) Copy constructor.AxisRotation3D(Rotation3D rot) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptioncom.irurueta.algebra.MatrixReturns this 3D rotation instance expressed as a 4x4 homogeneous matrix.voidasHomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 3D rotation expressed as a 4x4 homogeneous matrix.com.irurueta.algebra.MatrixReturns this 3D rotation instance expressed as a 3x3 inhomogeneous matrix.voidasInhomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 3D rotation expressed as a 3x3 inhomogeneous matrix.voidcombine(AxisRotation3D rotation) Combines provided rotation into this rotation resulting in the multiplication of the internal matrices of both rotations.static voidcombine(AxisRotation3D rot1, AxisRotation3D rot2, AxisRotation3D result) Combines the rotation of instances rot1 and rot1 into provided result instance.voidcombine(Rotation3D rotation) Combines provided rotation into this rotation resulting in the multiplication of the internal matrices of both rotations.combineAndReturnNew(AxisRotation3D rotation) Combines provided rotation with this rotation and returns the result as a new MatrixRotation3D instance.combineAndReturnNew(Rotation3D rotation) Combines provided rotation with this rotation and returns the result as a new MatrixRotation3D instance.voidfromHomogeneousMatrix(com.irurueta.algebra.Matrix m, double threshold) Sets amount of rotation from provided homogeneous rotation matrix.voidfromInhomogeneousMatrix(com.irurueta.algebra.Matrix m, double threshold) Sets amount of rotation from provided inhomogeneous rotation matrix.final voidSets rotation of this instance by copying provided rotation.voidSets values of this rotation from a quaternion.doublegetAxisX()Returns X coordinate of rotation axis.doublegetAxisY()Returns Y coordinate of rotation axis.doublegetAxisZ()Returns Z coordinate of rotation axis.doubleReturns rotation amount or angle in radians around the rotation axis associated to this instance.getType()Returns type of this rotation.voidReverses the rotation of this instance.voidinverseRotation(AxisRotation3D result) Sets into provided MatrixRotation3D instance a rotation inverse to this instance.voidinverseRotation(Rotation3D result) Sets into provided MatrixRotation3D instance a rotation inverse to this instance.Returns a 3D rotation which is inverse to this instance.voidRotates a 3D point using the origin of coordinates as the axis of rotation.voidrotationAxis(double[] axis) Returns rotation axis corresponding to this instance.voidsetAxis(double axisX, double axisY, double axisZ) Sets rotation axis of this instance while preserving the rotation angle.final voidsetAxisAndRotation(double axisX, double axisY, double axisZ, double theta) Sets the axis and rotation of this instance.voidtoAxisRotation(AxisRotation3D result) Converts this 3D rotation into an axis rotation storing the result into provided instance.voidtoMatrixRotation(MatrixRotation3D result) Converts this 3D rotation into a matrix rotation storing the result into provided instance.voidtoQuaternion(Quaternion result) Converts this 3D rotation into a quaternion storing the result into provided instance.Methods inherited from class com.irurueta.geometry.Rotation3D
create, create, create, create, create, create, equals, equals, equals, fromHomogeneousMatrix, fromInhomogeneousMatrix, fromMatrix, fromMatrix, fromRotation, fromRotation, getRotationAxis, hashCode, isValidRotationMatrix, isValidRotationMatrix, rotate, rotate, rotate, setAxisAndRotation, toAxisRotation, toMatrixRotation, toQuaternion
-
Field Details
-
AXIS_PARAMS
public static final int AXIS_PARAMSNumber of parameters defining a rotation axis.- See Also:
-
EPS
public static final double EPSConstant defining machine precision.- See Also:
-
axisX
private double axisXx element of axis angle. -
axisY
private double axisYy element of axis angle. -
axisZ
private double axisZz element of axis angle. -
theta
private double thetaangle element of axis angle.
-
-
Constructor Details
-
AxisRotation3D
public AxisRotation3D(double axisX, double axisY, double axisZ, double theta) Constructor which allows initial value to be supplied as axis and angle. For better accuracy, axis values should be normalized.- Parameters:
axisX- x dimension of normalized axis.axisY- y dimension of normalized axis.axisZ- z dimension of normalized axis.theta- angle in radians.
-
AxisRotation3D
public AxisRotation3D(double[] axis, double theta) Constructor where array of axis values and rotation angle are provided For better accuracy, axis values should be normalized.- Parameters:
axis- Array containing x,y and z values of axis.theta- rotation angle in radians.- Throws:
IllegalArgumentException- if provided axis length is not 3.
-
AxisRotation3D
Copy constructor.- Parameters:
rotation- instance to copy.
-
AxisRotation3D
Copy constructor.- Parameters:
rot- Converts and copies provided rotation instance.
-
AxisRotation3D
public AxisRotation3D()Empty constructor.
-
-
Method Details
-
getType
Returns type of this rotation.- Specified by:
getTypein classRotation3D- Returns:
- Type of this rotation.
-
fromRotation
Sets rotation of this instance by copying provided rotation.- Overrides:
fromRotationin classRotation3D- Parameters:
rot- Rotation to be copied.
-
setAxis
public void setAxis(double axisX, double axisY, double axisZ) Sets rotation axis of this instance while preserving the rotation angle. Once set, points will rotate around provided axis.- Parameters:
axisX- X coordinate of rotation axis.axisY- Y coordinate of rotation axis.axisZ- Z coordinate of rotation axis.
-
setAxisAndRotation
public final void setAxisAndRotation(double axisX, double axisY, double axisZ, double theta) Sets the axis and rotation of this instance. Once set, points will rotate around provided axis an amount equal to provided rotation angle in radians. Note: to avoid numerical instabilities and improve accuracy, axis coordinates should be normalized (e.g. norm equal to 1).- Specified by:
setAxisAndRotationin classRotation3D- Parameters:
axisX- X coordinate of rotation axis.axisY- Y coordinate of rotation axis.axisZ- Z coordinate of rotation axis.theta- Amount of rotation in radians.
-
getAxisX
public double getAxisX()Returns X coordinate of rotation axis.- Returns:
- X coordinate of rotation axis.
-
getAxisY
public double getAxisY()Returns Y coordinate of rotation axis.- Returns:
- Y coordinate of rotation axis.
-
getAxisZ
public double getAxisZ()Returns Z coordinate of rotation axis.- Returns:
- Z coordinate of rotation axis.
-
rotationAxis
public void rotationAxis(double[] axis) Returns rotation axis corresponding to this instance. Result is stored in provided axis array, which must have length 3- Specified by:
rotationAxisin classRotation3D- Parameters:
axis- Array where axis coordinates will be stored.- Throws:
IllegalArgumentException- Raised if provided array does not have length 3.
-
getRotationAngle
public double getRotationAngle()Returns rotation amount or angle in radians around the rotation axis associated to this instance.- Specified by:
getRotationAnglein classRotation3D- Returns:
- Rotation angle in radians.
-
inverseRotationAndReturnNew
Returns a 3D rotation which is inverse to this instance. In other words, the combination of this rotation with its inverse produces no change.- Specified by:
inverseRotationAndReturnNewin classRotation3D- Returns:
- Inverse 3D rotation.
-
inverseRotation
Sets into provided MatrixRotation3D 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.
-
inverseRotation
Sets into provided MatrixRotation3D instance a rotation inverse to this instance. The combination of this rotation with its inverse produces no change.- Specified by:
inverseRotationin classRotation3D- Parameters:
result- Instance where inverse rotation will be set.
-
inverseRotation
public void inverseRotation()Reverses the rotation of this instance.- Specified by:
inverseRotationin classRotation3D
-
asInhomogeneousMatrix
public com.irurueta.algebra.Matrix asInhomogeneousMatrix()Returns this 3D rotation instance expressed as a 3x3 inhomogeneous matrix. This is equivalent to call getInternalMatrix().- Specified by:
asInhomogeneousMatrixin classRotation3D- Returns:
- Rotation matrix expressed in inhomogeneous coordinates.
-
asInhomogeneousMatrix
public void asInhomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 3D rotation expressed as a 3x3 inhomogeneous matrix.- Specified by:
asInhomogeneousMatrixin classRotation3D- Parameters:
result- Matrix where rotation will be set.- Throws:
IllegalArgumentException- Raised if provided instance does not have size 3x3.
-
asHomogeneousMatrix
public com.irurueta.algebra.Matrix asHomogeneousMatrix()Returns this 3D rotation instance expressed as a 4x4 homogeneous matrix.- Specified by:
asHomogeneousMatrixin classRotation3D- Returns:
- Rotation matrix expressed in homogeneous coordinates.
-
asHomogeneousMatrix
public void asHomogeneousMatrix(com.irurueta.algebra.Matrix result) Sets into provided Matrix instance this 3D rotation expressed as a 4x4 homogeneous matrix.- Specified by:
asHomogeneousMatrixin classRotation3D- Parameters:
result- Matrix where rotation will be set.- Throws:
IllegalArgumentException- Raised if provided instance does not have size 4x4.
-
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 3x3.- Specified by:
fromInhomogeneousMatrixin classRotation3D- 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 negativeRotation3D.isValidRotationMatrix(Matrix)
-
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 4x4, and its last row and column must be zero, except for element in last row and column which must be 1.- Specified by:
fromHomogeneousMatrixin classRotation3D- 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.Rotation3D.isValidRotationMatrix(Matrix).
-
rotate
Rotates a 3D point using the origin of coordinates as the axis of rotation. Point will be rotated by the amount of rotation contained in this instance.- Specified by:
rotatein classRotation3D- Parameters:
inputPoint- Input point to be rotated.resultPoint- Rotated point.
-
combineAndReturnNew
Combines provided rotation with this rotation and returns the result as a new MatrixRotation3D instance.- Parameters:
rotation- Input rotation to be combined.- Returns:
- Combined rotation, which is equal to the multiplication of the internal matrix of provided rotation with the internal matrix of this instance.
-
combineAndReturnNew
Combines provided rotation with this rotation and returns the result as a new MatrixRotation3D instance.- Specified by:
combineAndReturnNewin classRotation3D- Parameters:
rotation- Input rotation to be combined.- Returns:
- Combined rotation, which is equal to the multiplication of the internal matrix of provided rotation with the internal matrix of this instance.
-
combine
Combines provided rotation into this rotation resulting in the multiplication of the internal matrices of both rotations.- Parameters:
rotation- Input rotation to be combined.
-
combine
Combines provided rotation into this rotation resulting in the multiplication of the internal matrices of both rotations.- Specified by:
combinein classRotation3D- 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 multiplication of the internal matrix of provided rotation with the internal matrix of this instance.
-
fromRotation
Sets values of this rotation from a quaternion.- Specified by:
fromRotationin classRotation3D- Parameters:
q- a quaternion to set values from.
-
toMatrixRotation
Converts this 3D rotation into a matrix rotation storing the result into provided instance.- Overrides:
toMatrixRotationin classRotation3D- Parameters:
result- instance where result wil be stored.
-
toAxisRotation
Converts this 3D rotation into an axis rotation storing the result into provided instance.- Overrides:
toAxisRotationin classRotation3D- Parameters:
result- instance where result will be stored.
-
toQuaternion
Converts this 3D rotation into a quaternion storing the result into provided instance.- Overrides:
toQuaternionin classRotation3D- Parameters:
result- instance where result will be stored.
-