Package org.gnome.graphene
Class Vec3
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.graphene.Vec3
- All Implemented Interfaces:
Proxy
A structure capable of holding a vector with three dimensions: x, y, and z.
The contents of the graphene_vec3_t
structure are private and should
never be accessed directly.
-
Constructor Summary
ConstructorDescriptionVec3()
Allocate a new Vec3.Allocate a new Vec3.Vec3
(MemorySegment address) Create a Vec3 proxy instance for the provided memory address.Allocate a new Vec3 with the fields set to the provided values.Allocate a new Vec3 with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds each component of the two given vectors.static Vec3
alloc()
Allocates a newgraphene_vec3_t
structure.void
Computes the cross product of the two given vectors.void
Divides each component of the first operand this Vec3 by the corresponding component of the second operandb
, and places the results into the vectorres
.float
Computes the dot product of the two given vectors.boolean
Checks whether the two givengraphene_vec3_t
are equal.void
free()
Frees the resources allocated by this Vec3static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the Vec3 classfloat
getX()
Retrieves the first component of the given vector this Vec3.void
Creates agraphene_vec2_t
that contains the first and second components of the givengraphene_vec3_t
.void
Creates agraphene_vec3_t
that contains the first two components of the givengraphene_vec3_t
, and the third component set to 0.void
Converts agraphene_vec3_t
in agraphene_vec4_t
using 0.0 as the value for the fourth component of the resulting vector.void
Converts agraphene_vec3_t
in agraphene_vec4_t
using 1.0 as the value for the fourth component of the resulting vector.void
Converts agraphene_vec3_t
in agraphene_vec4_t
usingw
as the value of the fourth component of the resulting vector.float
getY()
Retrieves the second component of the given vector this Vec3.float
getZ()
Retrieves the third component of the given vector this Vec3.init
(float x, float y, float z) Initializes agraphene_vec3_t
using the given values.initFromFloat
(float[] src) Initializes agraphene_vec3_t
with the values from an array.initFromVec3
(Vec3 src) Initializes agraphene_vec3_t
with the values of anothergraphene_vec3_t
.void
interpolate
(Vec3 v2, double factor, Vec3 res) Linearly interpolates this Vec3 andv2
using the givenfactor
.float
length()
Retrieves the length of the given vector this Vec3.void
Compares each component of the two given vectors and creates a vector that contains the maximum values.void
Compares each component of the two given vectors and creates a vector that contains the minimum values.void
Multiplies each component of the two given vectors.boolean
Compares the two givengraphene_vec3_t
vectors and checks whether their values are within the givenepsilon
.void
Negates the givengraphene_vec3_t
.void
Normalizes the givengraphene_vec3_t
.static Vec3
one()
Provides a constant pointer to a vector with three components, all sets to 1.Read the value of the fieldvalue
.void
Multiplies all components of the given vector with the given scalarfactor
.void
Subtracts from each component of the first operand this Vec3 the corresponding component of the second operandb
and places each result into the components ofres
.void
toFloat
(float[] dest) Copies the components of agraphene_vec3_t
into the given array.void
writeValue
(Simd4F value) Write a value in the fieldvalue
.static Vec3
xAxis()
Provides a constant pointer to a vector with three components with values set to (1, 0, 0).static Vec3
yAxis()
Provides a constant pointer to a vector with three components with values set to (0, 1, 0).static Vec3
zAxis()
Provides a constant pointer to a vector with three components with values set to (0, 0, 1).static Vec3
zero()
Provides a constant pointer to a vector with three components, all sets to 0.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Vec3
Create a Vec3 proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Vec3
Allocate a new Vec3.- Parameters:
arena
- to control the memory allocation scope
-
Vec3
public Vec3()Allocate a new Vec3. The memory is allocated withArena.ofAuto()
. -
Vec3
-
Vec3
Allocate a new Vec3 with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
value
- value for the fieldvalue
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readValue
-
writeValue
Write a value in the fieldvalue
.- Parameters:
value
- The new value for the fieldvalue
-
alloc
Allocates a newgraphene_vec3_t
structure.The contents of the returned structure are undefined.
Use graphene_vec3_init() to initialize the vector.
- Returns:
- the newly allocated
graphene_vec3_t
structure. Use graphene_vec3_free() to free the resources allocated by this function.
-
one
Provides a constant pointer to a vector with three components, all sets to 1.- Returns:
- a constant vector
-
xAxis
Provides a constant pointer to a vector with three components with values set to (1, 0, 0).- Returns:
- a constant vector
-
yAxis
Provides a constant pointer to a vector with three components with values set to (0, 1, 0).- Returns:
- a constant vector
-
zAxis
Provides a constant pointer to a vector with three components with values set to (0, 0, 1).- Returns:
- a constant vector
-
zero
Provides a constant pointer to a vector with three components, all sets to 0.- Returns:
- a constant vector
-
add
-
cross
-
divide
-
dot
Computes the dot product of the two given vectors.- Parameters:
b
- agraphene_vec3_t
- Returns:
- the value of the dot product
-
equal
Checks whether the two givengraphene_vec3_t
are equal.- Parameters:
v2
- agraphene_vec3_t
- Returns:
true
if the two vectors are equal, and false otherwise
-
free
public void free()Frees the resources allocated by this Vec3 -
getX
public float getX()Retrieves the first component of the given vector this Vec3.- Returns:
- the value of the first component of the vector
-
getXy
Creates agraphene_vec2_t
that contains the first and second components of the givengraphene_vec3_t
.- Parameters:
res
- return location for agraphene_vec2_t
-
getXy0
Creates agraphene_vec3_t
that contains the first two components of the givengraphene_vec3_t
, and the third component set to 0.- Parameters:
res
- return location for agraphene_vec3_t
-
getXyz0
Converts agraphene_vec3_t
in agraphene_vec4_t
using 0.0 as the value for the fourth component of the resulting vector.- Parameters:
res
- return location for the vector
-
getXyz1
Converts agraphene_vec3_t
in agraphene_vec4_t
using 1.0 as the value for the fourth component of the resulting vector.- Parameters:
res
- return location for the vector
-
getXyzw
Converts agraphene_vec3_t
in agraphene_vec4_t
usingw
as the value of the fourth component of the resulting vector.- Parameters:
w
- the value of the W componentres
- return location for the vector
-
getY
public float getY()Retrieves the second component of the given vector this Vec3.- Returns:
- the value of the second component of the vector
-
getZ
public float getZ()Retrieves the third component of the given vector this Vec3.- Returns:
- the value of the third component of the vector
-
init
Initializes agraphene_vec3_t
using the given values.This function can be called multiple times.
- Parameters:
x
- the X field of the vectory
- the Y field of the vectorz
- the Z field of the vector- Returns:
- a pointer to the initialized vector
-
initFromFloat
Initializes agraphene_vec3_t
with the values from an array.- Parameters:
src
- an array of 3 floating point values- Returns:
- the initialized vector
-
initFromVec3
-
interpolate
-
length
public float length()Retrieves the length of the given vector this Vec3.- Returns:
- the value of the length of the vector
-
max
-
min
-
multiply
-
near
Compares the two givengraphene_vec3_t
vectors and checks whether their values are within the givenepsilon
.- Parameters:
v2
- agraphene_vec3_t
epsilon
- the threshold between the two vectors- Returns:
true
if the two vectors are near each other
-
negate
Negates the givengraphene_vec3_t
.- Parameters:
res
- return location for the result vector
-
normalize
Normalizes the givengraphene_vec3_t
.- Parameters:
res
- return location for the normalized vector
-
scale
Multiplies all components of the given vector with the given scalarfactor
.- Parameters:
factor
- the scalar factorres
- return location for the result vector
-
subtract
-
toFloat
public void toFloat(float[] dest) Copies the components of agraphene_vec3_t
into the given array.- Parameters:
dest
- return location for an array of floating point values
-