Class Quaternion

java.lang.Object
edu.wpi.first.math.geometry.Quaternion

public class Quaternion
extends Object
  • Constructor Summary

    Constructors 
    Constructor Description
    Quaternion()
    Constructs a quaternion with a default angle of 0 degrees.
    Quaternion​(double w, double x, double y, double z)
    Constructs a quaternion with the given components.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(Object obj)
    Checks equality between this Quaternion and another object.
    double getW()
    Returns W component of the quaternion.
    double getX()
    Returns X component of the quaternion.
    double getY()
    Returns Y component of the quaternion.
    double getZ()
    Returns Z component of the quaternion.
    int hashCode()  
    Quaternion inverse()
    Returns the inverse of the quaternion.
    Quaternion normalize()
    Normalizes the quaternion.
    Quaternion times​(Quaternion other)
    Multiply with another quaternion.
    Vector<N3> toRotationVector()
    Returns the rotation vector representation of this quaternion.
    String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Quaternion

      public Quaternion()
      Constructs a quaternion with a default angle of 0 degrees.
    • Quaternion

      public Quaternion​(double w, double x, double y, double z)
      Constructs a quaternion with the given components.
      Parameters:
      w - W component of the quaternion.
      x - X component of the quaternion.
      y - Y component of the quaternion.
      z - Z component of the quaternion.
  • Method Details

    • times

      public Quaternion times​(Quaternion other)
      Multiply with another quaternion.
      Parameters:
      other - The other quaternion.
      Returns:
      The quaternion product.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals​(Object obj)
      Checks equality between this Quaternion and another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The other object.
      Returns:
      Whether the two objects are equal or not.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • inverse

      public Quaternion inverse()
      Returns the inverse of the quaternion.
      Returns:
      The inverse quaternion.
    • normalize

      Normalizes the quaternion.
      Returns:
      The normalized quaternion.
    • getW

      public double getW()
      Returns W component of the quaternion.
      Returns:
      W component of the quaternion.
    • getX

      public double getX()
      Returns X component of the quaternion.
      Returns:
      X component of the quaternion.
    • getY

      public double getY()
      Returns Y component of the quaternion.
      Returns:
      Y component of the quaternion.
    • getZ

      public double getZ()
      Returns Z component of the quaternion.
      Returns:
      Z component of the quaternion.
    • toRotationVector

      Returns the rotation vector representation of this quaternion.

      This is also the log operator of SO(3).

      Returns:
      The rotation vector representation of this quaternion.