Package org.gnome.graphene
Class Vec4
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.graphene.Vec4
- All Implemented Interfaces:
Proxy
A structure capable of holding a vector with four dimensions: x, y, z, and w.
The contents of the graphene_vec4_t structure are private and should
never be accessed directly.
-
Constructor Summary
ConstructorsConstructorDescriptionVec4()Allocate a new Vec4.Allocate a new Vec4.Vec4(MemorySegment address) Create a Vec4 proxy instance for the provided memory address.Allocate a new Vec4 with the fields set to the provided values.Allocate a new Vec4 with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds each component of the two given vectors.static Vec4alloc()Allocates a newgraphene_vec4_tstructure.voidDivides each component of the first operand this Vec4 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_vec4_tare equal.voidfree()Frees the resources allocated by this Vec4static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the Vec4 classfloatgetW()Retrieves the value of the fourth component of the givengraphene_vec4_t.floatgetX()Retrieves the value of the first component of the givengraphene_vec4_t.voidCreates agraphene_vec2_tthat contains the first two components of the givengraphene_vec4_t.voidCreates agraphene_vec3_tthat contains the first three components of the givengraphene_vec4_t.floatgetY()Retrieves the value of the second component of the givengraphene_vec4_t.floatgetZ()Retrieves the value of the third component of the givengraphene_vec4_t.init(float x, float y, float z, float w) Initializes agraphene_vec4_tusing the given values.initFromFloat(@org.jspecify.annotations.Nullable float @Nullable [] src) Initializes agraphene_vec4_twith the values inside the given array.initFromVec2(Vec2 src, float z, float w) Initializes agraphene_vec4_tusing the components of agraphene_vec2_tand the values ofzandw.initFromVec3(Vec3 src, float w) Initializes agraphene_vec4_tusing the components of agraphene_vec3_tand the value ofw.initFromVec4(Vec4 src) Initializes agraphene_vec4_tusing the components of anothergraphene_vec4_t.voidinterpolate(Vec4 v2, double factor, Vec4 res) Linearly interpolates this Vec4 andv2using the givenfactor.floatlength()Computes the length of the givengraphene_vec4_t.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_vec4_tvectors and checks whether their values are within the givenepsilon.voidNegates the givengraphene_vec4_t.voidNormalizes the givengraphene_vec4_t.static Vec4one()Retrieves a pointer to agraphene_vec4_twith all its components set 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 Vec4 the corresponding component of the second operandband places each result into the components ofres.voidStores the components of the givengraphene_vec4_tinto an array of floating point values.static Vec4wAxis()Retrieves a pointer to agraphene_vec4_twith its components set to (0, 0, 0, 1).voidwriteValue(@Nullable Simd4F value) Write a value in the fieldvalue.static Vec4xAxis()Retrieves a pointer to agraphene_vec4_twith its components set to (1, 0, 0, 0).static Vec4yAxis()Retrieves a pointer to agraphene_vec4_twith its components set to (0, 1, 0, 0).static Vec4zAxis()Retrieves a pointer to agraphene_vec4_twith its components set to (0, 0, 1, 0).static Vec4zero()Retrieves a pointer to agraphene_vec4_twith all its components set to 0.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Vec4
Create a Vec4 proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Vec4
Allocate a new Vec4.- Parameters:
arena- to control the memory allocation scope
-
Vec4
public Vec4()Allocate a new Vec4. The memory is allocated withArena.ofAuto(). -
Vec4
-
Vec4
Allocate a new Vec4 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_vec4_tstructure.The contents of the returned structure are undefined.
Use graphene_vec4_init() to initialize the vector.
- Returns:
- the newly allocated
graphene_vec4_tstructure. Use graphene_vec4_free() to free the resources allocated by this function. - Since:
- 1.0
-
one
Retrieves a pointer to agraphene_vec4_twith all its components set to 1.- Returns:
- a constant vector
- Since:
- 1.0
-
wAxis
Retrieves a pointer to agraphene_vec4_twith its components set to (0, 0, 0, 1).- Returns:
- a constant vector
- Since:
- 1.0
-
xAxis
Retrieves a pointer to agraphene_vec4_twith its components set to (1, 0, 0, 0).- Returns:
- a constant vector
- Since:
- 1.0
-
yAxis
Retrieves a pointer to agraphene_vec4_twith its components set to (0, 1, 0, 0).- Returns:
- a constant vector
- Since:
- 1.0
-
zAxis
Retrieves a pointer to agraphene_vec4_twith its components set to (0, 0, 1, 0).- Returns:
- a constant vector
- Since:
- 1.0
-
zero
Retrieves a pointer to agraphene_vec4_twith all its components set to 0.- Returns:
- a constant vector
- Since:
- 1.0
-
add
-
divide
-
dot
Computes the dot product of the two given vectors.- Parameters:
b- agraphene_vec4_t- Returns:
- the value of the dot product
- Since:
- 1.0
-
equal
Checks whether the two givengraphene_vec4_tare equal.- Parameters:
v2- agraphene_vec4_t- Returns:
trueif the two vectors are equal, and false otherwise- Since:
- 1.2
-
free
public void free()Frees the resources allocated by this Vec4- Since:
- 1.0
-
getW
public float getW()Retrieves the value of the fourth component of the givengraphene_vec4_t.- Returns:
- the value of the fourth component
- Since:
- 1.0
-
getX
public float getX()Retrieves the value of the first component of the givengraphene_vec4_t.- Returns:
- the value of the first component
- Since:
- 1.0
-
getXy
Creates agraphene_vec2_tthat contains the first two components of the givengraphene_vec4_t.- Parameters:
res- return location for agraphene_vec2_t- Since:
- 1.0
-
getXyz
Creates agraphene_vec3_tthat contains the first three components of the givengraphene_vec4_t.- Parameters:
res- return location for a graphene_vec3_t- Since:
- 1.0
-
getY
public float getY()Retrieves the value of the second component of the givengraphene_vec4_t.- Returns:
- the value of the second component
- Since:
- 1.0
-
getZ
public float getZ()Retrieves the value of the third component of the givengraphene_vec4_t.- Returns:
- the value of the third component
- Since:
- 1.0
-
init
Initializes agraphene_vec4_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 vectorw- the W field of the vector- Returns:
- a pointer to the initialized vector
- Since:
- 1.0
-
initFromFloat
Initializes agraphene_vec4_twith the values inside the given array.- Parameters:
src- an array of four floating point values- Returns:
- the initialized vector
- Throws:
IllegalArgumentException- when length ofsrcis less than 4- Since:
- 1.0
-
initFromVec2
Initializes agraphene_vec4_tusing the components of agraphene_vec2_tand the values ofzandw.- Parameters:
src- agraphene_vec2_tz- the value for the third component of this Vec4w- the value for the fourth component of this Vec4- Returns:
- the initialized vector
- Since:
- 1.0
-
initFromVec3
-
initFromVec4
-
interpolate
-
length
public float length()Computes the length of the givengraphene_vec4_t.- Returns:
- the length of the vector
- Since:
- 1.0
-
max
-
min
-
multiply
-
near
Compares the two givengraphene_vec4_tvectors and checks whether their values are within the givenepsilon.- Parameters:
v2- agraphene_vec4_tepsilon- the threshold between the two vectors- Returns:
trueif the two vectors are near each other- Since:
- 1.2
-
negate
Negates the givengraphene_vec4_t.- Parameters:
res- return location for the result vector- Since:
- 1.2
-
normalize
Normalizes the givengraphene_vec4_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
Stores the components of the givengraphene_vec4_tinto an array of floating point values.- Parameters:
dest- return location for an array of floating point values- Since:
- 1.0
-