Package ch.bailu.gtk.graphene
Class Vec2
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.graphene.Vec2
- All Implemented Interfaces:
PointerInterface
A structure capable of holding a vector with two dimensions, x and y.
The contents of the #graphene_vec2_t structure are private and should
never be accessed directly.
The contents of the #graphene_vec2_t structure are private and should
never be accessed directly.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds each component of the two passed vectors and places
each result into the components of @res.static Vec2
Allocates a new #graphene_vec2_t structure.void
Divides each component of the first operand @a by the corresponding
component of the second operand @b, and places the results into the
vector @res.float
Computes the dot product of the two given vectors.boolean
Checks whether the two given #graphene_vec2_t are equal.void
free()
Frees the resources allocated by @vstatic ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
float
getX()
Retrieves the X component of the #graphene_vec2_t.float
getY()
Retrieves the Y component of the #graphene_vec2_t.init
(float x, float y) Initializes a #graphene_vec2_t using the given values.initFromVec2
(Vec2 src) Copies the contents of @src into @v.void
interpolate
(Vec2 v2, double factor, Vec2 res) Linearly interpolates @v1 and @v2 using the given @factor.float
length()
Computes the length of the given vector.void
Compares the two given vectors and places the maximum
values of each component into @res.void
Compares the two given vectors and places the minimum
values of each component into @res.void
Multiplies each component of the two passed vectors and places
each result into the components of @res.boolean
Compares the two given #graphene_vec2_t vectors and checks
whether their values are within the given @epsilon.void
Negates the given #graphene_vec2_t.void
Computes the normalized vector for the given vector @v.static Vec2
one()
Retrieves a constant vector with (1, 1) components.void
Multiplies all components of the given vector with the given scalar @factor.void
Subtracts from each component of the first operand @a the
corresponding component of the second operand @b and places
each result into the components of @res.void
Stores the components of @v into an array.static Vec2
xAxis()
Retrieves a constant vector with (1, 0) components.static Vec2
yAxis()
Retrieves a constant vector with (0, 1) components.static Vec2
zero()
Retrieves a constant vector with (0, 0) components.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
Vec2
-
-
Method Details
-
getClassHandler
-
allocVec2
Allocates a new #graphene_vec2_t structure.
The contents of the returned structure are undefined.
Use graphene_vec2_init() to initialize the vector.- Returns:
- the newly allocated #graphene_vec2_t structure. Use graphene_vec2_free() to free the resources allocated by this function.
-
add
Adds each component of the two passed vectors and places
each result into the components of @res.- Parameters:
b
- a #graphene_vec2_tres
- return location for the result
-
divide
Divides each component of the first operand @a by the corresponding
component of the second operand @b, and places the results into the
vector @res.- Parameters:
b
- a #graphene_vec2_tres
- return location for the result
-
dot
Computes the dot product of the two given vectors.- Parameters:
b
- a #graphene_vec2_t- Returns:
- the dot product of the vectors
-
equal
Checks whether the two given #graphene_vec2_t are equal.- Parameters:
v2
- a #graphene_vec2_t- Returns:
- `true` if the two vectors are equal, and false otherwise
-
free
public void free()Frees the resources allocated by @v -
getX
public float getX()Retrieves the X component of the #graphene_vec2_t.- Returns:
- the value of the X component
-
getY
public float getY()Retrieves the Y component of the #graphene_vec2_t.- Returns:
- the value of the Y component
-
init
Initializes a #graphene_vec2_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 vector- Returns:
- the initialized vector
-
initFromVec2
Copies the contents of @src into @v.- Parameters:
src
- a #graphene_vec2_t- Returns:
- the initialized vector
-
interpolate
Linearly interpolates @v1 and @v2 using the given @factor.- Parameters:
v2
- a #graphene_vec2_tfactor
- the interpolation factorres
- the interpolated vector
-
length
public float length()Computes the length of the given vector.- Returns:
- the length of the vector
-
max
Compares the two given vectors and places the maximum
values of each component into @res.- Parameters:
b
- a #graphene_vec2_tres
- the resulting vector
-
min
Compares the two given vectors and places the minimum
values of each component into @res.- Parameters:
b
- a #graphene_vec2_tres
- the resulting vector
-
multiply
Multiplies each component of the two passed vectors and places
each result into the components of @res.- Parameters:
b
- a #graphene_vec2_tres
- return location for the result
-
near
Compares the two given #graphene_vec2_t vectors and checks
whether their values are within the given @epsilon.- Parameters:
v2
- a #graphene_vec2_tepsilon
- the threshold between the two vectors- Returns:
- `true` if the two vectors are near each other
-
negate
Negates the given #graphene_vec2_t.- Parameters:
res
- return location for the result vector
-
normalize
Computes the normalized vector for the given vector @v.- Parameters:
res
- return location for the normalized vector
-
scale
Multiplies all components of the given vector with the given scalar @factor.- Parameters:
factor
- the scalar factorres
- return location for the result vector
-
subtract
Subtracts from each component of the first operand @a the
corresponding component of the second operand @b and places
each result into the components of @res.- Parameters:
b
- a #graphene_vec2_tres
- return location for the result
-
toFloat
Stores the components of @v into an array.- Parameters:
dest
- return location for an array of floating point values with at least 2 elements
-
one
Retrieves a constant vector with (1, 1) components.- Returns:
- the one vector
-
xAxis
Retrieves a constant vector with (1, 0) components.- Returns:
- the X axis vector
-
yAxis
Retrieves a constant vector with (0, 1) components.- Returns:
- the Y axis vector
-
zero
Retrieves a constant vector with (0, 0) components.- Returns:
- the zero vector
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-