Class Quaternion

All Implemented Interfaces:
PointerInterface

public class Quaternion extends Record
A quaternion.

The contents of the #graphene_quaternion_t structure are private
and should never be accessed directly.

https://ebassi.github.io/graphene/docs/

  • Field Details

  • Constructor Details

    • Quaternion

      public Quaternion(PointerContainer pointer)
    • Quaternion

      public Quaternion()
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getFieldX

      public float getFieldX()
    • getFieldY

      public float getFieldY()
    • getFieldZ

      public float getFieldZ()
    • getFieldW

      public float getFieldW()
    • allocQuaternion

      public static Quaternion allocQuaternion()
      Allocates a new #graphene_quaternion_t.

      The contents of the returned value are undefined.
      Returns:
      the newly allocated #graphene_quaternion_t
    • add

      public void add(@Nonnull Quaternion b, @Nonnull Quaternion res)
      Adds two #graphene_quaternion_t @a and @b.
      Parameters:
      b - a #graphene_quaternion_t
      res - the result of the operation
    • dot

      public float dot(@Nonnull Quaternion b)
      Computes the dot product of two #graphene_quaternion_t.
      Parameters:
      b - a #graphene_quaternion_t
      Returns:
      the value of the dot products
    • equal

      public boolean equal(@Nonnull Quaternion b)
      Checks whether the given quaternions are equal.
      Parameters:
      b - a #graphene_quaternion_t
      Returns:
      `true` if the quaternions are equal
    • free

      public void free()
      Releases the resources allocated by graphene_quaternion_alloc().
    • init

      public Quaternion init(float x, float y, float z, float w)
      Initializes a #graphene_quaternion_t using the given four values.
      Parameters:
      x - the first component of the quaternion
      y - the second component of the quaternion
      z - the third component of the quaternion
      w - the fourth component of the quaternion
      Returns:
      the initialized quaternion
    • initFromAngleVec3

      public Quaternion initFromAngleVec3(float angle, @Nonnull Vec3 axis)
      Initializes a #graphene_quaternion_t using an @angle on a
      specific @axis.
      Parameters:
      angle - the rotation on a given axis, in degrees
      axis - the axis of rotation, expressed as a vector
      Returns:
      the initialized quaternion
    • initFromAngles

      public Quaternion initFromAngles(float deg_x, float deg_y, float deg_z)
      Initializes a #graphene_quaternion_t using the values of
      the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
      on each axis.

      See also: graphene_quaternion_init_from_euler()
      Parameters:
      deg_x - rotation angle on the X axis (yaw), in degrees
      deg_y - rotation angle on the Y axis (pitch), in degrees
      deg_z - rotation angle on the Z axis (roll), in degrees
      Returns:
      the initialized quaternion
    • initFromEuler

      public Quaternion initFromEuler(@Nonnull Euler e)
      Initializes a #graphene_quaternion_t using the given #graphene_euler_t.
      Parameters:
      e - a #graphene_euler_t
      Returns:
      the initialized #graphene_quaternion_t
    • initFromMatrix

      public Quaternion initFromMatrix(@Nonnull Matrix m)
      Initializes a #graphene_quaternion_t using the rotation components
      of a transformation matrix.
      Parameters:
      m - a #graphene_matrix_t
      Returns:
      the initialized quaternion
    • initFromQuaternion

      public Quaternion initFromQuaternion(@Nonnull Quaternion src)
      Initializes a #graphene_quaternion_t with the values from @src.
      Parameters:
      src - a #graphene_quaternion_t
      Returns:
      the initialized quaternion
    • initFromRadians

      public Quaternion initFromRadians(float rad_x, float rad_y, float rad_z)
      Initializes a #graphene_quaternion_t using the values of
      the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
      on each axis.

      See also: graphene_quaternion_init_from_euler()
      Parameters:
      rad_x - rotation angle on the X axis (yaw), in radians
      rad_y - rotation angle on the Y axis (pitch), in radians
      rad_z - rotation angle on the Z axis (roll), in radians
      Returns:
      the initialized quaternion
    • initFromVec4

      public Quaternion initFromVec4(@Nonnull Vec4 src)
      Initializes a #graphene_quaternion_t with the values from @src.
      Parameters:
      src - a #graphene_vec4_t
      Returns:
      the initialized quaternion
    • initIdentity

      public Quaternion initIdentity()
      Initializes a #graphene_quaternion_t using the identity
      transformation.
      Returns:
      the initialized quaternion
    • invert

      public void invert(@Nonnull Quaternion res)
      Inverts a #graphene_quaternion_t, and returns the conjugate
      quaternion of @q.
      Parameters:
      res - return location for the inverted quaternion
    • multiply

      public void multiply(@Nonnull Quaternion b, @Nonnull Quaternion res)
      Multiplies two #graphene_quaternion_t @a and @b.
      Parameters:
      b - a #graphene_quaternion_t
      res - the result of the operation
    • normalize

      public void normalize(@Nonnull Quaternion res)
      Normalizes a #graphene_quaternion_t.
      Parameters:
      res - return location for the normalized quaternion
    • scale

      public void scale(float factor, @Nonnull Quaternion res)
      Scales all the elements of a #graphene_quaternion_t @q using
      the given scalar factor.
      Parameters:
      factor - a scaling factor
      res - the result of the operation
    • slerp

      public void slerp(@Nonnull Quaternion b, float factor, @Nonnull Quaternion res)
      Interpolates between the two given quaternions using a spherical
      linear interpolation, or [SLERP](http://en.wikipedia.org/wiki/Slerp),
      using the given interpolation @factor.
      Parameters:
      b - a #graphene_quaternion_t
      factor - the linear interpolation factor
      res - return location for the interpolated quaternion
    • toAngleVec3

      public void toAngleVec3(@Nonnull Flt angle, @Nonnull Vec3 axis)
      Converts a quaternion into an @angle, @axis pair.
      Parameters:
      angle - return location for the angle, in degrees
      axis - return location for the rotation axis
    • toAngles

      public void toAngles(@Nullable Flt deg_x, @Nullable Flt deg_y, @Nullable Flt deg_z)
      Converts a #graphene_quaternion_t to its corresponding rotations
      on the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
      on each axis.
      Parameters:
      deg_x - return location for the rotation angle on the X axis (yaw), in degrees
      deg_y - return location for the rotation angle on the Y axis (pitch), in degrees
      deg_z - return location for the rotation angle on the Z axis (roll), in degrees
    • toMatrix

      public void toMatrix(@Nonnull Matrix m)
      Converts a quaternion into a transformation matrix expressing
      the rotation defined by the #graphene_quaternion_t.
      Parameters:
      m - a #graphene_matrix_t
    • toRadians

      public void toRadians(@Nullable Flt rad_x, @Nullable Flt rad_y, @Nullable Flt rad_z)
      Converts a #graphene_quaternion_t to its corresponding rotations
      on the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
      on each axis.
      Parameters:
      rad_x - return location for the rotation angle on the X axis (yaw), in radians
      rad_y - return location for the rotation angle on the Y axis (pitch), in radians
      rad_z - return location for the rotation angle on the Z axis (roll), in radians
    • toVec4

      public void toVec4(@Nonnull Vec4 res)
      Copies the components of a #graphene_quaternion_t into a
      #graphene_vec4_t.
      Parameters:
      res - return location for a #graphene_vec4_t
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()