Package me.deecaad.core.utils
Class Quaternion
java.lang.Object
me.deecaad.core.utils.Quaternion
- All Implemented Interfaces:
Cloneable
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic QuaternionangleAxis(double angle, org.bukkit.util.Vector axis) Creates a new Quaternion from the given axis and rotation.protected Quaternionclone()doubledot(Quaternion other) booleanstatic QuaternionfromAxis(org.bukkit.util.Vector right, org.bukkit.util.Vector up, org.bukkit.util.Vector forward) static QuaternionfromEuler(org.bukkit.util.Vector angles) Creates a new Quaternion from the given Euler angles.static QuaternionfromTo(org.bukkit.util.Vector from, org.bukkit.util.Vector to) Creates a quaternion that rotates between the 2 given vectors.org.bukkit.util.VectorGet the Euler Angles (in radians).inthashCode()static Quaternionidentity()Returns the identity quaternion, which is a quaternion with 0 rotation.inverse()booleanisPure()Returnstruewhen the scalar component (w) is zero.booleanisUnit()Returnstruewhen the "length" of the quaternion is zero.static QuaternionlookAt(org.bukkit.util.Vector direction, org.bukkit.util.Vector up) Creates a new quaternion looking in the given direction.multiply(Quaternion other) org.bukkit.util.Vectormultiply(org.bukkit.util.Vector vector) setEulerAngles(org.bukkit.util.Vector angles) Set the Euler Angles (in radians).
-
Field Details
-
EPSILON
public static final double EPSILON- See Also:
-
-
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
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
-
multiply
public org.bukkit.util.Vector multiply(org.bukkit.util.Vector vector) -
dot
-
inverse
-
normalize
-
clone
-
equals
-
hashCode
public int hashCode() -
isUnit
public boolean isUnit()Returnstruewhen the "length" of the quaternion is zero. Generally, you need a unit quaternion in order to do math. Usenormalize()to make this quaternion a unit- Returns:
- true if this is a unit
-
isPure
public boolean isPure()Returnstruewhen the scalar component (w) is zero. Pure quaternions usually hold a vector.- Returns:
- true if this is a pure
-
identity
Returns the identity quaternion, which is a quaternion with 0 rotation.- Returns:
- A copy of the identity
-
lookAt
Creates a new quaternion looking in the given direction.- Parameters:
direction- Normalized direction vector.up- The local upTransform.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
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
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
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).
-