Graphene.Vec2¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
value |
r |
Methods¶
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Graphene.Vec2¶
A structure capable of holding a vector with two dimensions, x and y.
The contents of the
Graphene.Vec2
structure are private and should never be accessed directly.- classmethod alloc()¶
- Returns:
the newly allocated
Graphene.Vec2
structure. UseGraphene.Vec2.free
() to free the resources allocated by this function.- Return type:
Allocates a new
Graphene.Vec2
structure.The contents of the returned structure are undefined.
Use
Graphene.Vec2.init
() to initialize the vector.New in version 1.0.
- classmethod one()¶
- Returns:
the one vector
- Return type:
Retrieves a constant vector with (1, 1) components.
New in version 1.0.
- classmethod x_axis()¶
- Returns:
the X axis vector
- Return type:
Retrieves a constant vector with (1, 0) components.
New in version 1.0.
- classmethod y_axis()¶
- Returns:
the Y axis vector
- Return type:
Retrieves a constant vector with (0, 1) components.
New in version 1.0.
- classmethod zero()¶
- Returns:
the zero vector
- Return type:
Retrieves a constant vector with (0, 0) components.
New in version 1.0.
- add(b)¶
- Parameters:
b (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
return location for the result
- Return type:
res:
Graphene.Vec2
Adds each component of the two passed vectors and places each result into the components of res.
New in version 1.0.
- divide(b)¶
- Parameters:
b (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
return location for the result
- Return type:
res:
Graphene.Vec2
Divides each component of the first operand self by the corresponding component of the second operand b, and places the results into the vector res.
New in version 1.0.
- dot(b)¶
- Parameters:
b (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
the dot product of the vectors
- Return type:
Computes the dot product of the two given vectors.
New in version 1.0.
- equal(v2)¶
- Parameters:
v2 (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
true
if the two vectors are equal, and false otherwise- Return type:
Checks whether the two given
Graphene.Vec2
are equal.New in version 1.2.
- free()¶
Frees the resources allocated by self
New in version 1.0.
- get_x()¶
- Returns:
the value of the X component
- Return type:
Retrieves the X component of the
Graphene.Vec2
.New in version 1.0.
- get_y()¶
- Returns:
the value of the Y component
- Return type:
Retrieves the Y component of the
Graphene.Vec2
.New in version 1.0.
- init(x, y)¶
- Parameters:
- Returns:
the initialized vector
- Return type:
Initializes a
Graphene.Vec2
using the given values.This function can be called multiple times.
New in version 1.0.
- init_from_float(src)¶
- Parameters:
src ([
float
]) – an array of floating point values with at least two elements- Returns:
the initialized vector
- Return type:
Initializes self with the contents of the given array.
New in version 1.0.
- init_from_vec2(src)¶
- Parameters:
src (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
the initialized vector
- Return type:
Copies the contents of src into self.
New in version 1.0.
- interpolate(v2, factor)¶
- Parameters:
v2 (
Graphene.Vec2
) – aGraphene.Vec2
factor (
float
) – the interpolation factor
- Returns:
the interpolated vector
- Return type:
res:
Graphene.Vec2
Linearly interpolates self and v2 using the given factor.
New in version 1.10.
- length()¶
- Returns:
the length of the vector
- Return type:
Computes the length of the given vector.
New in version 1.0.
- max(b)¶
- Parameters:
b (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
the resulting vector
- Return type:
res:
Graphene.Vec2
Compares the two given vectors and places the maximum values of each component into res.
New in version 1.0.
- min(b)¶
- Parameters:
b (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
the resulting vector
- Return type:
res:
Graphene.Vec2
Compares the two given vectors and places the minimum values of each component into res.
New in version 1.0.
- multiply(b)¶
- Parameters:
b (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
return location for the result
- Return type:
res:
Graphene.Vec2
Multiplies each component of the two passed vectors and places each result into the components of res.
New in version 1.0.
- near(v2, epsilon)¶
- Parameters:
v2 (
Graphene.Vec2
) – aGraphene.Vec2
epsilon (
float
) – the threshold between the two vectors
- Returns:
true
if the two vectors are near each other- Return type:
Compares the two given
Graphene.Vec2
vectors and checks whether their values are within the given epsilon.New in version 1.2.
- negate()¶
- Returns:
return location for the result vector
- Return type:
res:
Graphene.Vec2
Negates the given
Graphene.Vec2
.New in version 1.2.
- normalize()¶
- Returns:
return location for the normalized vector
- Return type:
res:
Graphene.Vec2
Computes the normalized vector for the given vector self.
New in version 1.0.
- scale(factor)¶
- Parameters:
factor (
float
) – the scalar factor- Returns:
return location for the result vector
- Return type:
res:
Graphene.Vec2
Multiplies all components of the given vector with the given scalar factor.
New in version 1.2.
- subtract(b)¶
- Parameters:
b (
Graphene.Vec2
) – aGraphene.Vec2
- Returns:
return location for the result
- Return type:
res:
Graphene.Vec2
Subtracts from each component of the first operand self the corresponding component of the second operand b and places each result into the components of res.
New in version 1.0.