Class Quaternion

java.lang.Object
me.deecaad.core.utils.Quaternion
All Implemented Interfaces:
Cloneable

public class Quaternion extends Object implements Cloneable
  • Field Details

  • Method Details

    • getEulerAngles

      public org.bukkit.util.Vector getEulerAngles()
      Get the Euler Angles (in radians). You can get the yaw, pitch, and roll by accessing the returned vector's x, y, and z components respectively. In general, converting to euler angles from quaternions (and vice versa) is a slow operation, and should be avoided if possible.
      Returns:
      The yaw, pitch, and roll, respectively.
      See Also:
    • setEulerAngles

      public Quaternion setEulerAngles(org.bukkit.util.Vector angles)
      Set the Euler Angles (in radians). angles.x is yaw, angles.y is pitch, and angles.z is roll. In general, converting from euler angles to quaternions (and vice versa) is a slow operation, and should be avoided if possible.
      Parameters:
      angles - The yaw, pitch, and roll, respectively.
      Returns:
      A non-null reference to this (builder pattern)
      See Also:
    • multiply

      public Quaternion multiply(Quaternion other)
    • multiply

      public org.bukkit.util.Vector multiply(org.bukkit.util.Vector vector)
    • dot

      public double dot(Quaternion other)
    • inverse

      public Quaternion inverse()
    • normalize

      public Quaternion normalize()
    • clone

      protected Quaternion clone()
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public boolean isUnit()
      Returns true when the "length" of the quaternion is zero. Generally, you need a unit quaternion in order to do math. Use normalize() to make this quaternion a unit
      Returns:
      true if this is a unit
    • isPure

      public boolean isPure()
      Returns true when the scalar component (w) is zero. Pure quaternions usually hold a vector.
      Returns:
      true if this is a pure
    • identity

      public static Quaternion identity()
      Returns the identity quaternion, which is a quaternion with 0 rotation.
      Returns:
      A copy of the identity
    • lookAt

      public static Quaternion lookAt(org.bukkit.util.Vector direction, org.bukkit.util.Vector up)
      Creates a new quaternion looking in the given direction.
      Parameters:
      direction - Normalized direction vector.
      up - The local up Transform.getUp()
      Returns:
      A new quaternion looking in the direction.
    • fromAxis

      public static Quaternion fromAxis(org.bukkit.util.Vector right, org.bukkit.util.Vector up, org.bukkit.util.Vector forward)
    • fromTo

      public static Quaternion fromTo(org.bukkit.util.Vector from, org.bukkit.util.Vector to)
      Creates a quaternion that rotates between the 2 given vectors.
      Parameters:
      from - From direction.
      to - To direction.
      Returns:
      A new quaternion rotation from -> to.
    • fromEuler

      public static Quaternion fromEuler(org.bukkit.util.Vector angles)
      Creates a new Quaternion from the given Euler angles.
      Parameters:
      angles - The yaw, pitch, and roll stored in x, y, and z respectively.
      Returns:
      A new
      See Also:
    • angleAxis

      public static Quaternion angleAxis(double angle, org.bukkit.util.Vector axis)
      Creates a new Quaternion from the given axis and rotation.
      Parameters:
      angle - The angle, in radians, to rotate.
      axis - The normalized axis.
      Returns:
      A non-null reference to this (builder pattern).