Class Quaternion

java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.graphene.Quaternion
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Quaternion extends ProxyInstance

A quaternion.

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

Since:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new Quaternion.
    Quaternion(float x, float y, float z, float w)
    Allocate a new Quaternion with the fields set to the provided values.
    Quaternion(float x, float y, float z, float w, Arena arena)
    Allocate a new Quaternion with the fields set to the provided values.
    Allocate a new Quaternion.
    Create a Quaternion proxy instance for the provided memory address.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds two graphene_quaternion_t this Quaternion and b.
    static Quaternion
    Allocates a new graphene_quaternion_t.
    float
    Computes the dot product of two graphene_quaternion_t.
    boolean
    Checks whether the given quaternions are equal.
    void
    Releases the resources allocated by graphene_quaternion_alloc().
    The memory layout of the native struct.
    static @Nullable Type
    Get the GType of the Quaternion class.
    init(float x, float y, float z, float w)
    Initializes a graphene_quaternion_t using the given four values.
    initFromAngles(float degX, float degY, float degZ)
    Initializes a graphene_quaternion_t using the values of the Euler angles on each axis.
    initFromAngleVec3(float angle, Vec3 axis)
    Initializes a graphene_quaternion_t using an angle on a specific axis.
    Initializes a graphene_quaternion_t using the given graphene_euler_t.
    Initializes a graphene_quaternion_t using the rotation components of a transformation matrix.
    Initializes a graphene_quaternion_t with the values from src.
    initFromRadians(float radX, float radY, float radZ)
    Initializes a graphene_quaternion_t using the values of the Euler angles on each axis.
    Initializes a graphene_quaternion_t with the values from src.
    Initializes a graphene_quaternion_t using the identity transformation.
    void
    Inverts a graphene_quaternion_t, and returns the conjugate quaternion of q.
    void
    Multiplies two graphene_quaternion_t this Quaternion and b.
    void
    Normalizes a graphene_quaternion_t.
    float
    Read the value of the field w.
    float
    Read the value of the field x.
    float
    Read the value of the field y.
    float
    Read the value of the field z.
    void
    scale(float factor, Quaternion res)
    Scales all the elements of a graphene_quaternion_t this Quaternion using the given scalar factor.
    void
    slerp(Quaternion b, float factor, Quaternion res)
    Interpolates between the two given quaternions using a spherical linear interpolation, or SLERP, using the given interpolation factor.
    void
    toAngles(@Nullable Out<Float> degX, @Nullable Out<Float> degY, @Nullable Out<Float> degZ)
    Converts a graphene_quaternion_t to its corresponding rotations on the Euler angles on each axis.
    void
    toAngleVec3(Out<Float> angle, Vec3 axis)
    Converts a quaternion into an angle, axis pair.
    void
    Converts a quaternion into a transformation matrix expressing the rotation defined by the graphene_quaternion_t.
    void
    toRadians(@Nullable Out<Float> radX, @Nullable Out<Float> radY, @Nullable Out<Float> radZ)
    Converts a graphene_quaternion_t to its corresponding rotations on the Euler angles on each axis.
    void
    toVec4(Vec4 res)
    Copies the components of a graphene_quaternion_t into a graphene_vec4_t.
    void
    writeW(float w)
    Write a value in the field w.
    void
    writeX(float x)
    Write a value in the field x.
    void
    writeY(float y)
    Write a value in the field y.
    void
    writeZ(float z)
    Write a value in the field z.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Quaternion

      public Quaternion(MemorySegment address)
      Create a Quaternion proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Quaternion

      public Quaternion(Arena arena)
      Allocate a new Quaternion.
      Parameters:
      arena - to control the memory allocation scope
    • Quaternion

      public Quaternion()
      Allocate a new Quaternion. The memory is allocated with Arena.ofAuto().
    • Quaternion

      public Quaternion(float x, float y, float z, float w, Arena arena)
      Allocate a new Quaternion with the fields set to the provided values.
      Parameters:
      x - value for the field x
      y - value for the field y
      z - value for the field z
      w - value for the field w
      arena - to control the memory allocation scope
    • Quaternion

      public Quaternion(float x, float y, float z, float w)
      Allocate a new Quaternion with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      x - value for the field x
      y - value for the field y
      z - value for the field z
      w - value for the field w
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Quaternion class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readX

      public float readX()
      Read the value of the field x.
      Returns:
      The value of the field x
    • writeX

      public void writeX(float x)
      Write a value in the field x.
      Parameters:
      x - The new value for the field x
    • readY

      public float readY()
      Read the value of the field y.
      Returns:
      The value of the field y
    • writeY

      public void writeY(float y)
      Write a value in the field y.
      Parameters:
      y - The new value for the field y
    • readZ

      public float readZ()
      Read the value of the field z.
      Returns:
      The value of the field z
    • writeZ

      public void writeZ(float z)
      Write a value in the field z.
      Parameters:
      z - The new value for the field z
    • readW

      public float readW()
      Read the value of the field w.
      Returns:
      The value of the field w
    • writeW

      public void writeW(float w)
      Write a value in the field w.
      Parameters:
      w - The new value for the field w
    • alloc

      public static Quaternion alloc()

      Allocates a new graphene_quaternion_t.

      The contents of the returned value are undefined.

      Returns:
      the newly allocated graphene_quaternion_t
      Since:
      1.0
    • add

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

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

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

      public void free()
      Releases the resources allocated by graphene_quaternion_alloc().
      Since:
      1.0
    • 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
      Since:
      1.0
    • initFromAngleVec3

      public Quaternion initFromAngleVec3(float angle, 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
      Since:
      1.0
    • initFromAngles

      public Quaternion initFromAngles(float degX, float degY, float degZ)

      Initializes a graphene_quaternion_t using the values of the Euler angles on each axis.

      See also: graphene_quaternion_init_from_euler()

      Parameters:
      degX - rotation angle on the X axis (yaw), in degrees
      degY - rotation angle on the Y axis (pitch), in degrees
      degZ - rotation angle on the Z axis (roll), in degrees
      Returns:
      the initialized quaternion
      Since:
      1.0
    • initFromEuler

      public Quaternion initFromEuler(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
      Since:
      1.2
    • initFromMatrix

      public Quaternion initFromMatrix(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
      Since:
      1.0
    • initFromQuaternion

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

      public Quaternion initFromRadians(float radX, float radY, float radZ)

      Initializes a graphene_quaternion_t using the values of the Euler angles on each axis.

      See also: graphene_quaternion_init_from_euler()

      Parameters:
      radX - rotation angle on the X axis (yaw), in radians
      radY - rotation angle on the Y axis (pitch), in radians
      radZ - rotation angle on the Z axis (roll), in radians
      Returns:
      the initialized quaternion
      Since:
      1.0
    • initFromVec4

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

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

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

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

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

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

      public void slerp(Quaternion b, float factor, Quaternion res)
      Interpolates between the two given quaternions using a spherical linear interpolation, or SLERP, using the given interpolation factor.
      Parameters:
      b - a graphene_quaternion_t
      factor - the linear interpolation factor
      res - return location for the interpolated quaternion
      Since:
      1.0
    • toAngleVec3

      public void toAngleVec3(Out<Float> angle, 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
      Since:
      1.0
    • toAngles

      public void toAngles(@Nullable Out<Float> degX, @Nullable Out<Float> degY, @Nullable Out<Float> degZ)
      Converts a graphene_quaternion_t to its corresponding rotations on the Euler angles on each axis.
      Parameters:
      degX - return location for the rotation angle on the X axis (yaw), in degrees
      degY - return location for the rotation angle on the Y axis (pitch), in degrees
      degZ - return location for the rotation angle on the Z axis (roll), in degrees
      Since:
      1.2
    • toMatrix

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

      public void toRadians(@Nullable Out<Float> radX, @Nullable Out<Float> radY, @Nullable Out<Float> radZ)
      Converts a graphene_quaternion_t to its corresponding rotations on the Euler angles on each axis.
      Parameters:
      radX - return location for the rotation angle on the X axis (yaw), in radians
      radY - return location for the rotation angle on the Y axis (pitch), in radians
      radZ - return location for the rotation angle on the Z axis (roll), in radians
      Since:
      1.2
    • toVec4

      public void toVec4(Vec4 res)
      Copies the components of a graphene_quaternion_t into a graphene_vec4_t.
      Parameters:
      res - return location for a graphene_vec4_t
      Since:
      1.0