src/vector3i_ptr.c file

Functions

void vec3i_add_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Computes the component-wise sum of two vector3i.
void vec3i_sub_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Computes the component-wise difference of two vector3i (a minus b).
void vec3i_mul_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)
Scales a vector3i by an integer scalar.
void vec3i_div_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)
Scales a vector3i by the inverse of an integer scalar.
void vec3i_mul_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Computes the component-wise product (Hadamard) of two vector3i.
void vec3i_neg_ptr(vector3i* res, const vector3i* v)
Negates a vector3i (multiplies by -1).
void vec3i_abs_ptr(vector3i* res, const vector3i* v)
Computes the absolute value of each component of a vector3i.
void vec3i_normalize_ptr(vector3i* res, const vector3i* v)
Normalizes a vector3i to approximate unit length.
void vec3i_cross_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Computes the cross-product of two vector3i.
void vec3i_min_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Computes the component-wise minimum of two vector3i.
void vec3i_max_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Computes the component-wise maximum of two vector3i.
void vec3i_sign_ptr(vector3i* res, const vector3i* v)
Computes the sign of each component of a vector3i (-1, 0, or 1).
void vec3i_lerp_ptr(vector3i* res, const vector3i* a, const vector3i* b, const vm_float_t t)
Performs linear interpolation between two vector3i.
void vec3i_clamp_ptr(vector3i* res, const vector3i* v, const vector3i* min, const vector3i* max)
Clamps each component of a vector3i between corresponding min and max values.
static auto vm_div_floor3(const vm_int_t a, const vm_int_t b) -> vm_int_t
Floor division toward -inf; returns 0 if b == 0.
static auto vm_mod_floor3(const vm_int_t a, const vm_int_t b) -> vm_int_t
Floor modulo matching vm_div_floor3.
void vec3i_div_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Divides two vectors component-wise.
void vec3i_add_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)
Adds a scalar to each component.
void vec3i_sub_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)
Subtracts a scalar from each component.
void vec3i_mod_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Component-wise floor modulo of a by b.
void vec3i_div_floor_ptr(vector3i* res, const vector3i* a, const vector3i* b)
Component-wise floored division of a by b.
void vec3i_wrap_ptr(vector3i* res, const vector3i* v, const vector3i* period)
Wraps each component of v into [0, period).
void vec3i_from_vec2i_ptr(vector3i* res, const vector2i* v, const vm_int_t z)
Builds a vector3i from a vector2i and z.
void vec3i_xy_ptr(vector2i* res, const vector3i* v)
Returns the x and y components as a 2D vector.
void vec3i_normalize_to_vec3_ptr(vector3* res, const vector3i* v)
Converts to a unit-length vector3.

Function documentation

void vec3i_add_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Computes the component-wise sum of two vector3i.

Parameters
res Pointer to the vector that will store the result.
a Pointer to the first vector.
b Pointer to the second vector.

void vec3i_sub_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Computes the component-wise difference of two vector3i (a minus b).

Parameters
res Pointer to the vector that will store the result.
a Pointer to the first vector.
b Pointer to the second vector.

void vec3i_mul_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)

Scales a vector3i by an integer scalar.

Parameters
res Pointer to the vector that will store the result.
v Pointer to the input vector.
s The scalar multiplier.

void vec3i_div_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)

Scales a vector3i by the inverse of an integer scalar.

Parameters
res Pointer to the vector that will store the result.
v Pointer to the input vector.
s The scalar divisor.

If the scalar is zero, stores the zero vector.

void vec3i_mul_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Computes the component-wise product (Hadamard) of two vector3i.

Parameters
res Pointer to the vector that will store the result.
a Pointer to the first vector.
b Pointer to the second vector.

void vec3i_neg_ptr(vector3i* res, const vector3i* v)

Negates a vector3i (multiplies by -1).

Parameters
res Pointer to the vector that will store the result.
v Pointer to the input vector.

