Class Quaternion

java.lang.Object
au.edu.unsw.cse.Quaternion

public class Quaternion
extends java.lang.Object
A quaternion. Really handy for representing a 3D rotation.
  • Constructor Summary

    Constructors
    Constructor Description
    Quaternion​(double x, double y, double z, double w)
    Create the quaternion ix+jy+kz+w
    Quaternion​(Point3d axis, double theta)
    Create a unit quaternion that represents the rotation about axis by theta
  • Method Summary

    Modifier and Type Method Description
    Quaternion add​(Quaternion x)  
    Quaternion conjugate()  
    static Quaternion fromRotMatrix​(Point3d u, Point3d v, Point3d w)
    construct Quaternion from a rotation matrix expressed as a triple of vectors, each one a row of the matrix.
    Quaternion inverse()  
    static void main​(java.lang.String[] arg)  
    Quaternion multiply​(Quaternion x)  
    double norm()  
    Quaternion scale​(double x)  
    java.lang.String toString()  
    java.lang.String toVRML()
    Convert to VRML representation: axis + rotation angle

    Methods inherited from class java.lang.Object

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

    • Quaternion

      public Quaternion​(double x, double y, double z, double w)
      Create the quaternion ix+jy+kz+w
    • Quaternion

      public Quaternion​(Point3d axis, double theta)
      Create a unit quaternion that represents the rotation about axis by theta
  • Method Details

    • add

      public Quaternion add​(Quaternion x)
    • multiply

      public Quaternion multiply​(Quaternion x)
    • scale

      public Quaternion scale​(double x)
    • conjugate

      public Quaternion conjugate()
    • norm

      public double norm()
    • inverse

      public Quaternion inverse()
    • fromRotMatrix

      public static Quaternion fromRotMatrix​(Point3d u, Point3d v, Point3d w)
      construct Quaternion from a rotation matrix expressed as a triple of vectors, each one a row of the matrix. Code adapted from Shoemake's paper "Quaternions".
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • toVRML

      public java.lang.String toVRML()
      Convert to VRML representation: axis + rotation angle
    • main

      public static void main​(java.lang.String[] arg)