Vec3#
- class Vec3(*args, **kwargs)#
A structure capable of holding a vector with three dimensions: x, y, and z.
The contents of the Vec3
structure are private and should
never be accessed directly.
Constructors#
Methods#
- class Vec3
- add(b: Vec3) Vec3 #
Adds each component of the two given vectors.
Added in version 1.0.
- Parameters:
b – a
Vec3
- cross(b: Vec3) Vec3 #
Computes the cross product of the two given vectors.
Added in version 1.0.
- Parameters:
b – a
Vec3
- divide(b: Vec3) Vec3 #
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
Vec3
- dot(b: Vec3) float #
Computes the dot product of the two given vectors.
Added in version 1.0.
- Parameters:
b – a
Vec3
- equal(v2: Vec3) bool #
Checks whether the two given
Vec3
are equal.Added in version 1.2.
- Parameters:
v2 – a
Vec3
- get_xy() Vec2 #
Creates a
Vec2
that contains the first and second components of the givenVec3
.Added in version 1.0.
- get_xy0() Vec3 #
Creates a
Vec3
that contains the first two components of the givenVec3
, and the third component set to 0.Added in version 1.0.
- get_xyz0() Vec4 #
Converts a
Vec3
in aVec4
using 0.0 as the value for the fourth component of the resulting vector.Added in version 1.0.
- get_xyz1() Vec4 #
Converts a
Vec3
in aVec4
using 1.0 as the value for the fourth component of the resulting vector.Added in version 1.0.
- get_xyzw(w: float) Vec4 #
Converts a
Vec3
in aVec4
usingw
as the value of the fourth component of the resulting vector.Added in version 1.0.
- Parameters:
w – the value of the W component
- init(x: float, y: float, z: float) Vec3 #
Initializes a
Vec3
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
z – the Z field of the vector
- init_from_float(src: list[float]) Vec3 #
Initializes a
Vec3
with the values from an array.Added in version 1.0.
- Parameters:
src – an array of 3 floating point values
- init_from_vec3(src: Vec3) Vec3 #
Initializes a
Vec3
with the values of anotherVec3
.Added in version 1.0.
- Parameters:
src – a
Vec3
- interpolate(v2: Vec3, factor: float) Vec3 #
Linearly interpolates
v1
andv2
using the givenfactor
.Added in version 1.10.
- Parameters:
v2 – a
Vec3
factor – the interpolation factor
- max(b: Vec3) Vec3 #
Compares each component of the two given vectors and creates a vector that contains the maximum values.
Added in version 1.0.
- Parameters:
b – a
Vec3
- min(b: Vec3) Vec3 #
Compares each component of the two given vectors and creates a vector that contains the minimum values.
Added in version 1.0.
- Parameters:
b – a
Vec3
- multiply(b: Vec3) Vec3 #
Multiplies each component of the two given vectors.
Added in version 1.0.
- Parameters:
b – a
Vec3
- near(v2: Vec3, epsilon: float) bool #
Compares the two given
Vec3
vectors and checks whether their values are within the givenepsilon
.Added in version 1.2.
- Parameters:
v2 – a
Vec3
epsilon – the threshold between the two vectors
- classmethod one() Vec3 #
Provides a constant pointer to a vector with three components, all sets to 1.
Added in version 1.0.
- scale(factor: float) Vec3 #
Multiplies all components of the given vector with the given scalar
factor
.Added in version 1.2.
- Parameters:
factor – the scalar factor
- subtract(b: Vec3) Vec3 #
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
Vec3
- to_float() list[float] #
Copies the components of a
Vec3
into the given array.Added in version 1.0.
- classmethod x_axis() Vec3 #
Provides a constant pointer to a vector with three components with values set to (1, 0, 0).
Added in version 1.0.
- classmethod y_axis() Vec3 #
Provides a constant pointer to a vector with three components with values set to (0, 1, 0).
Added in version 1.0.
Fields#
- class Vec3
- value#