Class RotationMatrixBuilder

java.lang.Object
org.moeaframework.util.RotationMatrixBuilder

public class RotationMatrixBuilder extends Object
Builds rotation matrices of any dimension constructively from one or more 2D planar rotations. Three types of construction mechanisms are provided:
  1. Specific rotation planes and thetas
    new RotationMatrixBuilder(3).rotatePlane(0,1).withTheta(Math.PI/4).rotatePlane(1,2).withTheta(Math.PI/8).create()
  2. Specific rotation planes with random thetas
    new RotationMatrixBuilder(3).rotatePlane(0,1).rotatePlane(1,2).withRandomThetas().create()
  3. Random subplanes with random thetas
    new RotationMatrixBuilder(3).rotateK(2).create()

References:

  1. Aguilera, A. and Pérez-Aguila, R. "General n-Dimensional Rotations." WSCG 2004, pp. 1-8, 2004.
  • 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

      public RotationMatrixBuilder rotatePlane(int i, int j)
      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 by withTheta(double).
      Parameters:
      i - the first axis
      j - the second axis
      Returns:
      a reference to this rotation matrix builder
    • withTheta

      public RotationMatrixBuilder withTheta(double theta)
      Sets the rotation angle, in radians, of the last 2D rotation plane added to this builder. This method should always only follow invocations of rotatePlane(int, int).
      Parameters:
      theta - the rotation angle in radians
      Returns:
      a reference to this rotation matrix builder
    • withThetas

      public RotationMatrixBuilder withThetas(double theta)
      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

      public RotationMatrixBuilder withRandomThetas()
      Assigns random rotation angles to all 2D rotation planes added to this builder.
      Returns:
      a reference to this rotation matrix builder
    • rotateAll

      public RotationMatrixBuilder rotateAll()
      Rotates all 2D rotation planes and assigns each a random rotation angle.
      Returns:
      a reference to this rotation matrix builder
    • rotateK

      public RotationMatrixBuilder rotateK(int k)
      Rotates k randomly-selected but unique 2D rotation planes and assigns each a random rotation angle. For an N-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