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

class Vec3
classmethod alloc() Vec3

Allocates a new Vec3 structure.

The contents of the returned structure are undefined.

Use init() to initialize the vector.

Added in version 1.0.

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 operand b, and places the results into the vector res.

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

free() None

Frees the resources allocated by v

Added in version 1.0.

get_x() float

Retrieves the first component of the given vector v.

Added in version 1.0.

get_xy() Vec2

Creates a Vec2 that contains the first and second components of the given Vec3.

Added in version 1.0.

get_xy0() Vec3

Creates a Vec3 that contains the first two components of the given Vec3, and the third component set to 0.

Added in version 1.0.

get_xyz0() Vec4

Converts a Vec3 in a Vec4 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 a Vec4 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 a Vec4 using w as the value of the fourth component of the resulting vector.

Added in version 1.0.

Parameters:

w – the value of the W component

get_y() float

Retrieves the second component of the given vector v.

Added in version 1.0.

get_z() float

Retrieves the third component of the given vector v.

Added in version 1.0.

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: Sequence[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 another Vec3.

Added in version 1.0.

Parameters:

src – a Vec3

interpolate(v2: Vec3, factor: float) Vec3

Linearly interpolates v1 and v2 using the given factor.

Added in version 1.10.

Parameters:
  • v2 – a Vec3

  • factor – the interpolation factor

length() float

Retrieves the length of the given vector v.

Added in version 1.0.

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 given epsilon.

Added in version 1.2.

Parameters:
  • v2 – a Vec3

  • epsilon – the threshold between the two vectors

negate() Vec3

Negates the given Vec3.

Added in version 1.2.

normalize() Vec3

Normalizes the given Vec3.

Added in version 1.0.

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 operand b and places each result into the components of res.

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.

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.

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.

z_axis() Vec3

Provides a constant pointer to a vector with three components with values set to (0, 0, 1).

Added in version 1.0.

zero() Vec3

Provides a constant pointer to a vector with three components, all sets to 0.

Added in version 1.0.

Fields

class Vec3
value