Package org.moeaframework.util
Class RotationMatrixBuilder
java.lang.Object
org.moeaframework.util.RotationMatrixBuilder
Builds rotation matrices of any dimension constructively from one or more 2D planar rotations. Three types of
construction mechanisms are provided:
- Specific rotation planes and thetas
new RotationMatrixBuilder(3).rotatePlane(0,1).withTheta(Math.PI/4).rotatePlane(1,2).withTheta(Math.PI/8).create()
- Specific rotation planes with random thetas
new RotationMatrixBuilder(3).rotatePlane(0,1).rotatePlane(1,2).withRandomThetas().create()
- Random subplanes with random thetas
new RotationMatrixBuilder(3).rotateK(2).create()
References:
- Aguilera, A. and Pérez-Aguila, R. "General n-Dimensional Rotations." WSCG 2004, pp. 1-8, 2004.
-
Constructor Summary
ConstructorDescriptionRotationMatrixBuilder
(int dimension) Constructs a rotation matrix builder for the given dimension. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.commons.math3.linear.RealMatrix
create()
Returns the rotation matrix resulting from applying all 2D rotation planes and angles added to this builder.Rotates all 2D rotation planes and assigns each a random rotation angle.rotateK
(int k) Rotatesk
randomly-selected but unique 2D rotation planes and assigns each a random rotation angle.rotatePlane
(int i, int j) Adds a rotation around the 2D rotation plane defined by the two axes.Assigns random rotation angles to all 2D rotation planes added to this builder.withTheta
(double theta) Sets the rotation angle, in radians, of the last 2D rotation plane added to this builder.withThetas
(double theta) Sets the rotation angle, in radians, of all 2D rotation planes added to this builder.
-
Constructor Details
-
RotationMatrixBuilder
public RotationMatrixBuilder(int dimension) Constructs a rotation matrix builder for the given dimension.- Parameters:
dimension
- the dimension of rotation matrices produced by this builder
-
-
Method Details
-
rotatePlane
Adds a rotation around the 2D rotation plane defined by the two axes. The plane is initially unrotated, but can be assigned a specific rotation angle if followed bywithTheta(double)
.- Parameters:
i
- the first axisj
- the second axis- Returns:
- a reference to this rotation matrix builder
-
withTheta
Sets the rotation angle, in radians, of the last 2D rotation plane added to this builder. This method should always only follow invocations ofrotatePlane(int, int)
.- Parameters:
theta
- the rotation angle in radians- Returns:
- a reference to this rotation matrix builder
-
withThetas
Sets the rotation angle, in radians, of all 2D rotation planes added to this builder.- Parameters:
theta
- the rotation angle in radians- Returns:
- a reference to this rotation matrix builder
-
withRandomThetas
Assigns random rotation angles to all 2D rotation planes added to this builder.- Returns:
- a reference to this rotation matrix builder
-
rotateAll
Rotates all 2D rotation planes and assigns each a random rotation angle.- Returns:
- a reference to this rotation matrix builder
-
rotateK
Rotatesk
randomly-selected but unique 2D rotation planes and assigns each a random rotation angle. For anN
-dimension rotation matrix, there exist(N choose 2)
2D rotation planes.- Parameters:
k
- the number of randomly-selected 2D rotation planes- Returns:
- a reference to this rotation matrix builder
-
create
public org.apache.commons.math3.linear.RealMatrix create()Returns the rotation matrix resulting from applying all 2D rotation planes and angles added to this builder.- Returns:
- the rotation matrix resulting from applying all 2D rotation planes and angles added to this builder
-