137 res->
x = a->
x < b->
x ? a->
x : b->
x;
138 res->
y = a->
y < b->
y ? a->
y : b->
y;
151 res->
x = a->
x > b->
x ? a->
x : b->
x;
152 res->
y = a->
y > b->
y ? a->
y : b->
y;
164 res->
x = v->
x > 0 ? 1 : v->
x < 0 ? -1 : 0;
165 res->
y = v->
y > 0 ? 1 : v->
y < 0 ? -1 : 0;
191 res->
x = a->
x * b->
y - a->
y * b->
x;
203 if (r != 0 && ((a < 0) != (b < 0))) {
216 if (r != 0 && ((a < 0) != (b < 0))) {
246 res->
x = v->
x < min->
x ? min->
x : (v->
x > max->
x ? max->
x : v->
x);
247 res->
y = v->
y < min->
y ? min->
y : (v->
y > max->
y ? max->
y : v->
y);
259 res->
x = (b->
x == 0) ? 0 : a->
x / b->
x;
260 res->
y = (b->
y == 0) ? 0 : a->
y / b->
y;
void vec2_normalize_ptr(vector2 *res, const vector2 *v)
Normalizes vector v to unit length, storing the result in res.
vm_float_t vec2i_length(vector2i v)
Computes the length (magnitude) of the vector.
void vec2i_perpendicular_ptr(vector2i *res, const vector2i *v)
Computes the perpendicular vector to v (90 degrees counterclockwise rotation), storing the result in ...
void vec2i_div_floor_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Component-wise floored division of a by b.
void vec2i_sub_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Subtracts vector b from vector a component-wise, storing the result in res.
void vec2i_div_scalar_ptr(vector2i *res, const vector2i *v, const vm_int_t s)
Divides vector v by scalar s component-wise (float division, truncated to int), storing the result in...
void vec2i_div_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Divides two vectors component-wise.
void vec2i_min_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Computes the component-wise minimum of vectors a and b, storing the result in res.
void vec2i_add_scalar_ptr(vector2i *res, const vector2i *v, const vm_int_t s)
Adds a scalar to each component.
void vec2i_neg_ptr(vector2i *res, const vector2i *v)
Negates the components of vector v, storing the result in res.
void vec2i_sub_scalar_ptr(vector2i *res, const vector2i *v, const vm_int_t s)
Subtracts a scalar from each component.
void vec2i_lerp_ptr(vector2i *res, const vector2i *a, const vector2i *b, const vm_float_t t)
Linearly interpolates from a to b by t.
void vec2i_mul_scalar_ptr(vector2i *res, const vector2i *v, const vm_int_t s)
Multiplies vector v by scalar s component-wise, storing the result in res.
void vec2i_mul_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Multiplies vectors a and b component-wise (Hadamard product), storing the result in res.
void vec2i_abs_ptr(vector2i *res, const vector2i *v)
Computes the absolute values of the components of vector v (using int abs), storing the result in res...
static vm_int_t vm_div_floor(const vm_int_t a, const vm_int_t b)
void vec2i_mod_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Component-wise floor modulo of a by b.
static vm_int_t vm_mod_floor(const vm_int_t a, const vm_int_t b)
void vec2i_normalize_ptr(vector2i *res, const vector2i *v)
Normalizes vector v to approximate unit length (float length computation, truncated to int),...
void vec2i_clamp_ptr(vector2i *res, const vector2i *v, const vector2i *min, const vector2i *max)
Clamps each component between min and max.
void vec2i_add_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Adds vectors a and b component-wise, storing the result in res.
void vec2i_normalize_to_vec2_ptr(vector2 *res, const vector2i *v)
Converts to a unit-length vector2.
void vec2i_wrap_ptr(vector2i *res, const vector2i *v, const vector2i *period)
Wraps each component of v into [0, period).
void vec2i_max_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Computes the component-wise maximum of vectors a and b, storing the result in res.
void vec2i_cross_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Computes the 2D cross-product of a and b, storing the scalar value in res->x and 0 in res->y.
void vec2i_to_vec3i_ptr(vector3i *res, const vector2i *v, const vm_int_t z)
Converts a vector4i to a vector3i by dropping w.
void vec2i_sign_ptr(vector2i *res, const vector2i *v)
Sets each component of res to the sign of the corresponding component in v (+1, -1,...