Vec2#
- class Vec2(*args, **kwargs)#
A structure capable of holding a vector with two dimensions, x and y.
The contents of the Vec2
structure are private and should
never be accessed directly.
Constructors#
Methods#
- class Vec2
- add(b: Vec2) Vec2 #
Adds each component of the two passed vectors and places each result into the components of
res
.Added in version 1.0.
- Parameters:
b – a
Vec2
- divide(b: Vec2) Vec2 #
Divides each component of the first operand
a
by the corresponding component of the second operandb
, and places the results into the vectorres
.Added in version 1.0.
- Parameters:
b – a
Vec2
- dot(b: Vec2) float #
Computes the dot product of the two given vectors.
Added in version 1.0.
- Parameters:
b – a
Vec2
- equal(v2: Vec2) bool #
Checks whether the two given
Vec2
are equal.Added in version 1.2.
- Parameters:
v2 – a
Vec2
- init(x: float, y: float) Vec2 #
Initializes a
Vec2
using the given values.This function can be called multiple times.
Added in version 1.0.
- Parameters:
x – the X field of the vector
y – the Y field of the vector
- init_from_float(src: list[float]) Vec2 #
Initializes
v
with the contents of the given array.Added in version 1.0.
- Parameters:
src – an array of floating point values with at least two elements
- init_from_vec2(src: Vec2) Vec2 #
Copies the contents of
src
intov
.Added in version 1.0.
- Parameters:
src – a
Vec2
- interpolate(v2: Vec2, factor: float) Vec2 #
Linearly interpolates
v1
andv2
using the givenfactor
.Added in version 1.10.
- Parameters:
v2 – a
Vec2
factor – the interpolation factor
- max(b: Vec2) Vec2 #
Compares the two given vectors and places the maximum values of each component into
res
.Added in version 1.0.
- Parameters:
b – a
Vec2
- min(b: Vec2) Vec2 #
Compares the two given vectors and places the minimum values of each component into
res
.Added in version 1.0.
- Parameters:
b – a
Vec2
- multiply(b: Vec2) Vec2 #
Multiplies each component of the two passed vectors and places each result into the components of
res
.Added in version 1.0.
- Parameters:
b – a
Vec2
- near(v2: Vec2, epsilon: float) bool #
Compares the two given
Vec2
vectors and checks whether their values are within the givenepsilon
.Added in version 1.2.
- Parameters:
v2 – a
Vec2
epsilon – the threshold between the two vectors
- scale(factor: float) Vec2 #
Multiplies all components of the given vector with the given scalar
factor
.Added in version 1.2.
- Parameters:
factor – the scalar factor
- subtract(b: Vec2) Vec2 #
Subtracts from each component of the first operand
a
the corresponding component of the second operandb
and places each result into the components ofres
.Added in version 1.0.
- Parameters:
b – a
Vec2
- classmethod x_axis() Vec2 #
Retrieves a constant vector with (1, 0) components.
Added in version 1.0.
Fields#
- class Vec2
- value#