284 return a.
x * b.
x + a.
y * b.
y;
327 if (len_a == 0.0f || len_b == 0.0f)
return 0.0f;
342 if (v.
y == 0)
return 0.0f;
529 return a.
x * b.
y - a.
y * b.
x;
554 return dx * dx + dy * dy;
580 return ax > ay ? ax : ay;
591 return v.
x < v.
y ? v.
x : v.
y;
602 return v.
x > v.
y ? v.
x : v.
y;
624 return v.
x == 0 && v.
y == 0;
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_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_neg_ptr(vector2i *res, const vector2i *v)
Negates the components of vector v, 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_sub_scalar_ptr(vector2i *res, const vector2i *v, vm_int_t s)
Subtracts a scalar from each component.
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...
void vec2i_mod_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Component-wise floor modulo of a by 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_lerp_ptr(vector2i *res, const vector2i *a, const vector2i *b, vm_float_t t)
Linearly interpolates from a to b by t.
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_mul_scalar_ptr(vector2i *res, const vector2i *v, vm_int_t s)
Multiplies vector v by scalar s component-wise, storing the result in res.
void vec2i_add_scalar_ptr(vector2i *res, const vector2i *v, vm_int_t s)
Adds a scalar to each component.
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_to_vec3i_ptr(vector3i *res, const vector2i *v, vm_int_t z)
Converts a vector4i to a vector3i by dropping w.
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.
#define VECMAT_ATAN2(y, x)
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,...
void vec2i_div_scalar_ptr(vector2i *res, const vector2i *v, vm_int_t s)
Divides vector v by scalar s component-wise (float division, truncated to int), storing the result in...
bool vec2i_is_zero(const vector2i v)
Returns true if every component is zero.
vector2 vec2i_normalize_to_vec2(const vector2i v)
Converts to a unit-length vector2.
vector2i vec2i_x_scale(const vm_int_t x)
Returns a vector2i representing x-axis scaling (y = 1).
vector2i vec2i_one(void)
Returns a vector2i with both components set to 1.
vm_float_t vec2i_angle(const vector2i a, const vector2i b)
Computes the signed angle between two vectors (in radians, range [-PI, PI]) using atan2(cross,...
vector2i vec2i_min(const vector2i a, const vector2i b)
Returns the component-wise minimum of two vectors.
vm_int_t vec2i_cross_scalar(const vector2i a, const vector2i b)
Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).
vm_int_t vec2i_length_squared(const vector2i v)
Returns the squared Euclidean length.
vm_float_t vec2i_aspect_ratio(const vector2i v)
Computes the aspect ratio of the vector (x / y).
vm_int_t vec2i_sum(const vector2i v)
Returns the sum of all components.
vector2i vec2i_normalize(const vector2i v)
Normalizes the vector to approximate unit length (float length, truncated to int).
vm_int_t vec2i_dot(const vector2i a, const vector2i b)
Computes the dot product of two vectors.
vector2i vec2i_y_scale(const vm_int_t y)
Returns a vector2i representing y-axis scaling (x = 1).
vector2i vec2i_add(const vector2i a, const vector2i b)
Adds two vectors component-wise.
vm_int_t vec2i_distance_squared(const vector2i a, const vector2i b)
Returns the squared Euclidean distance between a and b.
vm_int_t vec2i_length_manhattan(const vector2i v)
Returns the Manhattan (L1) length.
vm_int_t vec2i_max_component(const vector2i v)
Returns the largest component.
vector2i vec2i_neg(const vector2i v)
Negates the vector (multiplies each component by -1).
vm_float_t vec2i_distance(const vector2i a, const vector2i b)
Computes the Euclidean distance between two vectors (treated as points).
vector2i vec2i_sub(const vector2i a, const vector2i b)
Subtracts the second vector from the first component-wise.
vector2i vec2i_sign(const vector2i v)
Returns the sign of each component (+1, -1, or 0).
vm_int_t vec2i_min_component(const vector2i v)
Returns the smallest component.
vector2i vec2i_lerp(const vector2i a, const vector2i b, const vm_float_t t)
Linearly interpolates from a to b by t.
vector2i vec2i_mul_scalar(const vector2i v, const vm_int_t s)
Multiplies a vector by a scalar component-wise.
vm_int_t vec2i_length_chebyshev(const vector2i v)
Returns the Chebyshev (L-inf) length.
vector2i vec2i_zero(void)
Returns a vector2i with both components set to 0.
vector2i vec2i_div(const vector2i a, const vector2i b)
Divides two vectors component-wise.
vector2i vec2i_add_scalar(const vector2i v, const vm_int_t s)
Adds a scalar to each component.
vector2i vec2i_splat(const vm_int_t s)
Returns a vector with every component set to s.
vector2i vec2i_max(const vector2i a, const vector2i b)
Returns the component-wise maximum of two vectors.
vector3i vec2i_to_vec3i(const vector2i v, const vm_int_t z)
Converts a vector2i to a vector3i using z.
vector2i vec2i_clamp(const vector2i v, const vector2i min, const vector2i max)
Clamps each component between min and max.
vector2i vec2i_wrap(const vector2i v, const vector2i period)
Wraps each component of v into [0, period).
vector2i vec2i_cross(const vector2i a, const vector2i b)
Computes the 2D cross-product as a vector.
vector2i vec2i_y_axis(const vm_int_t y)
Returns a vector2i along the y-axis (x = 0).
vector2i vec2i_sub_scalar(const vector2i v, const vm_int_t s)
Subtracts a scalar from each component.
vector2i vec2i_perpendicular(const vector2i v)
Returns the perpendicular vector (90 degrees counterclockwise).
vm_float_t vec2i_length(const vector2i v)
Computes the length (magnitude) of the vector.
vector2i vec2i_mod(const vector2i a, const vector2i b)
Component-wise floor modulo of a by b.
vector2i vec2i_x_axis(const vm_int_t x)
Returns a vector2i along the x-axis (y = 0).
vector2i vec2i_mul(const vector2i a, const vector2i b)
Multiplies two vectors component-wise (Hadamard product).
vector2i vec2i_div_scalar(const vector2i v, const vm_int_t s)
Divides a vector by a scalar component-wise (float division, truncated to int).
vector2i vec2i_abs(const vector2i v)
Returns the absolute values of each component.
vector2i vec2i_div_floor(const vector2i a, const vector2i b)
Component-wise floored division of a by b.