Graphene.Vec2

Fields

Name

Type

Access

Description

value

Graphene.Simd4F

r

Methods

class

alloc ()

class

one ()

class

x_axis ()

class

y_axis ()

class

zero ()

add (b)

divide (b)

dot (b)

equal (v2)

free ()

get_x ()

get_y ()

init (x, y)

init_from_float (src)

init_from_vec2 (src)

interpolate (v2, factor)

length ()

max (b)

min (b)

multiply (b)

near (v2, epsilon)

negate ()

normalize ()

scale (factor)

subtract (b)

to_float ()

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. Use Graphene.Vec2.free() to free the resources allocated by this function.

Return type:

Graphene.Vec2

Allocates a new Graphene.Vec2 structure.

The contents of the returned structure are undefined.

Use Graphene.Vec2.init() to initialize the vector.

Added in version 1.0.

classmethod one()
Returns:

the one vector

Return type:

Graphene.Vec2

Retrieves a constant vector with (1, 1) components.

Added in version 1.0.

classmethod x_axis()
Returns:

the X axis vector

Return type:

Graphene.Vec2

Retrieves a constant vector with (1, 0) components.

Added in version 1.0.

classmethod y_axis()
Returns:

the Y axis vector

Return type:

Graphene.Vec2

Retrieves a constant vector with (0, 1) components.

Added in version 1.0.

classmethod zero()
Returns:

the zero vector

Return type:

Graphene.Vec2

Retrieves a constant vector with (0, 0) components.

Added in version 1.0.

add(b)
Parameters:

b (Graphene.Vec2) – a Graphene.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.

Added in version 1.0.

divide(b)
Parameters:

b (Graphene.Vec2) – a Graphene.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.

Added in version 1.0.

dot(b)
Parameters:

b (Graphene.Vec2) – a Graphene.Vec2

Returns:

the dot product of the vectors

Return type:

float

Computes the dot product of the two given vectors.

Added in version 1.0.

equal(v2)
Parameters:

v2 (Graphene.Vec2) – a Graphene.Vec2

Returns:

true if the two vectors are equal, and false otherwise

Return type:

bool

Checks whether the two given Graphene.Vec2 are equal.

Added in version 1.2.

free()

Frees the resources allocated by self

Added in version 1.0.

get_x()
Returns:

the value of the X component

Return type:

float

Retrieves the X component of the Graphene.Vec2.

Added in version 1.0.

get_y()
Returns:

the value of the Y component

Return type:

float

Retrieves the Y component of the Graphene.Vec2.

Added in version 1.0.

init(x, y)
Parameters:
  • x (float) – the X field of the vector

  • y (float) – the Y field of the vector

Returns:

the initialized vector

Return type:

Graphene.Vec2

Initializes a Graphene.Vec2 using the given values.

This function can be called multiple times.

Added 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:

Graphene.Vec2

Initializes self with the contents of the given array.

Added in version 1.0.

init_from_vec2(src)
Parameters:

src (Graphene.Vec2) – a Graphene.Vec2

Returns:

the initialized vector

Return type:

Graphene.Vec2

Copies the contents of src into self.

Added in version 1.0.

interpolate(v2, factor)
Parameters:
Returns:

the interpolated vector

Return type:

res: Graphene.Vec2

Linearly interpolates self and v2 using the given factor.

Added in version 1.10.

length()
Returns:

the length of the vector

Return type:

float

Computes the length of the given vector.

Added in version 1.0.

max(b)
Parameters:

b (Graphene.Vec2) – a Graphene.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.

Added in version 1.0.

min(b)
Parameters:

b (Graphene.Vec2) – a Graphene.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.

Added in version 1.0.

multiply(b)
Parameters:

b (Graphene.Vec2) – a Graphene.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.

Added in version 1.0.

near(v2, epsilon)
Parameters:
Returns:

true if the two vectors are near each other

Return type:

bool

Compares the two given Graphene.Vec2 vectors and checks whether their values are within the given epsilon.

Added in version 1.2.

negate()
Returns:

return location for the result vector

Return type:

res: Graphene.Vec2

Negates the given Graphene.Vec2.

Added 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.

Added 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.

Added in version 1.2.

subtract(b)
Parameters:

b (Graphene.Vec2) – a Graphene.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.

Added in version 1.0.

to_float()
Returns:

return location for an array of floating point values with at least 2 elements

Return type:

dest: [float]

Stores the components of self into an array.

Added in version 1.0.