Class RotationTools.Rotator

java.lang.Object
com.github.yellowstonegames.grid.RotationTools.Rotator
Enclosing class:
RotationTools

public static class RotationTools.Rotator extends Object
A wrapper around similar logic to RotationTools, but with no allocation after construction. Operates on a fixed dimension; create different Rotator instances to rotate different dimensions. You can rotate a float array with length equal to dimension with rotate(float[], float[]).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Rotator(int dimension)
     
    Rotator(int dimension, Random random)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    rotate(float[] input, float[] output)
    A rotation method that uses this Rotator's rotation matrix and takes an input vector to rotate (as a 1D float array), and an output vector to write to (as a 1D float array), does the math to rotate input using this Rotator, and adds the results into output.
    void
    rotate(float[] input, float[] output, int offsetOut)
    A rotation method that uses this Rotator's rotation matrix and takes an input vector to rotate (as a 1D float array), and an output vector to write to (as a 1D float array), and an offset into the output vector to start writing there, does the math to rotate input using this Rotator, and adds the results into output starting at offsetOut.
    void
    rotate(float[] input, int offsetIn, float[] output, int offsetOut)
    A rotation method that uses this Rotator's rotation matrix and takes an input vector to rotate (as a 1D float array), an output vector to write to (as a 1D float array), and offsets into the input and output vectors to start reading from and writing to, then does the math to rotate input using this Rotator, and adds the results into output starting at offsetOut.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dimension

      public final int dimension
    • random

      public Random random
  • Constructor Details

    • Rotator

      public Rotator()
    • Rotator

      public Rotator(int dimension)
    • Rotator

      public Rotator(int dimension, Random random)
  • Method Details

    • randomize

      public void randomize()
    • rotate

      public void rotate(float[] input, float[] output)
      A rotation method that uses this Rotator's rotation matrix and takes an input vector to rotate (as a 1D float array), and an output vector to write to (as a 1D float array), does the math to rotate input using this Rotator, and adds the results into output. This does not erase output before writing to it, so it can be called more than once to sum multiple rotations if so desired. The length of output can be arbitrarily large, so this is complete when it has completely processed rotation. That means this affects dimension items in output. Almost always, both input and the writeable part of output should have a length equal to dimension.
      Parameters:
      input - an input vector of length dimension
      output - the output vector of length dimension
    • rotate

      public void rotate(float[] input, float[] output, int offsetOut)
      A rotation method that uses this Rotator's rotation matrix and takes an input vector to rotate (as a 1D float array), and an output vector to write to (as a 1D float array), and an offset into the output vector to start writing there, does the math to rotate input using this Rotator, and adds the results into output starting at offsetOut. This does not erase output before writing to it, so it can be called more than once to sum multiple rotations if so desired. The length of output can be arbitrarily large, so this is complete when it has completely processed rotation. That means this affects dimension items in output. Almost always, both input and the writeable part of output should have a length equal to dimension.
      Parameters:
      input - an input vector of length dimension
      output - the output vector of length dimension
      offsetOut - the index in output to start writing the rotated output
    • rotate

      public void rotate(float[] input, int offsetIn, float[] output, int offsetOut)
      A rotation method that uses this Rotator's rotation matrix and takes an input vector to rotate (as a 1D float array), an output vector to write to (as a 1D float array), and offsets into the input and output vectors to start reading from and writing to, then does the math to rotate input using this Rotator, and adds the results into output starting at offsetOut. This does not erase output before writing to it, so it can be called more than once to sum multiple rotations if so desired. The length of output can be arbitrarily large, so this is complete when it has completely processed rotation. That means this affects dimension items in output, and likewise reads the same amount from input. Both the part of input after offsetIn and the writeable part of output should have a length at least equal to dimension.
      Parameters:
      input - an input vector of length dimension or greater
      offsetIn - the index in input to read dimension items from
      output - the output vector of length dimension or greater
      offsetOut - the index in output to start writing the rotated output