Package javajs.util

Class Quat

java.lang.Object
javajs.util.Quat

public class Quat extends Object
  • Field Details

    • q0

      public float q0
    • q1

      public float q1
    • q2

      public float q2
    • q3

      public float q3
  • Constructor Details

    • Quat

      public Quat()
  • Method Details

    • newQ

      public static Quat newQ(Quat q)
    • newVA

      public static Quat newVA(T3 v, float theta)
    • newM

      public static Quat newM(M3 mat)
    • newAA

      public static Quat newAA(A4 a)
    • newP4

      public static Quat newP4(P4 pt)
    • new4

      public static Quat new4(float q1, float q2, float q3, float q0)
      Note that q0 is the last parameter here
      Parameters:
      q1 -
      q2 -
      q3 -
      q0 -
      Returns:
      {q1 q2 q3 q0}
    • set

      public void set(Quat q)
    • setTA

      public void setTA(T3 pt, float theta)
      q = (cos(theta/2), sin(theta/2) * n)
      Parameters:
      pt -
      theta -
    • setAA

      public void setAA(A4 a)
    • setRef

      public void setRef(Quat qref)
    • getQuaternionFrame

      public static final Quat getQuaternionFrame(P3 center, T3 x, T3 xy)
      returns a quaternion frame based on three points (center, x, and any point in xy plane) or two vectors (vA, vB).
      Parameters:
      center - (null for vA/vB option)
      x -
      xy -
      Returns:
      quaternion for frame
    • getQuaternionFrameV

      public static final Quat getQuaternionFrameV(V3 vA, V3 vB, V3 vC, boolean yBased)
      Create a quaternion based on a frame
      Parameters:
      vA -
      vB -
      vC -
      yBased -
      Returns:
      quaternion
    • getMatrix

      public M3 getMatrix()
    • add

      public Quat add(float x)
    • mul

      public Quat mul(float x)
    • mulQ

      public Quat mulQ(Quat p)
    • divLeft

      public Quat divLeft(Quat p)
    • dot

      public float dot(Quat q)
    • inv

      public Quat inv()
    • negate

      public Quat negate()
    • getVector

      public V3 getVector(int i)
    • getVectorScaled

      public V3 getVectorScaled(int i, float scale)
    • getNormal

      public V3 getNormal()
      Returns:
      vector such that 0 <= angle <= 180
    • getTheta

      public float getTheta()
      Returns:
      0 <= angle <= 180 in degrees
    • getThetaRadians

      public float getThetaRadians()
    • getNormalDirected

      public V3 getNormalDirected(V3 v0)
      Parameters:
      v0 -
      Returns:
      vector option closest to v0
    • get3dProjection

      public V3 get3dProjection(V3 v3d)
    • getThetaDirected

      public P4 getThetaDirected(P4 axisAngle)
      Parameters:
      axisAngle -
      Returns:
      fill in theta of axisAngle such that
    • getThetaDirectedV

      public float getThetaDirectedV(V3 vector)
      Parameters:
      vector - a vector, same as for getNormalDirected
      Returns:
      return theta
    • toPoint4f

      public P4 toPoint4f()
      Quaternions are saved as {q1, q2, q3, q0} While this may seem odd, it is so that for any point4 -- planes, axisangles, and quaternions -- we can use the first three coordinates to determine the relavent axis the fourth then gives us offset to {0,0,0} (plane), rotation angle (axisangle), and cos(theta/2) (quaternion).
      Returns:
      {x y z w} (unnormalized)
    • toAxisAngle4f

      public A4 toAxisAngle4f()
    • transform2

      public T3 transform2(T3 pt, T3 ptNew)
    • leftDifference

      public Quat leftDifference(Quat q2)
    • rightDifference

      public Quat rightDifference(Quat q2)
    • toString

      public String toString()
      Java axisAngle / plane / Point4f format all have the format {x y z w} so we go with that here as well
      Overrides:
      toString in class Object
      Returns:
      "{q1 q2 q3 q0}"
    • div

      public Quat div(Quat p)
    • arrayDiv

      public static Quat[] arrayDiv(Quat[] data1, Quat[] data2, int nMax, boolean isRelative)
      Parameters:
      data1 -
      data2 -
      nMax - > 0 --> limit to this number
      isRelative -
      Returns:
      pairwise array of data1 / data2 or data1 \ data2
    • sphereMean

      public static Quat sphereMean(Quat[] data, float[] retStddev, float criterion)
    • getEulerZYZ

      public float[] getEulerZYZ()
    • getEulerZXZ

      public float[] getEulerZXZ()