void vec3i_abs_ptr(vector3i* res, const vector3i* v)

Computes the absolute value of each component of a vector3i.

Parameters
res Pointer to the vector that will store the result.
v Pointer to the input vector.

void vec3i_normalize_ptr(vector3i* res, const vector3i* v)

Normalizes a vector3i to approximate unit length.

Parameters
res Pointer to the vector that will store the result.
v Pointer to the input vector.

If the vector length is zero, copies the input vector.

void vec3i_cross_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Computes the cross-product of two vector3i.

Parameters
res Pointer to the vector that will store the result.
a Pointer to the first vector.
b Pointer to the second vector.

void vec3i_min_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Computes the component-wise minimum of two vector3i.

Parameters
res Pointer to the vector that will store the result.
a Pointer to the first vector.
b Pointer to the second vector.

void vec3i_max_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Computes the component-wise maximum of two vector3i.

Parameters
res Pointer to the vector that will store the result.
a Pointer to the first vector.
b Pointer to the second vector.

void vec3i_sign_ptr(vector3i* res, const vector3i* v)

Computes the sign of each component of a vector3i (-1, 0, or 1).

Parameters
res Pointer to the vector that will store the result.
v Pointer to the input vector.

void vec3i_lerp_ptr(vector3i* res, const vector3i* a, const vector3i* b, const vm_float_t t)

Performs linear interpolation between two vector3i.

Parameters
res Pointer to the vector that will store the result.
a Pointer to the start vector.
b Pointer to the end vector.
t Interpolation factor (typically between 0.0 and 1.0).

void vec3i_clamp_ptr(vector3i* res, const vector3i* v, const vector3i* min, const vector3i* max)

Clamps each component of a vector3i between corresponding min and max values.

Parameters
res Pointer to the vector that will store the result.
v Pointer to the input vector.
min Pointer to the minimum bounds vector.
max Pointer to the maximum bounds vector.

static vm_int_t vm_div_floor3(const vm_int_t a, const vm_int_t b)

Floor division toward -inf; returns 0 if b == 0.

Parameters
a Dividend.
b Divisor.
Returns floor(a / b), or 0 if b is 0.

static vm_int_t vm_mod_floor3(const vm_int_t a, const vm_int_t b)

Floor modulo matching vm_div_floor3.

Parameters
a Dividend.
b Divisor.
Returns Floor modulus.

void vec3i_div_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Divides two vectors component-wise.

Parameters
res Output vector.
a First input vector.
b Second input vector.

void vec3i_add_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)

Adds a scalar to each component.

Parameters
res Output vector.
v Input vector.
s Scalar value.

void vec3i_sub_scalar_ptr(vector3i* res, const vector3i* v, const vm_int_t s)

Subtracts a scalar from each component.

Parameters
res Output vector.
v Input vector.
s Scalar value.

void vec3i_mod_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Component-wise floor modulo of a by b.

Parameters
res Output vector.
a First input vector.
b Second input vector.

void vec3i_div_floor_ptr(vector3i* res, const vector3i* a, const vector3i* b)

Component-wise floored division of a by b.

Parameters
res Output vector.
a First input vector.
b Second input vector.

void vec3i_wrap_ptr(vector3i* res, const vector3i* v, const vector3i* period)

Wraps each component of v into [0, period).

Parameters
res Output vector.
v Input vector.
period Wrap period per component.

void vec3i_from_vec2i_ptr(vector3i* res, const vector2i* v, const vm_int_t z)

Builds a vector3i from a vector2i and z.

Parameters
res Output vector.
v Input vector.
z Z component.

void vec3i_xy_ptr(vector2i* res, const vector3i* v)

Returns the x and y components as a 2D vector.

Parameters
res Output vector.
v Input vector.

void vec3i_normalize_to_vec3_ptr(vector3* res, const vector3i* v)

Converts to a unit-length vector3.

Parameters
res Output vector.
v Input vector.