115 res->
x = v->
x * inv_len;
116 res->
y = v->
y * inv_len;
223 res->
x = a->
x * b->
y - a->
y * b->
x;
250 res->
x = v->
x - normal->
x * d;
251 res->
y = v->
y - normal->
y * d;
270 res->
x = b->
x * scale;
271 res->
y = b->
y * scale;
303 result->
x = x * cs - y * sn;
304 result->
y = x * sn + y * cs;
319 result->
x = v->
x - normal->
x * d;
320 result->
y = v->
y - normal->
y * d;
347 res->
x = a->
x + t * (b->
x - a->
x);
348 res->
y = a->
y + t * (b->
y - a->
y);
360 res->
x = (b->
x == 0.0f) ? 0.0f : a->
x / b->
x;
361 res->
y = (b->
y == 0.0f) ? 0.0f : a->
y / b->
y;
438 const vm_float_t k = 1.0f - eta * eta * (1.0f - dot * dot);
445 res->
x = eta * incident->
x - factor * normal->
x;
446 res->
y = eta * incident->
y - factor * normal->
y;
460 res->
x = a->
x - projected.
x;
461 res->
y = a->
y - projected.
y;
475 offset.
x = v->
x - pivot->
x;
476 offset.
y = v->
y - pivot->
y;
495 if (dist <= max_delta || dist == 0.0f) {
500 res->
x = current->
x + dx * scale;
501 res->
y = current->
y + dy * scale;
514 if (len <= max_len || len == 0.0f) {
519 res->
x = v->
x * scale;
520 res->
y = v->
y * scale;
#define VECMAT_FMAX(a, b)
#define VECMAT_FMIN(a, b)
#define VECMAT_COPYSIGN(x, y)
vm_float_t vec2_dot(vector2 a, vector2 b)
Computes the dot product of two vectors.
vm_float_t vec2_length(vector2 v)
Computes the length (magnitude) of the vector.
void vec2_min_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Computes the component-wise minimum of vectors a and b, storing the result in res.
void vec2_move_toward_ptr(vector2 *res, const vector2 *current, const vector2 *target, const vm_float_t max_delta)
Moves current toward target by at most max_delta.
void vec2_clamp_ptr(vector2 *res, const vector2 *v, const vector2 *min, const vector2 *max)
Clamps vector v component-wise between min and max.
void vec2_perpendicular_ptr(vector2 *res, const vector2 *v)
Computes the perpendicular vector to v (90 degrees counterclockwise rotation), storing the result in ...
void vec2_normalize_ptr(vector2 *res, const vector2 *v)
Normalizes vector v to unit length, storing the result in res.
void vec2_sub_scalar_ptr(vector2 *res, const vector2 *v, const vm_float_t s)
Subtracts a scalar from each component.
void vec2_clamp_scalar_ptr(vector2 *res, const vector2 *v, const vm_float_t min, const vm_float_t max)
Clamps each component to the scalar range [min, max].
void vec2_add_scalar_ptr(vector2 *res, const vector2 *v, const vm_float_t s)
Adds a scalar to each component.
void vec2_lerp_ptr(vector2 *res, const vector2 *a, const vector2 *b, const vm_float_t t)
Linearly interpolates from a to b by t.
void vec2_round_ptr(vector2 *res, const vector2 *v)
Applies the round function to each component of vector v, storing the result in res.
void vec2_div_scalar_ptr(vector2 *res, const vector2 *v, const vm_float_t s)
Divides vector v by scalar s component-wise, storing the result in res.
void vec2_tangent_ptr(vector2 *res, const vector2 *v)
Computes a tangent vector perpendicular to the input (90 degrees clockwise).
void vec2_ceil_ptr(vector2 *res, const vector2 *v)
Applies the ceil function to each component of vector v, storing the result in res.
void vec2_scale_ptr(vector2 *res, const vector2 *v, const vm_float_t s)
Scales a vector by a scalar component-wise, storing the result in res.
void vec2_saturate_ptr(vector2 *res, const vector2 *v)
Clamps each component to the range [0, 1].
void vec2_abs_ptr(vector2 *res, const vector2 *v)
Computes the absolute values of the components of vector v, storing the result in res.
void vec2_to_vec3_ptr(vector3 *res, const vector2 *v, const vm_float_t z)
Converts a vector2 to a vector3 with the given z.
void vec2_add_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Adds vectors a and b component-wise, storing the result in res.
void vec2_reject_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Returns the component of a orthogonal to b.
void vec2_sign_ptr(vector2 *res, const vector2 *v)
Sets each component of res to the sign of the corresponding component in v (+1, -1).
void vec2_neg_ptr(vector2 *res, const vector2 *v)
Negates the components of vector v, storing the result in res.
void vec2_div_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Divides two vectors component-wise.
void vec2_mul_scalar_ptr(vector2 *res, const vector2 *v, const vm_float_t s)
Multiplies vector v by scalar s component-wise, storing the result in res.
void vec2_project_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Projects vector a onto vector b (scalar projection scaled by b).
void vec2_reflect_ptr(vector2 *res, const vector2 *v, const vector2 *normal)
Reflects vector v across the normal, storing the result in res.
void vec2_max_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Computes the component-wise maximum of vectors a and b, storing the result in res.
void vec2_sub_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Subtracts vector b from vector a component-wise, storing the result in res.
void vec2_slide_ptr(vector2 *result, const vector2 *v, const vector2 *normal)
Slides the input vector tangent to the normal (removes normal component).
void vec2_rotate_around_ptr(vector2 *res, const vector2 *v, const vector2 *pivot, const vm_float_t angle)
Rotates v around pivot by angle radians.
void vec2_limit_length_ptr(vector2 *res, const vector2 *v, const vm_float_t max_len)
Clamps the vector length to max_len.
void vec2_mul_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Multiplies vectors a and b component-wise, storing the result in res.
void vec2_refract_ptr(vector2 *res, const vector2 *incident, const vector2 *normal, const vm_float_t eta)
Computes the refraction of incident across normal with ratio eta.
void vec2_rotate_ptr(vector2 *result, const vector2 *v, const vm_float_t angle)
Rotates the input vector counterclockwise by the given angle (radians).
void vec2_fract_ptr(vector2 *res, const vector2 *v)
Returns the fractional part of each component.
void vec2_floor_ptr(vector2 *res, const vector2 *v)
Applies the floor function to each component of vector v, storing the result in res.
void vec2_cross_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Computes the 2D cross-product of a and b, storing the scalar value in res->x and 0 in res->y.