Package org.gnome.graphene
Class Vec3
java.lang.Object
org.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
ConstructorsConstructorDescriptionVec3()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 TypeMethodDescriptionvoidAdds each component of the two given vectors.static Vec3alloc()Allocates a newgraphene_vec3_tstructure.voidComputes the cross product of the two given vectors.voidDivides each component of the first operand this Vec3 by the corresponding component of the second operandb,and places the results into the vectorres.floatComputes the dot product of the two given vectors.booleanChecks whether the two givengraphene_vec3_tare equal.voidfree()Frees the resources allocated by this Vec3static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the Vec3 classfloatgetX()Retrieves the first component of the given vectorv.voidCreates agraphene_vec2_tthat contains the first and second components of the givengraphene_vec3_t.voidCreates agraphene_vec3_tthat contains the first two components of the givengraphene_vec3_t, and the third component set to 0.voidConverts agraphene_vec3_tin agraphene_vec4_tusing 0.0 as the value for the fourth component of the resulting vector.voidConverts agraphene_vec3_tin agraphene_vec4_tusing 1.0 as the value for the fourth component of the resulting vector.voidConverts agraphene_vec3_tin agraphene_vec4_tusingwas the value of the fourth component of the resulting vector.floatgetY()Retrieves the second component of the given vectorv.floatgetZ()Retrieves the third component of the given vectorv.init(float x, float y, float z) Initializes agraphene_vec3_tusing the given values.initFromFloat(@org.jspecify.annotations.Nullable float @Nullable [] src) Initializes agraphene_vec3_twith the values from an array.initFromVec3(Vec3 src) Initializes agraphene_vec3_twith the values of anothergraphene_vec3_t.voidinterpolate(Vec3 v2, double factor, Vec3 res) Linearly interpolates this Vec3 andv2using the givenfactor.floatlength()Retrieves the length of the given vectorv.voidCompares each component of the two given vectors and creates a vector that contains the maximum values.voidCompares each component of the two given vectors and creates a vector that contains the minimum values.voidMultiplies each component of the two given vectors.booleanCompares the two givengraphene_vec3_tvectors and checks whether their values are within the givenepsilon.voidNegates the givengraphene_vec3_t.voidNormalizes the givengraphene_vec3_t.static Vec3one()Provides a constant pointer to a vector with three components, all sets to 1.@Nullable Simd4FRead the value of the fieldvalue.voidMultiplies all components of the given vector with the given scalarfactor.voidSubtracts from each component of the first operand this Vec3 the corresponding component of the second operandband places each result into the components ofres.voidCopies the components of agraphene_vec3_tinto the given array.voidwriteValue(@Nullable Simd4F value) Write a value in the fieldvalue.static Vec3xAxis()Provides a constant pointer to a vector with three components with values set to (1, 0, 0).static Vec3yAxis()Provides a constant pointer to a vector with three components with values set to (0, 1, 0).static Vec3zAxis()Provides a constant pointer to a vector with three components with values set to (0, 0, 1).static Vec3zero()Provides a constant pointer to a vector with three components, all sets to 0.Methods inherited from class org.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
Read the value of the fieldvalue.- Returns:
- The value of the field
value
-
writeValue
Write a value in the fieldvalue.- Parameters:
value- The new value for the fieldvalue
-
alloc
Allocates a newgraphene_vec3_tstructure.The contents of the returned structure are undefined.
Use graphene_vec3_init() to initialize the vector.
- Returns:
- the newly allocated
graphene_vec3_tstructure. Use graphene_vec3_free() to free the resources allocated by this function. - Since:
- 1.0
-
one
Provides a constant pointer to a vector with three components, all sets to 1.- Returns:
- a constant vector
- Since:
- 1.0
-
xAxis
Provides a constant pointer to a vector with three components with values set to (1, 0, 0).- Returns:
- a constant vector
- Since:
- 1.0
-
yAxis
Provides a constant pointer to a vector with three components with values set to (0, 1, 0).- Returns:
- a constant vector
- Since:
- 1.0
-
zAxis
Provides a constant pointer to a vector with three components with values set to (0, 0, 1).- Returns:
- a constant vector
- Since:
- 1.0
-
zero
Provides a constant pointer to a vector with three components, all sets to 0.- Returns:
- a constant vector
- Since:
- 1.0
-
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
- Since:
- 1.0
-
equal
Checks whether the two givengraphene_vec3_tare equal.- Parameters:
v2- agraphene_vec3_t- Returns:
trueif the two vectors are equal, and false otherwise- Since:
- 1.2
-
free
public void free()Frees the resources allocated by this Vec3- Since:
- 1.0
-
getX
public float getX()Retrieves the first component of the given vectorv.- Returns:
- the value of the first component of the vector
- Since:
- 1.0
-
getXy
Creates agraphene_vec2_tthat contains the first and second components of the givengraphene_vec3_t.- Parameters:
res- return location for agraphene_vec2_t- Since:
- 1.0
-
getXy0
Creates agraphene_vec3_tthat 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- Since:
- 1.0
-
getXyz0
Converts agraphene_vec3_tin agraphene_vec4_tusing 0.0 as the value for the fourth component of the resulting vector.- Parameters:
res- return location for the vector- Since:
- 1.0
-
getXyz1
Converts agraphene_vec3_tin agraphene_vec4_tusing 1.0 as the value for the fourth component of the resulting vector.- Parameters:
res- return location for the vector- Since:
- 1.0
-
getXyzw
Converts agraphene_vec3_tin agraphene_vec4_tusingwas the value of the fourth component of the resulting vector.- Parameters:
w- the value of the W componentres- return location for the vector- Since:
- 1.0
-
getY
public float getY()Retrieves the second component of the given vectorv.- Returns:
- the value of the second component of the vector
- Since:
- 1.0
-
getZ
public float getZ()Retrieves the third component of the given vectorv.- Returns:
- the value of the third component of the vector
- Since:
- 1.0
-
init
Initializes agraphene_vec3_tusing 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
- Since:
- 1.0
-
initFromFloat
Initializes agraphene_vec3_twith the values from an array.- Parameters:
src- an array of 3 floating point values- Returns:
- the initialized vector
- Throws:
IllegalArgumentException- when length ofsrcis less than 3- Since:
- 1.0
-
initFromVec3
-
interpolate
-
length
public float length()Retrieves the length of the given vectorv.- Returns:
- the value of the length of the vector
- Since:
- 1.0
-
max
-
min
-
multiply
-
near
Compares the two givengraphene_vec3_tvectors and checks whether their values are within the givenepsilon.- Parameters:
v2- agraphene_vec3_tepsilon- the threshold between the two vectors- Returns:
trueif the two vectors are near each other- Since:
- 1.2
-
negate
Negates the givengraphene_vec3_t.- Parameters:
res- return location for the result vector- Since:
- 1.2
-
normalize
Normalizes the givengraphene_vec3_t.- Parameters:
res- return location for the normalized vector- Since:
- 1.0
-
scale
Multiplies all components of the given vector with the given scalarfactor.- Parameters:
factor- the scalar factorres- return location for the result vector- Since:
- 1.2
-
subtract
-
toFloat
Copies the components of agraphene_vec3_tinto the given array.- Parameters:
dest- return location for an array of floating point values- Since:
- 1.0
-