Class RotationHelpers

java.lang.Object
edu.tufts.hrilab.util.RotationHelpers

public class RotationHelpers extends Object
A collection of static methods to help out with rotations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static javax.vecmath.Matrix4d
    buildTransformMatrix(javax.vecmath.Vector3d translation, javax.vecmath.Tuple3d rotation)
    Converts a translation and a rotation into a transform matrix that can be applied to points.
    static javax.vecmath.Point3d
    calcTargetOffset(javax.vecmath.Point3d point, javax.vecmath.Quat4d orientation, javax.vecmath.Vector3d offset_axis, float offset)
    Move point by offset amount in direction of specified offset_axis.
    static javax.vecmath.Quat4d
    createQuaternion(javax.vecmath.Vector3d axis_of_rot, double rev_rad)
    Creates a quaternion based off of a given axis of rotation and given radians of rotation
    static javax.vecmath.Quat4d
    mirrorOrientation(javax.vecmath.Quat4d ref_orient)
    Gives a quaternion representing the "mirror" orientation of the given quaternion.
    static javax.vecmath.Vector3d
    quaternionToNormVect(javax.vecmath.Quat4d orient_quat)
    Converts an orientation quaternion into it's equivalent normal vector.
    static javax.vecmath.Tuple3d
    quatToXYZRotations(javax.vecmath.Quat4d q)
     
    static javax.vecmath.Quat4d
    rotateQuaternion(javax.vecmath.Quat4d toRotate, String axis, double rad)
     
    static javax.vecmath.Quat4d
    xyzRotationsToQuaternion(javax.vecmath.Tuple3d xyz)
    Converts a Tuple containing a rotation about x, y, and z (to be applied in that order) into an equivalent quaternion.
    static javax.vecmath.Matrix3d
    xyzRotationsToRotationMatrix(javax.vecmath.Tuple3d xyz)
    Converts a Tuple containing a rotation about x, y, and z (to be applied in that order) into a matrix that can rotate points by x, then y, and then z.
    static javax.vecmath.Matrix4d
    xyzRotationsToTransformMatrix(javax.vecmath.Tuple3d xyz)
    Converts a Tuple containing a rotation about x, y, and z (to be applied in that order) into a matrix that can rotate points by x, then y, and then z.

    Methods inherited from class java.lang.Object

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

    • RotationHelpers

      public RotationHelpers()
  • Method Details

    • xyzRotationsToQuaternion

      public static javax.vecmath.Quat4d xyzRotationsToQuaternion(javax.vecmath.Tuple3d xyz)
      Converts a Tuple containing a rotation about x, y, and z (to be applied in that order) into an equivalent quaternion.
      Parameters:
      xyz - The three desired rotations
      Returns:
      The same rotation as a quaternion.
    • xyzRotationsToRotationMatrix

      public static javax.vecmath.Matrix3d xyzRotationsToRotationMatrix(javax.vecmath.Tuple3d xyz)
      Converts a Tuple containing a rotation about x, y, and z (to be applied in that order) into a matrix that can rotate points by x, then y, and then z.
      Parameters:
      xyz - The three desired rotations.
      Returns:
      A matrix that achieves them.
    • xyzRotationsToTransformMatrix

      public static javax.vecmath.Matrix4d xyzRotationsToTransformMatrix(javax.vecmath.Tuple3d xyz)
      Converts a Tuple containing a rotation about x, y, and z (to be applied in that order) into a matrix that can rotate points by x, then y, and then z. The translate component of the matrix will always be zero.
      Parameters:
      xyz - The three desired rotations.
      Returns:
      A matrix that achieves them.
    • quatToXYZRotations

      public static javax.vecmath.Tuple3d quatToXYZRotations(javax.vecmath.Quat4d q)
    • buildTransformMatrix

      public static javax.vecmath.Matrix4d buildTransformMatrix(javax.vecmath.Vector3d translation, javax.vecmath.Tuple3d rotation)
      Converts a translation and a rotation into a transform matrix that can be applied to points.
      Parameters:
      translation - How far the points should move.
      rotation - How far the points should rotate.
      Returns:
    • rotateQuaternion

      public static javax.vecmath.Quat4d rotateQuaternion(javax.vecmath.Quat4d toRotate, String axis, double rad)
    • createQuaternion

      public static javax.vecmath.Quat4d createQuaternion(javax.vecmath.Vector3d axis_of_rot, double rev_rad)
      Creates a quaternion based off of a given axis of rotation and given radians of rotation
      Parameters:
      axis_of_rot - The axis of rotation
      rev_rad - The magnitude of the rotation in radians
      Returns:
      A quaternion based off of a given axis of rotation and given radians of rotation
    • mirrorOrientation

      public static javax.vecmath.Quat4d mirrorOrientation(javax.vecmath.Quat4d ref_orient)
      Gives a quaternion representing the "mirror" orientation of the given quaternion. While it is not possible to directly mirror a quaternion, we can view the resultant quaternion as a 180-degree rotation of the reference quaternion around an axis orthogonal to its equivalent normal vector
      Parameters:
      ref_orient - The reference orientation given by the inputted quaternion
      Returns:
      The "mirror" orientation of the given quaternion
    • quaternionToNormVect

      public static javax.vecmath.Vector3d quaternionToNormVect(javax.vecmath.Quat4d orient_quat)
      Converts an orientation quaternion into it's equivalent normal vector. We can think of that normal vector as the rotational transformation applied by the given quaternion onto the base vector (the unit x-axis vector)
      Parameters:
      orient_quat - the orientation quaternion to convert
      Returns:
      the equivalent normal vector
    • calcTargetOffset

      public static javax.vecmath.Point3d calcTargetOffset(javax.vecmath.Point3d point, javax.vecmath.Quat4d orientation, javax.vecmath.Vector3d offset_axis, float offset)
      Move point by offset amount in direction of specified offset_axis.
      Parameters:
      point - 3D point
      orientation - point's orientation
      offset_axis - direction to apply offset
      offset - (amount to translate along offset_axis)
      Returns: