Class Quaternion2

java.lang.Object
edu.nps.moves.legacy.math.Quaternion2

public class Quaternion2 extends Object
The Quaternion2 class executes quaternion operations.
Author:
Ildeniz Duman
  • Constructor Details

    • Quaternion2

      public Quaternion2(String myName, double ww, double xx, double yy, double zz)
      Default constructor
      Parameters:
      myName - Name of the quaternion
      ww - w value of the quaternion
      xx - x value of the quaternion
      yy - y value of the quaternion
      zz - z value of the quaternion
    • Quaternion2

      public Quaternion2(String myName)
      Default constructor
      Parameters:
      myName - Name of the quaternion
    • Quaternion2

      public Quaternion2()
      Default constructor
  • Method Details

    • setQuaternion2

      public void setQuaternion2(double ww, double xx, double yy, double zz)
      Sets the quaternion values
      Parameters:
      ww - w value of the quaternion
      xx - x value of the quaternion
      yy - y value of the quaternion
      zz - z value of the quaternion
    • getW

      public double getW()
      Returns the w value of quaternion.
    • getX

      public double getX()
      Returns the x value of quaternion.
    • getY

      public double getY()
      Returns the y value of quaternion.
    • getZ

      public double getZ()
      Returns the z value of quaternion.
    • multiply

      public Quaternion2 multiply(Quaternion2 QUAT)
      Multiplies two quaternions
      Parameters:
      QUAT - second quaternion
      Returns:
      new Quaternion2
    • multiply

      public Quaternion2 multiply(double NUM)
      Multiplies this quaternion with a scalar
      Parameters:
      NUM - is a scalar
      Returns:
      modified Quaternion2
    • add

      public Quaternion2 add(Quaternion2 QUAT)
      Adds two quaternions
      Parameters:
      QUAT - is a quaternion to add
      Returns:
      new Quaternion2
    • substract

      public Quaternion2 substract(Quaternion2 QUAT)
      Substracts two quaternions
      Parameters:
      QUAT - is a quaternion to substract
      Returns:
      new Quaternion2
    • invert

      public Quaternion2 invert()
      Finds the inverse (conjugate) of a quaternion
      Returns:
      new Quaternion2
    • rotate

      public Quaternion2 rotate(Quaternion2 QUAT4)
      Rotates a vector by quaternions
      Parameters:
      QUAT4 - a vector in quaternion form
      Returns:
      Rotated vector in quaternion form
    • toBody

      public Quaternion2 toBody(Quaternion2 QUAT)
      Converts to body coordinates
      Parameters:
      QUAT - a vector in quaternion form to convert to body coordinates
      Returns:
      Converted vector in quaternion form
    • dotProduct

      public double dotProduct(Quaternion2 QUAT5)
      Finds the dot product of two quaternions
      Parameters:
      QUAT5 - a quaternion
      Returns:
      Dot product value
    • normalize

      public void normalize()
      Normalizes the quaternion modifies the current quaternion
    • toAxisAngles

      public Quaternion2 toAxisAngles()
      Calculates the axis angles of quaternion for drawing, results must be used in glRotatef() by using get() functions
      Returns:
      Result in quaternion form
    • toQuaternion2

      public Quaternion2 toQuaternion2()
      Calculates the quaternion value of three rotations Current object is a 3D vector with rotation angles in quaternion form
      Returns:
      new Quaternion2
    • toEulerAngles

      public Quaternion2 toEulerAngles()
      Converts a quaternion into Euler angles Warning : This conversion is inherently ill-defined
      Returns:
      new Quaternion2
    • toString

      public String toString()
      Overrides the toString method
      Overrides:
      toString in class Object
      Returns:
      String object
    • toFloat

      public float[] toFloat()
      Converts quaternion's values into float
      Returns:
      Float []
    • main

      public static void main(String[] ags)
      Main method for testing