Vec4

class Vec4(*args, **kwargs)

A structure capable of holding a vector with four dimensions: x, y, z, and w.

The contents of the Vec4 structure are private and should never be accessed directly.

Constructors

class Vec4
classmethod alloc() Vec4

Allocates a new Vec4 structure.

The contents of the returned structure are undefined.

Use init() to initialize the vector.

Added in version 1.0.

Methods

class Vec4
add(b: Vec4) Vec4

Adds each component of the two given vectors.

Added in version 1.0.

Parameters:

b – a Vec4

divide(b: Vec4) Vec4

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 Vec4

dot(b: Vec4) float

Computes the dot product of the two given vectors.

Added in version 1.0.

Parameters:

b – a Vec4

equal(v2: Vec4) bool

Checks whether the two given Vec4 are equal.

Added in version 1.2.

Parameters:

v2 – a Vec4

free() None

Frees the resources allocated by v

Added in version 1.0.

get_w() float

Retrieves the value of the fourth component of the given Vec4.

Added in version 1.0.

get_x() float

Retrieves the value of the first component of the given Vec4.

Added in version 1.0.

get_xy() Vec2

Creates a Vec2 that contains the first two components of the given Vec4.

Added in version 1.0.

get_xyz() Vec3

Creates a Vec3 that contains the first three components of the given Vec4.

Added in version 1.0.

get_y() float

Retrieves the value of the second component of the given Vec4.

Added in version 1.0.

get_z() float

Retrieves the value of the third component of the given Vec4.

Added in version 1.0.

init(x: float, y: float, z: float, w: float) Vec4

Initializes a Vec4 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

  • w – the W field of the vector

init_from_float(src: Sequence[float]) Vec4

Initializes a Vec4 with the values inside the given array.

Added in version 1.0.

Parameters:

src – an array of four floating point values

init_from_vec2(src: Vec2, z: float, w: float) Vec4

Initializes a Vec4 using the components of a Vec2 and the values of z and w.

Added in version 1.0.

Parameters:
  • src – a Vec2

  • z – the value for the third component of v

  • w – the value for the fourth component of v

init_from_vec3(src: Vec3, w: float) Vec4

Initializes a Vec4 using the components of a Vec3 and the value of w.

Added in version 1.0.

Parameters:
  • src – a Vec3

  • w – the value for the fourth component of v

init_from_vec4(src: Vec4) Vec4

Initializes a Vec4 using the components of another Vec4.

Added in version 1.0.

Parameters:

src – a Vec4

interpolate(v2: Vec4, factor: float) Vec4

Linearly interpolates v1 and v2 using the given factor.

Added in version 1.10.

Parameters:
  • v2 – a Vec4

  • factor – the interpolation factor

length() float

Computes the length of the given Vec4.

Added in version 1.0.

max(b: Vec4) Vec4

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 Vec4

min(b: Vec4) Vec4

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 Vec4

multiply(b: Vec4) Vec4

Multiplies each component of the two given vectors.

Added in version 1.0.

Parameters:

b – a Vec4

near(v2: Vec4, epsilon: float) bool

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

Added in version 1.2.

Parameters:
  • v2 – a Vec4

  • epsilon – the threshold between the two vectors

negate() Vec4

Negates the given Vec4.

Added in version 1.2.

normalize() Vec4

Normalizes the given Vec4.

Added in version 1.0.

one() Vec4

Retrieves a pointer to a Vec4 with all its components set to 1.

Added in version 1.0.

scale(factor: float) Vec4

Multiplies all components of the given vector with the given scalar factor.

Added in version 1.2.

Parameters:

factor – the scalar factor

subtract(b: Vec4) Vec4

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 Vec4

to_float() list[float]

Stores the components of the given Vec4 into an array of floating point values.

Added in version 1.0.

w_axis() Vec4

Retrieves a pointer to a Vec4 with its components set to (0, 0, 0, 1).

Added in version 1.0.

x_axis() Vec4

Retrieves a pointer to a Vec4 with its components set to (1, 0, 0, 0).

Added in version 1.0.

y_axis() Vec4

Retrieves a pointer to a Vec4 with its components set to (0, 1, 0, 0).

Added in version 1.0.

z_axis() Vec4

Retrieves a pointer to a Vec4 with its components set to (0, 0, 1, 0).

Added in version 1.0.

zero() Vec4

Retrieves a pointer to a Vec4 with all its components set to 0.

Added in version 1.0.

Fields

class Vec4
value