Class Quaternion

  • java.lang.Object
    • com.aspose.threed.Quaternion
  • All Implemented Interfaces:
    com.aspose.threed.Struct<Quaternion>, java.io.Serializable, java.lang.Cloneable

    public final class Quaternion
    extends java.lang.Object
    implements com.aspose.threed.Struct<Quaternion>, java.io.Serializable
    Quaternion is usually used to perform rotation in computer graphics.
    See Also:
    Serialized Form
    • Field Detail

      • IDENTITY

        public static final Quaternion IDENTITY
        The Identity quaternion.
      • w

        public double w
        The w component.
      • x

        public double x
        The x component.
      • y

        public double y
        The y component.
      • z

        public double z
        The z component.
    • Constructor Detail

      • Quaternion

        public Quaternion​(double w,
                          double x,
                          double y,
                          double z)
        Initializes a new instance of the Quaternion class.
        Parameters:
        w - w component of the quaternion
        x - x component of the quaternion
        y - y component of the quaternion
        z - z component of the quaternion
      • Quaternion

        public Quaternion()
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Check if two quaternions equals
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - The object to check equality.
        Returns:
        True if all components are identically equal.
      • conjugate

        public Quaternion conjugate()
        Returns a conjugate quaternion of current quaternion
        Returns:
        The conjugate quaternion.
      • inverse

        public Quaternion inverse()
        Returns a inverse quaternion of current quaternion
        Returns:
        Inverse quaternion.
      • dot

        public double dot​(Quaternion q)
        Dots product
        Parameters:
        q - The quaternion
        Returns:
        Dot value
      • eulerAngles

        public Vector3 eulerAngles()
        Converts quaternion to rotation represented by Euler angles All components are in radian
        Returns:
        Result vector
      • getLength

        public double getLength()
        Gets the length of the quaternion
      • normalize

        public Quaternion normalize()
        Normalize the quaternion
        Returns:
        Normalized quaternion.
      • toAngleAxis

        public void toAngleAxis​(double[] angle,
                                Vector3 axis)
        Decompose the quaternion to angle and axis
        Parameters:
        angle - The angle to rotate, in radian.
        axis - The axis that rotates around.
      • concat

        public Quaternion concat​(Quaternion rhs)
        Concatenate two quaternions
        Parameters:
        rhs -
      • fromAngleAxis

        public static Quaternion fromAngleAxis​(double a,
                                               Vector3 axis)
        Creates a quaternion around given axis and rotate in clockwise
        Parameters:
        a - Clockwise rotation in radian
        axis - Axis
        Returns:
        Created quaternion
      • fromRotation

        public static Quaternion fromRotation​(Vector3 orig,
                                              Vector3 dest)
        Creates a quaternion that rotate from original to destination direction
        Parameters:
        orig - Original direction
        dest - Destination direction
        Returns:
        Created quaternion
      • fromEulerAngle

        public static Quaternion fromEulerAngle​(double pitch,
                                                double yaw,
                                                double roll)
        Creates quaternion from given Euler angle
        Parameters:
        pitch - Pitch in radian
        yaw - Yaw in radian
        roll - Roll in radian
        Returns:
        Created quaternion
      • fromEulerAngle

        public static Quaternion fromEulerAngle​(Vector3 eulerAngle)
        Creates quaternion from given Euler angle
        Parameters:
        eulerAngle - Euler angle in radian
        Returns:
        Created quaternion
      • toMatrix

        public Matrix4 toMatrix()
        Convert the rotation presented by quaternion to transform matrix.
        Returns:
        The matrix representation of current quaternion.
      • add

        public static Quaternion add​(Quaternion lhs,
                                     Quaternion rhs)
        Operator overloading for +
        Parameters:
        lhs - Left quaternion
        rhs - Right quaternion
        Returns:
        Result quaternion
      • div

        public static Quaternion div​(Quaternion lhs,
                                     double rhs)
        Operator overloading for /
        Parameters:
        lhs - Left quaternion
        rhs - Right quaternion
        Returns:
        Result quaternion
      • mul

        public static Quaternion mul​(Quaternion lhs,
                                     double rhs)
        Operator overloading for *
        Parameters:
        lhs - Left quaternion
        rhs - Right quaternion
        Returns:
        Result quaternion
      • mul

        public static Quaternion mul​(Quaternion lhs,
                                     Quaternion rhs)
        Operator overloading for *
        Parameters:
        lhs - Left quaternion
        rhs - Right quaternion
        Returns:
        Result quaternion
      • mul

        public static Vector3 mul​(Quaternion q,
                                  Vector3 v)
        Operator overloading for *
        Parameters:
        q - The rotation quaternion
        v - Vector to rotate
        Returns:
        Rotated vector
      • mul

        public static Vector4 mul​(Quaternion q,
                                  Vector4 v)
        Operator overloading for *
        Parameters:
        q - The rotation quaternion
        v - Vector to rotate
        Returns:
        Rotated vector
      • toString

        public java.lang.String toString()
        Gets the representation of quaternion in string
        Overrides:
        toString in class java.lang.Object
        Returns:
        Object string
      • mul

        public static Vector3 mul​(Vector3 v,
                                  Quaternion q)
        Operator overloading for *
        Parameters:
        v - The rotation quaternion
        q - Vector to rotate
        Returns:
        Rotated vector
      • op_eq

        public static boolean op_eq​(Quaternion lhs,
                                    Quaternion rhs)
        Equal operator for quaternion
        Parameters:
        lhs - Left hand side value.
        rhs - Right hand side value.
        Returns:
        True if all components are identically equal.
      • op_ne

        public static boolean op_ne​(Quaternion lhs,
                                    Quaternion rhs)
        Not-equal operator for quaternion
        Parameters:
        lhs - Left hand side value.
        rhs - Right hand side value.
        Returns:
        True if two quaternions are not equal.
      • interpolate

        public static Quaternion interpolate​(float t,
                                             Quaternion from,
                                             Quaternion to)
        Populates this quaternion with the interpolated value between the given quaternion arguments for a t between from and to.
        Parameters:
        t - The coefficient to interpolate.
        from - Source quaternion.
        to - Target quaternion.
        Returns:
        The interpolated quaternion.
      • clone

        public Quaternion clone()
        Specified by:
        clone in interface com.aspose.threed.Struct<Quaternion>
        Overrides:
        clone in class java.lang.Object
      • copyFrom

        public void copyFrom​(Quaternion src)
        Specified by:
        copyFrom in interface com.aspose.threed.Struct<Quaternion>
      • hashCode

        public int hashCode()
        Gets the hash code of Quaternion
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code of the Quaternion