Package org.gnome.graphene
Class Quaternion
java.lang.Object
org.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.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionAllocate 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 TypeMethodDescriptionvoidadd(Quaternion b, Quaternion res) Adds twographene_quaternion_tthis Quaternion andb.static Quaternionalloc()Allocates a newgraphene_quaternion_t.floatdot(Quaternion b) Computes the dot product of twographene_quaternion_t.booleanequal(Quaternion b) Checks whether the given quaternions are equal.voidfree()Releases the resources allocated by graphene_quaternion_alloc().static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the Quaternion classinit(float x, float y, float z, float w) Initializes agraphene_quaternion_tusing the given four values.initFromAngles(float degX, float degY, float degZ) Initializes agraphene_quaternion_tusing the values of the Euler angles on each axis.initFromAngleVec3(float angle, Vec3 axis) Initializes agraphene_quaternion_tusing anangleon a specificaxis.Initializes agraphene_quaternion_tusing the givengraphene_euler_t.Initializes agraphene_quaternion_tusing the rotation components of a transformation matrix.Initializes agraphene_quaternion_twith the values fromsrc.initFromRadians(float radX, float radY, float radZ) Initializes agraphene_quaternion_tusing the values of the Euler angles on each axis.initFromVec4(Vec4 src) Initializes agraphene_quaternion_twith the values fromsrc.Initializes agraphene_quaternion_tusing the identity transformation.voidinvert(Quaternion res) Inverts agraphene_quaternion_t, and returns the conjugate quaternion ofq.voidmultiply(Quaternion b, Quaternion res) Multiplies twographene_quaternion_tthis Quaternion andb.voidnormalize(Quaternion res) Normalizes agraphene_quaternion_t.floatreadW()Read the value of the fieldw.floatreadX()Read the value of the fieldx.floatreadY()Read the value of the fieldy.floatreadZ()Read the value of the fieldz.voidscale(float factor, Quaternion res) Scales all the elements of agraphene_quaternion_tthis Quaternion using the given scalar factor.voidslerp(Quaternion b, float factor, Quaternion res) Interpolates between the two given quaternions using a spherical linear interpolation, or SLERP, using the given interpolationfactor.voidConverts agraphene_quaternion_tto its corresponding rotations on the Euler angles on each axis.voidtoAngleVec3(Out<Float> angle, Vec3 axis) Converts a quaternion into anangle,axispair.voidConverts a quaternion into a transformation matrix expressing the rotation defined by thegraphene_quaternion_t.voidConverts agraphene_quaternion_tto its corresponding rotations on the Euler angles on each axis.voidCopies the components of agraphene_quaternion_tinto agraphene_vec4_t.voidwriteW(float w) Write a value in the fieldw.voidwriteX(float x) Write a value in the fieldx.voidwriteY(float y) Write a value in the fieldy.voidwriteZ(float z) Write a value in the fieldz.Methods inherited from class org.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 fieldxy- value for the fieldyz- value for the fieldzw- value for the fieldwarena- 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 fieldxy- value for the fieldyz- value for the fieldzw- 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 - Since:
- 1.0
-
add
Adds twographene_quaternion_tthis Quaternion andb.- Parameters:
b- agraphene_quaternion_tres- the result of the operation- Since:
- 1.10
-
dot
Computes the dot product of twographene_quaternion_t.- Parameters:
b- agraphene_quaternion_t- Returns:
- the value of the dot products
- Since:
- 1.0
-
equal
Checks whether the given quaternions are equal.- Parameters:
b- agraphene_quaternion_t- Returns:
trueif the quaternions are equal- Since:
- 1.0
-
free
public void free()Releases the resources allocated by graphene_quaternion_alloc().- Since:
- 1.0
-
init
Initializes agraphene_quaternion_tusing 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
- Since:
- 1.0
-
initFromAngleVec3
Initializes agraphene_quaternion_tusing anangleon a specificaxis.- Parameters:
angle- the rotation on a given axis, in degreesaxis- the axis of rotation, expressed as a vector- Returns:
- the initialized quaternion
- Since:
- 1.0
-
initFromAngles
Initializes agraphene_quaternion_tusing 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
- Since:
- 1.0
-
initFromEuler
Initializes agraphene_quaternion_tusing the givengraphene_euler_t.- Parameters:
e- agraphene_euler_t- Returns:
- the initialized
graphene_quaternion_t - Since:
- 1.2
-
initFromMatrix
Initializes agraphene_quaternion_tusing the rotation components of a transformation matrix.- Parameters:
m- agraphene_matrix_t- Returns:
- the initialized quaternion
- Since:
- 1.0
-
initFromQuaternion
Initializes agraphene_quaternion_twith the values fromsrc.- Parameters:
src- agraphene_quaternion_t- Returns:
- the initialized quaternion
- Since:
- 1.0
-
initFromRadians
Initializes agraphene_quaternion_tusing 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
- Since:
- 1.0
-
initFromVec4
Initializes agraphene_quaternion_twith the values fromsrc.- Parameters:
src- agraphene_vec4_t- Returns:
- the initialized quaternion
- Since:
- 1.0
-
initIdentity
Initializes agraphene_quaternion_tusing the identity transformation.- Returns:
- the initialized quaternion
- Since:
- 1.0
-
invert
Inverts agraphene_quaternion_t, and returns the conjugate quaternion ofq.- Parameters:
res- return location for the inverted quaternion- Since:
- 1.0
-
multiply
Multiplies twographene_quaternion_tthis Quaternion andb.- Parameters:
b- agraphene_quaternion_tres- the result of the operation- Since:
- 1.10
-
normalize
Normalizes agraphene_quaternion_t.- Parameters:
res- return location for the normalized quaternion- Since:
- 1.0
-
scale
Scales all the elements of agraphene_quaternion_tthis Quaternion using the given scalar factor.- Parameters:
factor- a scaling factorres- the result of the operation- Since:
- 1.10
-
slerp
Interpolates between the two given quaternions using a spherical linear interpolation, or SLERP, using the given interpolationfactor.- Parameters:
b- agraphene_quaternion_tfactor- the linear interpolation factorres- return location for the interpolated quaternion- Since:
- 1.0
-
toAngleVec3
-
toAngles
public void toAngles(@Nullable Out<Float> degX, @Nullable Out<Float> degY, @Nullable Out<Float> degZ) Converts agraphene_quaternion_tto 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- Since:
- 1.2
-
toMatrix
Converts a quaternion into a transformation matrix expressing the rotation defined by thegraphene_quaternion_t.- Parameters:
m- agraphene_matrix_t- Since:
- 1.0
-
toRadians
public void toRadians(@Nullable Out<Float> radX, @Nullable Out<Float> radY, @Nullable Out<Float> radZ) Converts agraphene_quaternion_tto 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- Since:
- 1.2
-
toVec4
Copies the components of agraphene_quaternion_tinto agraphene_vec4_t.- Parameters:
res- return location for agraphene_vec4_t- Since:
- 1.0
-