Package org.gnome.graphene
Class Quaternion
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.graphene.Quaternion
- All Implemented Interfaces:
Proxy
A quaternion.
The contents of the graphene_quaternion_t
structure are private
and should never be accessed directly.
-
Constructor Summary
ConstructorDescriptionAllocate 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.Quaternion
(Arena arena) Allocate a new Quaternion.Quaternion
(MemorySegment address) Create a Quaternion proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Quaternion b, Quaternion res) Adds twographene_quaternion_t
this Quaternion andb
.static Quaternion
alloc()
Allocates a newgraphene_quaternion_t
.float
dot
(Quaternion b) Computes the dot product of twographene_quaternion_t
.boolean
equal
(Quaternion b) Checks whether the given quaternions are equal.void
free()
Releases the resources allocated by graphene_quaternion_alloc().static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the Quaternion classinit
(float x, float y, float z, float w) Initializes agraphene_quaternion_t
using the given four values.initFromAngles
(float degX, float degY, float degZ) Initializes agraphene_quaternion_t
using the values of the Euler angles on each axis.initFromAngleVec3
(float angle, Vec3 axis) Initializes agraphene_quaternion_t
using anangle
on a specificaxis
.Initializes agraphene_quaternion_t
using the givengraphene_euler_t
.Initializes agraphene_quaternion_t
using the rotation components of a transformation matrix.Initializes agraphene_quaternion_t
with the values fromsrc
.initFromRadians
(float radX, float radY, float radZ) Initializes agraphene_quaternion_t
using the values of the Euler angles on each axis.initFromVec4
(Vec4 src) Initializes agraphene_quaternion_t
with the values fromsrc
.Initializes agraphene_quaternion_t
using the identity transformation.void
invert
(Quaternion res) Inverts agraphene_quaternion_t
, and returns the conjugate quaternion of this Quaternion.void
multiply
(Quaternion b, Quaternion res) Multiplies twographene_quaternion_t
this Quaternion andb
.void
normalize
(Quaternion res) Normalizes agraphene_quaternion_t
.float
readW()
Read the value of the fieldw
.float
readX()
Read the value of the fieldx
.float
readY()
Read the value of the fieldy
.float
readZ()
Read the value of the fieldz
.void
scale
(float factor, Quaternion res) Scales all the elements of agraphene_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 interpolationfactor
.void
Converts agraphene_quaternion_t
to its corresponding rotations on the Euler angles on each axis.void
toAngleVec3
(Out<Float> angle, Vec3 axis) Converts a quaternion into anangle
,axis
pair.void
Converts a quaternion into a transformation matrix expressing the rotation defined by thegraphene_quaternion_t
.void
Converts agraphene_quaternion_t
to its corresponding rotations on the Euler angles on each axis.void
Copies the components of agraphene_quaternion_t
into agraphene_vec4_t
.void
writeW
(float w) Write a value in the fieldw
.void
writeX
(float x) Write a value in the fieldx
.void
writeY
(float y) Write a value in the fieldy
.void
writeZ
(float z) Write a value in the fieldz
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Quaternion
Create a Quaternion proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Quaternion
Allocate a new Quaternion.- Parameters:
arena
- to control the memory allocation scope
-
Quaternion
public Quaternion()Allocate a new Quaternion. The memory is allocated withArena.ofAuto()
. -
Quaternion
Allocate a new Quaternion with the fields set to the provided values.- Parameters:
x
- value for the fieldx
y
- value for the fieldy
z
- value for the fieldz
w
- value for the fieldw
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 withArena.ofAuto()
.- Parameters:
x
- value for the fieldx
y
- value for the fieldy
z
- value for the fieldz
w
- value for the fieldw
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readX
public float readX()Read the value of the fieldx
.- Returns:
- The value of the field
x
-
writeX
public void writeX(float x) Write a value in the fieldx
.- Parameters:
x
- The new value for the fieldx
-
readY
public float readY()Read the value of the fieldy
.- Returns:
- The value of the field
y
-
writeY
public void writeY(float y) Write a value in the fieldy
.- Parameters:
y
- The new value for the fieldy
-
readZ
public float readZ()Read the value of the fieldz
.- Returns:
- The value of the field
z
-
writeZ
public void writeZ(float z) Write a value in the fieldz
.- Parameters:
z
- The new value for the fieldz
-
readW
public float readW()Read the value of the fieldw
.- Returns:
- The value of the field
w
-
writeW
public void writeW(float w) Write a value in the fieldw
.- Parameters:
w
- The new value for the fieldw
-
alloc
Allocates a newgraphene_quaternion_t
.The contents of the returned value are undefined.
- Returns:
- the newly allocated
graphene_quaternion_t
-
add
Adds twographene_quaternion_t
this Quaternion andb
.- Parameters:
b
- agraphene_quaternion_t
res
- the result of the operation
-
dot
Computes the dot product of twographene_quaternion_t
.- Parameters:
b
- agraphene_quaternion_t
- Returns:
- the value of the dot products
-
equal
Checks whether the given quaternions are equal.- Parameters:
b
- agraphene_quaternion_t
- Returns:
true
if the quaternions are equal
-
free
public void free()Releases the resources allocated by graphene_quaternion_alloc(). -
init
Initializes agraphene_quaternion_t
using the given four values.- Parameters:
x
- the first component of the quaterniony
- the second component of the quaternionz
- the third component of the quaternionw
- the fourth component of the quaternion- Returns:
- the initialized quaternion
-
initFromAngleVec3
Initializes agraphene_quaternion_t
using anangle
on a specificaxis
.- Parameters:
angle
- the rotation on a given axis, in degreesaxis
- the axis of rotation, expressed as a vector- Returns:
- the initialized quaternion
-
initFromAngles
Initializes agraphene_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 degreesdegY
- rotation angle on the Y axis (pitch), in degreesdegZ
- rotation angle on the Z axis (roll), in degrees- Returns:
- the initialized quaternion
-
initFromEuler
Initializes agraphene_quaternion_t
using the givengraphene_euler_t
.- Parameters:
e
- agraphene_euler_t
- Returns:
- the initialized
graphene_quaternion_t
-
initFromMatrix
Initializes agraphene_quaternion_t
using the rotation components of a transformation matrix.- Parameters:
m
- agraphene_matrix_t
- Returns:
- the initialized quaternion
-
initFromQuaternion
Initializes agraphene_quaternion_t
with the values fromsrc
.- Parameters:
src
- agraphene_quaternion_t
- Returns:
- the initialized quaternion
-
initFromRadians
Initializes agraphene_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 radiansradY
- rotation angle on the Y axis (pitch), in radiansradZ
- rotation angle on the Z axis (roll), in radians- Returns:
- the initialized quaternion
-
initFromVec4
Initializes agraphene_quaternion_t
with the values fromsrc
.- Parameters:
src
- agraphene_vec4_t
- Returns:
- the initialized quaternion
-
initIdentity
Initializes agraphene_quaternion_t
using the identity transformation.- Returns:
- the initialized quaternion
-
invert
Inverts agraphene_quaternion_t
, and returns the conjugate quaternion of this Quaternion.- Parameters:
res
- return location for the inverted quaternion
-
multiply
Multiplies twographene_quaternion_t
this Quaternion andb
.- Parameters:
b
- agraphene_quaternion_t
res
- the result of the operation
-
normalize
Normalizes agraphene_quaternion_t
.- Parameters:
res
- return location for the normalized quaternion
-
scale
Scales all the elements of agraphene_quaternion_t
this Quaternion using the given scalar factor.- Parameters:
factor
- a scaling factorres
- the result of the operation
-
slerp
Interpolates between the two given quaternions using a spherical linear interpolation, or SLERP, using the given interpolationfactor
.- Parameters:
b
- agraphene_quaternion_t
factor
- the linear interpolation factorres
- return location for the interpolated quaternion
-
toAngleVec3
-
toAngles
public void toAngles(@Nullable @Nullable Out<Float> degX, @Nullable @Nullable Out<Float> degY, @Nullable @Nullable Out<Float> degZ) Converts agraphene_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 degreesdegY
- return location for the rotation angle on the Y axis (pitch), in degreesdegZ
- return location for the rotation angle on the Z axis (roll), in degrees
-
toMatrix
Converts a quaternion into a transformation matrix expressing the rotation defined by thegraphene_quaternion_t
.- Parameters:
m
- agraphene_matrix_t
-
toRadians
public void toRadians(@Nullable @Nullable Out<Float> radX, @Nullable @Nullable Out<Float> radY, @Nullable @Nullable Out<Float> radZ) Converts agraphene_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 radiansradY
- return location for the rotation angle on the Y axis (pitch), in radiansradZ
- return location for the rotation angle on the Z axis (roll), in radians
-
toVec4
Copies the components of agraphene_quaternion_t
into agraphene_vec4_t
.- Parameters:
res
- return location for agraphene_vec4_t
-