13#define VECMAT_VERSION_MAJOR 0
14#define VECMAT_VERSION_MINOR 2
15#define VECMAT_VERSION_PATCH 3
17#define VECMAT_STR_HELPER(x) #x
18#define VECMAT_STR(x) VECMAT_STR_HELPER(x)
19#define VECMAT_VERSION VECMAT_STR(VECMAT_VERSION_MAJOR) "." \
20 VECMAT_STR(VECMAT_VERSION_MINOR) "." VECMAT_STR(VECMAT_VERSION_PATCH)
24 #ifdef VEC_BUILD_SHARED
25 #define VEC_API __declspec(dllexport)
38#define M_E 2.71828182845904523536
39#define M_LOG2E 1.44269504088896340736
40#define M_LOG10E 0.434294481903251827651
41#define M_LN2 0.693147180559945309417
42#define M_LN10 2.30258509299404568402
43#define M_PI 3.14159265358979323846
44#define M_PI_2 1.57079632679489661923
45#define M_PI_4 0.785398163397448309616
46#define M_1_PI 0.318309886183790671538
47#define M_2_PI 0.636619772367581343076
48#define M_2_SQRTPI 1.12837916709551257390
49#define M_SQRT2 1.41421356237309504880
50#define M_SQRT1_2 0.707106781186547524401
58#define VECMAT_FLT_MAX __FLT_MAX__
59#define VECMAT_DBL_MAX __DBL_MAX__
61#define VECMAT_FLT_MIN __FLT_MIN__
62#define VECMAT_DBL_MIN __DBL_MIN__
64#define VECMAT_VEC2_SIZE 2
65#define VECMAT_VEC3_SIZE 3
66#define VECMAT_VEC4_SIZE 4
68#define VECMAT_MAT2_SIZE 4
69#define VECMAT_MAT3_SIZE 9
70#define VECMAT_MAT4_SIZE 16
72#define VECMAT_QUAT_SIZE 4
78#if defined(VECMAT_USE_F64)
102#if defined(VECMAT_USE_INT8)
104#define VEC_INT_MAX INT8_MAX
105#define VEC_INT_MIN INT8_MIN
106#elif defined(VECMAT_USE_INT16)
108#define VEC_INT_MAX INT16_MAX
109#define VEC_INT_MIN INT16_MIN
110#elif defined(VECMAT_USE_INT32)
112#define VEC_INT_MAX INT32_MAX
113#define VEC_INT_MIN INT32_MIN
116#define VEC_INT_MAX INT32_MAX
117#define VEC_INT_MIN INT32_MIN
373#define VECMAT_EPS_F32 1e-6f
374#define VECMAT_EPS_F64 1e-12
377#define VECMAT_EPSILON VECMAT_EPS_F64
379#define VECMAT_EPSILON VECMAT_EPS_F32
390#define FLOAT_EQ(a, b, eps) (fabsf((a) - (b)) < (eps))
400#define DOUBLE_EQ(a, b, eps) (fabs((a) - (b)) < (eps))
403#define VECMAT_EQ(a, b, eps) DOUBLE_EQ((a), (b), (eps))
405#define VECMAT_EQ(a, b, eps) FLOAT_EQ((a), (b), (eps))
413#define VECMAT_FABS(x) fabs((x))
414#define VECMAT_SQRT(x) sqrt((x))
415#define VECMAT_SIN(x) sin((x))
416#define VECMAT_COS(x) cos((x))
417#define VECMAT_TAN(x) tan((x))
418#define VECMAT_ASIN(x) asin((x))
419#define VECMAT_ACOS(x) acos((x))
420#define VECMAT_ATAN(x) atan((x))
421#define VECMAT_ATAN2(y, x) atan2((y), (x))
422#define VECMAT_FMIN(a, b) fmin((a), (b))
423#define VECMAT_FMAX(a, b) fmax((a), (b))
424#define VECMAT_FLOOR(x) floor((x))
425#define VECMAT_CEIL(x) ceil((x))
426#define VECMAT_ROUND(x) round((x))
427#define VECMAT_POW(x, y) pow((x), (y))
428#define VECMAT_COPYSIGN(x, y) copysign((x), (y))
430#define VECMAT_FABS(x) fabsf((x))
431#define VECMAT_SQRT(x) sqrtf((x))
432#define VECMAT_SIN(x) sinf((x))
433#define VECMAT_COS(x) cosf((x))
434#define VECMAT_TAN(x) tanf((x))
435#define VECMAT_ASIN(x) asinf((x))
436#define VECMAT_ACOS(x) acosf((x))
437#define VECMAT_ATAN(x) atanf((x))
438#define VECMAT_ATAN2(y, x) atan2f((y), (x))
439#define VECMAT_FMIN(a, b) fminf((a), (b))
440#define VECMAT_FMAX(a, b) fmaxf((a), (b))
441#define VECMAT_FLOOR(x) floorf((x))
442#define VECMAT_CEIL(x) ceilf((x))
443#define VECMAT_ROUND(x) roundf((x))
444#define VECMAT_POW(x, y) powf((x), (y))
445#define VECMAT_COPYSIGN(x, y) copysignf((x), (y))
vm_float_t v[VECMAT_MAT2_SIZE]
vm_int_t v[VECMAT_MAT2_SIZE]
vm_float_t v[VECMAT_MAT3_SIZE]
vm_int_t v[VECMAT_MAT3_SIZE]
vm_float_t v[VECMAT_MAT4_SIZE]
vm_int_t v[VECMAT_MAT4_SIZE]
vm_float_t v[VECMAT_QUAT_SIZE]
vm_float_t v[VECMAT_VEC2_SIZE]
vm_int_t v[VECMAT_VEC2_SIZE]
vm_float_t v[VECMAT_VEC3_SIZE]
vm_int_t v[VECMAT_VEC3_SIZE]
vm_float_t v[VECMAT_VEC4_SIZE]
vm_int_t v[VECMAT_VEC4_SIZE]
void vec2i_perpendicular_ptr(vector2i *res, const vector2i *v)
Computes the perpendicular vector to v (90 degrees counterclockwise rotation), storing the result in ...
vector3i vec3i_mod(vector3i a, vector3i b)
Component-wise floor modulo of a by b.
matrix3 mat3_mul(matrix3 a, matrix3 b)
Multiplies two 3x3 matrices.
void vec3_add_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Adds a scalar to each component.
vm_int_t vec3i_max_component(vector3i v)
Returns the largest component.
vm_float_t vec2_distance_squared(vector2 a, vector2 b)
Returns the squared Euclidean distance between a and b.
void mat4_mul_vec3_ptr(vector3 *res, const matrix4 *m, const vector3 *v, vm_float_t w)
vector3 vec3_limit_length(vector3 v, vm_float_t max_len)
Clamps the vector length to max_len.
void vec3i_cross_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Computes the cross-product of two vector3i.
vector4 vec4_z_axis(vm_float_t z)
Returns a vector4 along the z-axis.
static const vm_float_t VM_DEG_TO_RAD
vector4i vec4i_div_floor(vector4i a, vector4i b)
Component-wise floored division of a by b.
void vec3_mul_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise multiplication of two vectors.
void vec2_rotate_ptr(vector2 *result, const vector2 *v, vm_float_t angle)
Rotates the input vector counterclockwise by the given angle (radians).
void vec2i_assign(vector2i *dest, const vector2i *src)
Copies src into dest.
void vec3_abs_ptr(vector3 *res, const vector3 *v)
Computes the absolute value per component of a vector3.
void mat2i_transpose_ptr(matrix2i *res, const matrix2i *m)
Computes the transpose of the input integer 2x2 matrix and stores in res.
vm_int_t vec4i_distance_squared(vector4i a, vector4i b)
Returns the squared Euclidean distance between a and b.
vm_float_t vec2_distance(vector2 a, vector2 b)
Computes the Euclidean distance between two vectors (treated as points).
void quat_mul_ptr(quaternion *res, const quaternion *a, const quaternion *b)
vector4 vec4_add(vector4 a, vector4 b)
Component-wise addition of two vectors.
void mat2i_mul_ptr(matrix2i *res, const matrix2i *a, const matrix2i *b)
Multiplies two integer 2x2 matrices (a * b) using explicit loops and stores the result in res.
vm_float_t quadratic_ease_out(vm_float_t f)
matrix2i mat2i_identity(void)
Constructs the 2x2 integer identity matrix.
vector2i vec2i_mul(vector2i a, vector2i b)
Multiplies two vectors component-wise (Hadamard product).
void vec3i_wrap_ptr(vector3i *res, const vector3i *v, const vector3i *period)
Wraps each component of v into [0, period).
matrix4 mat4_transpose(matrix4 m)
Computes the transpose of a 4x4 matrix.
void vec4i_div_scalar_ptr(vector4i *res, const vector4i *v, vm_int_t s)
Divides the components of a vector4i by a scalar and stores the result in res.
void mat4_ortho_ptr(matrix4 *res, vm_float_t left, vm_float_t right, vm_float_t bottom, vm_float_t top, vm_float_t near, vm_float_t far)
Sets the matrix to an orthographic projection matrix.
void mat4_rotation_x_ptr(matrix4 *res, vm_float_t degrees)
Builds a 4x4 rotation matrix around the X axis (degrees).
matrix4 mat4_rotation(vector3 axis, vm_float_t angle)
Constructs a rotation matrix around the given axis by the specified angle (in radians).
void vec4i_lerp_ptr(vector4i *res, const vector4i *a, const vector4i *b, vm_float_t t)
Linearly interpolates between two vector4i using an interpolation factor t (clamped to [0,...
vm_float_t vec4_dot(vector4 a, vector4 b)
Computes the dot product of two vector4.
vm_float_t quadratic_ease_in(vm_float_t f)
vm_float_t vec4_length_squared(vector4 v)
Returns the squared Euclidean length.
vector4 vec4_floor(vector4 v)
Applies the floor per component to a vector4.
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.
vector2 vec2_move_toward(vector2 current, vector2 target, vm_float_t max_delta)
Moves current toward target by at most max_delta.
void vec4_to_vec3_ptr(vector3 *res, const vector4 *v)
Copies the x, y, z components from a vector4 to a vector3.
vm_float_t vec2i_angle(vector2i a, vector2i b)
Computes the signed angle between two vectors (in radians, range [-PI, PI]) using atan2(cross,...
vector2 vec2_limit_length(vector2 v, vm_float_t max_len)
Clamps the vector length to max_len.
matrix4 mat4_look_at(vector3 position, vector3 target, vector3 up)
Constructs a view matrix from eye position, target, and up vector.
vector2i vec2i_min(vector2i a, vector2i b)
Returns the component-wise minimum of two vectors.
vector4 vec4_clamp(vector4 v, vector4 min, vector4 max)
Clamps a vector4 between min and max per component.
void vec2i_div_floor_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Component-wise floored division of a by b.
matrix3 quat_to_mat3(quaternion q)
Converts a quaternion to a 3x3 rotation matrix.
vector4 vec4_slide(vector4 v, vector4 normal)
Removes the component of v along normal.
void vec2i_add_assign(vector2i *dest, const vector2i *src)
Adds src to dest in place.
void mat2i_mul_vec2i_ptr(vector2i *res, const matrix2i *m, const vector2i *v)
Multiplies a 2x2 integer matrix by a vector2i.
void vec3_min_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise minimum of two vectors.
vm_float_t vec3_min_component(vector3 v)
Returns the smallest component.
vector3i vec3i_div(vector3i a, vector3i b)
Divides two vectors component-wise.
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.
static const float VM_DEG_TO_RAD_F32
bool vec3_eq(vector3 a, vector3 b)
Returns true if two vectors are equal within VECMAT_EPSILON.
vm_int_t vec3i_length_squared(vector3i v)
Returns the squared Euclidean length.
void vec4i_add_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Adds the components of two vector4i and stores the result in res.
void mat4i_mul_vec3i_ptr(vector3i *res, const matrix4i *m, const vector3i *v, vm_int_t w)
Transforms a vector3i by a 4x4 integer matrix using homogeneous w.
vector2 vec2_fract(vector2 v)
Returns the fractional part of each component.
vm_float_t vec3_length_manhattan(vector3 v)
Returns the Manhattan (L1) length.
void vec3i_mod_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Component-wise floor modulo of a by b.
void mat2_scale_ptr(matrix2 *res, const vector2 *s)
Builds a 2x2 scaling matrix from a vector2.
void mat3_identity_ptr(matrix3 *res)
Initializes the 3x3 matrix to identity (diagonal 1.0, others 0.0).
vector3i vec3i_div_scalar(vector3i v, vm_int_t s)
Component-wise division of vector by scalar.
void mat4i_mul_ptr(matrix4i *res, const matrix4i *a, const matrix4i *b)
Performs matrix multiplication of two 4x4 matrices and stores the result.
vm_int_t vec4i_length_chebyshev(vector4i v)
Returns the Chebyshev (L-inf) length.
void vec3_sign_ptr(vector3 *res, const vector3 *v)
Component-wise sign of a vector.
vm_cpu_features_t vm_cpu_compiled_features(void)
void vec4i_to_vec3i_ptr(vector3i *res, const vector4i *v)
Copies the x, y, z components of a vector4i and stores the result in a vector3i.
void mat4_scale_ptr(matrix4 *res, const vector3 *v)
Sets the matrix to a scaling matrix using the provided scale vector.
void mat3_mul_vec2_ptr(vector2 *res, const matrix3 *m, const vector2 *v)
Applies a 3x3 affine transform to a vector2.
void mat4_mul_vec4_ptr(vector4 *res, const matrix4 *m, const vector4 *v)
vector2 vec2i_normalize_to_vec2(vector2i v)
Converts to a unit-length vector2.
vector2 vec2_sub_scalar(vector2 v, vm_float_t s)
Subtracts a scalar from each component.
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 vec3_clamp_ptr(vector3 *res, const vector3 *v, const vector3 *min, const vector3 *max)
Clamp vector components between min and max.
vector3 vec3_z_axis(vm_float_t z)
Returns a vector3 along the z-axis.
vector3i vec4i_to_vec3i(vector4i v)
Converts a vector4i to a vector3i (discards the w component).
matrix4 mat4_perspective_infinite(vm_float_t fov_y, vm_float_t aspect, vm_float_t n)
Constructs an infinite far-plane perspective projection matrix.
void quat_rotate_vec3_ptr(vector3 *res, const quaternion *q, const vector3 *v)
Rotates a vector3 by a quaternion.
void mat3_translate_ptr(matrix3 *res, const vector2 *t)
Builds a 3x3 2D translation matrix.
vm_int_t vec4i_sum(vector4i v)
Returns the sum of all components.
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.
matrix4i mat4i_inverse(matrix4i m)
Computes the inverse of a 4x4 integer matrix.
vector2i vec2i_div_floor(vector2i a, vector2i b)
Component-wise floored division of a by b.
void vec3_scale_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Scales the vector by a scalar.
void vec4i_div_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Divides two vectors component-wise.
vector3 vec3_mul(vector3 a, vector3 b)
Component-wise multiplication of two vectors.
vector3i vec3i_normalize(vector3i v)
Normalizes a vector3i to unit length.
void vec2_perpendicular_ptr(vector2 *res, const vector2 *v)
Computes the perpendicular vector to v (90 degrees counterclockwise rotation), storing the result in ...
bool vec4i_is_zero(vector4i v)
Returns true if every component is zero.
void vec4_sub_scalar_ptr(vector4 *res, const vector4 *v, vm_float_t s)
vm_float_t vec3i_distance(vector3i a, vector3i b)
Computes the Euclidean distance between two vector3i.
void mat3_from_mat4_ptr(matrix3 *res, const matrix4 *m)
Copies the upper-left 3x3 of a matrix4.
void vec4i_mod_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Component-wise floor modulo of a by b.
void mat2i_inverse_ptr(matrix2i *res, const matrix2i *m)
Computes the inverse of the input integer 2x2 matrix and stores in res.
vector2 vec2_x_axis(vm_float_t x)
Returns a vector2 along the x-axis (y = 0.0f).
vector3i vec3i_splat(vm_int_t s)
Returns a vector with every component set to s.
void vec3_div_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Divides two vectors component-wise.
vector4 vec4_one(void)
Returns a vector4 with all components set to 1.0f.
vector2i vec2i_mul_scalar(vector2i v, vm_int_t s)
Multiplies a vector by a scalar component-wise.
void vec4_div_ptr(vector4 *res, const vector4 *a, const vector4 *b)
vm_float_t vec3_length_squared(vector3 v)
Returns the squared Euclidean length.
vector2 vec2_refract(vector2 incident, vector2 normal, vm_float_t eta)
Computes the refraction of incident across normal with ratio eta.
void vec3_saturate_ptr(vector3 *res, const vector3 *v)
Clamps each component to the range [0, 1].
static const double VM_RAD_TO_DEG_F64
vector2 vec2_div(vector2 a, vector2 b)
Divides two vectors component-wise.
vector3 vec3_mul_scalar(vector3 v, vm_float_t s)
Component-wise multiplication of vector by scalar.
void mat4_extract_scale_ptr(vector3 *res, const matrix4 *m)
Extracts the scale vector from a matrix4.
void vec2_move_toward_ptr(vector2 *res, const vector2 *current, const vector2 *target, vm_float_t max_delta)
Moves current toward target by at most max_delta.
void vec3i_add_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Computes the component-wise sum of two vector3i.
void vec4i_sub_scalar_ptr(vector4i *res, const vector4i *v, vm_int_t s)
Subtracts a scalar from each component.
void vec3_sub_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Subtracts a scalar from each component.
vector2i vec2i_clamp(vector2i v, vector2i min, vector2i max)
Clamps each component between min and max.
void vec3i_sign_ptr(vector3i *res, const vector3i *v)
Computes the sign of each component of a vector3i (-1, 0, or 1).
vector3 vec3_x_scale(vm_float_t x)
Returns a vector3 for scaling along the x-axis.
matrix2 mat2_inverse(matrix2 m)
Computes the inverse of a 2x2 matrix.
void mat2_mul_ptr(matrix2 *res, const matrix2 *a, const matrix2 *b)
Multiplies two 2x2 matrices (a * b) in column-major / column-vector convention.
vm_float_t bounce_ease_out(vm_float_t f)
void vec4i_abs_ptr(vector4i *res, const vector4i *v)
Computes the absolute value of each component of a vector4i and stores the result in res.
void mat3i_mul_ptr(matrix3i *res, const matrix3i *a, const matrix3i *b)
Multiplies two 3x3 integer matrices (standard matrix multiplication).
vector4 vec4_div(vector4 a, vector4 b)
Divides two vectors component-wise.
vector3 vec3_one(void)
Returns a vector3 with all components set to 1.0f.
vector3i vec3i_add_scalar(vector3i v, vm_int_t s)
Adds a scalar to each component.
bool vec3_is_zero(vector3 v)
Returns true if every component is zero.
vector3 vec3_y_scale(vm_float_t y)
Returns a vector3 for scaling along the y-axis.
void vec2_normalize_ptr(vector2 *res, const vector2 *v)
Normalizes vector v to unit length, storing the result in res.
vector3 vec3_lerp(vector3 a, vector3 b, vm_float_t t)
Linearly interpolates between two vector3.
void vec3i_normalize_ptr(vector3i *res, const vector3i *v)
Normalizes a vector3i to approximate unit length.
vector4 mat4_mul_vec4(matrix4 m, vector4 v)
Multiplies a 4x4 matrix by a vector4.
vector4i vec4i_x_axis(vm_int_t x)
Returns a vector4i along the x-axis.
vector2i vec2i_sub_scalar(vector2i v, vm_int_t s)
Subtracts a scalar from each component.
vm_float_t mat4_determinant(matrix4 m)
Calculates the determinant of the given 4x4 matrix.
vector3 vec3_add_scalar(vector3 v, vm_float_t s)
Adds a scalar to each component.
vm_float_t vec2i_distance(vector2i a, vector2i b)
Computes the Euclidean distance between two vectors (treated as points).
vm_float_t vec3_max_component(vector3 v)
Returns the largest component.
void vec3i_max_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Computes the component-wise maximum of two vector3i.
vm_float_t circular_ease_out(vm_float_t f)
vector4 vec4_x_axis(vm_float_t x)
Returns a vector4 along the x-axis.
vector2i vec2i_one(void)
Returns a vector2i with both components set to 1.
bool vec3_near(vector3 a, vector3 b, vm_float_t eps)
Returns true if a and b are within eps of each other.
void vec2_clamp_scalar_ptr(vector2 *res, const vector2 *v, vm_float_t min, vm_float_t max)
Clamps each component to the scalar range [min, max].
matrix4 mat4_perspective_fov(vm_float_t fov, vm_float_t w, vm_float_t h, vm_float_t n, vm_float_t f)
Constructs a perspective projection matrix using FOV, width, and height.
void quat_to_axis_angle_ptr(vector3 *axis, vm_float_t *degrees, const quaternion *q)
Converts a quaternion to an axis and an angle in degrees.
vm_int_t vec2i_length_manhattan(vector2i v)
Returns the Manhattan (L1) length.
vector4 vec4_div_scalar(vector4 v, vm_float_t s)
Component-wise division of vector by scalar.
vector2 vec2_clamp(vector2 v, vector2 min, vector2 max)
Clamps vector v component-wise between min and max.
vm_int_t vec4i_length_manhattan(vector4i v)
Returns the Manhattan (L1) length.
vector3 vec3_move_toward(vector3 current, vector3 target, vm_float_t max_delta)
Moves current toward target by at most max_delta.
vector3i vec3i_y_axis(vm_int_t y)
Returns a vector3i along the y-axis.
matrix2 mat2_identity(void)
Constructs the 2x2 identity matrix.
matrix4i mat4i_transpose(matrix4i m)
Computes the transpose of a 4x4 integer matrix.
vector2 vec3_xy(vector3 v)
Returns the x and y components as a 2D vector.
vector3i vec3i_one(void)
Returns a vector3i with all components set to 1.
vector3 vec3_ceil(vector3 v)
Applies ceil per component to a vector3.
void mat3_inverse_ptr(matrix3 *res, const matrix3 *m)
Computes the inverse of the input 3x3 matrix using the adjugate method and stores in res.
vector2i vec2i(vm_int_t x, vm_int_t y)
Constructs a vector2i from x and y.
void mat4_look_at_ptr(matrix4 *res, const vector3 *position, const vector3 *target, const vector3 *up)
Constructs a view matrix for a camera positioned at the given location, looking towards a target,...
bool vec2i_eq(vector2i a, vector2i b)
Returns true if two vectors are exactly equal.
quaternion quat_from_euler(vector3 euler)
Constructs a quaternion from Euler angles (in radians, XYZ order).
vm_float_t vec3_signed_angle(vector3 a, vector3 b, vector3 axis)
Returns the signed angle from a to b around axis.
void vec3i_div_floor_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Component-wise floored division of a by b.
vector2i vec2i_x_axis(vm_int_t x)
Returns a vector2i along the x-axis (y = 0).
vector4i vec4i_min(vector4i a, vector4i b)
Computes the component-wise minimum of two vector4i.
void vec3_from_vec2_ptr(vector3 *res, const vector2 *v, vm_float_t z)
Builds a higher-dimension vector from a vector2.
matrix4 mat4_perspective(vm_float_t fov, vm_float_t aspect, vm_float_t near, vm_float_t far)
Constructs a perspective projection matrix.
void vec3_move_toward_ptr(vector3 *res, const vector3 *current, const vector3 *target, vm_float_t max_delta)
Moves current toward target by at most max_delta.
void vec4i_clamp_ptr(vector4i *res, const vector4i *v, const vector4i *min, const vector4i *max)
Clamps the components of a vector4i to the range [min, max] and stores the result in res.
vector4i vec4i_lerp(vector4i a, vector4i b, vm_float_t t)
Linearly interpolates between two vector4i.
vector4i vec4i_div_scalar(vector4i v, vm_int_t s)
Component-wise division of vector by scalar.
vm_float_t cubic_ease_out(vm_float_t f)
matrix3 mat3_identity(void)
Constructs the 3x3 identity matrix.
vector3i vec3i_div_floor(vector3i a, vector3i b)
Component-wise floored division of a by b.
vm_float_t elastic_oscillation(vm_float_t f, vm_float_t exp_mult, vm_float_t sin_mult, vm_float_t sin_offset, vm_float_t period)
vector4 vec4_mul(vector4 a, vector4 b)
Component-wise multiplication of two vectors.
vector2 vec2_add_scalar(vector2 v, vm_float_t s)
Adds a scalar to each component.
void quat_from_mat4_ptr(quaternion *res, const matrix4 *m)
Builds a quaternion from the rotation of a 4x4 matrix.
vector2 vec2_abs(vector2 v)
Returns the absolute values of each component.
void vec2i_div_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Divides two vectors component-wise.
bool vec4_near(vector4 a, vector4 b, vm_float_t eps)
Returns true if a and b are within eps of each other.
vm_float_t quadratic_ease_in_out(vm_float_t f)
vector3i vec3i_from(const vector3 *v)
Converts a vector3 to a vector3i by truncation.
vector3 vec3_from_vec2(vector2 v, vm_float_t z)
Builds a vector3 from a vector2 and z.
static const vm_float_t VM_RAD_TO_DEG
void mat2_transpose_ptr(matrix2 *res, const matrix2 *m)
Computes the transpose of the input 2x2 matrix and stores in res.
vector3i vec3i_wrap(vector3i v, vector3i period)
Wraps each component of v into [0, period).
void vec2_limit_length_ptr(vector2 *res, const vector2 *v, vm_float_t max_len)
Clamps the vector length to max_len.
vm_float_t vec3_dot(vector3 a, vector3 b)
Computes the dot product of two vector3.
vm_float_t vec2_length_squared(vector2 v)
Returns the squared Euclidean length.
vector4 vec4_zero(void)
Returns a zero-initialized vector4.
vector3 quat_to_euler(quaternion q)
Converts a quaternion to Euler angles in degrees (XYZ).
void vec3_xy_ptr(vector2 *res, const vector3 *v)
Returns the x and y components as a 2D vector.
void mat3_mul_ptr(matrix3 *res, const matrix3 *a, const matrix3 *b)
Multiplies two 3x3 matrices (a * b) in column-major / column-vector convention.
bool vec2_is_zero(vector2 v)
Returns true if every component is zero.
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.
matrix2 mat2_mul(matrix2 a, matrix2 b)
Multiplies two 2x2 matrices (a * b).
vector4 vec4_fract(vector4 v)
Returns the fractional part of each component.
matrix3 mat3_rotation_x(vm_float_t degrees)
Builds a 3x3 rotation matrix around the X axis (degrees).
vector4 vec4_y_axis(vm_float_t y)
Returns a vector4 along the y-axis.
matrix3 mat3_inverse(matrix3 m)
Computes the inverse of a 3x3 matrix.
void vec4i_mul_scalar_ptr(vector4i *res, const vector4i *v, vm_int_t s)
Multiplies the components of a vector4i by a scalar and stores the result in res.
quaternion quat_normalize(quaternion q)
Normalizes a quaternion.
void vec2_mul_scalar_ptr(vector2 *res, const vector2 *v, vm_float_t s)
Multiplies vector v by scalar s component-wise, storing the result in res.
void mat2i_identity_ptr(matrix2i *res)
Initializes the integer 2x2 matrix to identity (diagonal 1, others 0).
bool vec4i_eq(vector4i a, vector4i b)
Returns true if two vectors are exactly equal.
quaternion mat4_extract_rotation(matrix4 m)
Extracts the rotation quaternion from a matrix4.
void quat_from_mat3_ptr(quaternion *res, const matrix3 *m)
Builds a quaternion from a 3x3 rotation matrix.
bool mat3_eq(matrix3 a, matrix3 b)
Returns true if two matrices are equal within VECMAT_EPSILON.
vector3 quat_to_axis_angle(quaternion q, vm_float_t *degrees)
Converts a quaternion to an axis and an angle in degrees.
vector3 vec3_reflect(vector3 incident, vector3 normal)
Reflects an incident vector over normal.
vm_float_t quintic_ease_in_out(vm_float_t f)
vector3i vec2i_to_vec3i(vector2i v, vm_int_t z)
Converts a vector2i to a vector3i using z.
void vec4_min_ptr(vector4 *res, const vector4 *a, const vector4 *b)
vector3 vec3_from(const vector3i *v)
Converts a vector3i to a vector3.
vm_float_t vec3_length(vector3 v)
Computes the length (magnitude) of a vector3.
vector2i vec3i_xy(vector3i v)
Returns the x and y components as a 2D vector.
vector3 vec3_fract(vector3 v)
Returns the fractional part of each component.
vector2i vec2i_from_floored(const vector2 *v)
Converts a vector2 to a vector2i by flooring each component.
vector2 vec2_normalize(vector2 v)
Normalizes the vector to unit length.
void mat4_rotation_ptr(matrix4 *res, const vector3 *axis, vm_float_t angle)
Sets the matrix to a rotation matrix around the specified axis by the given angle.
bool mat3i_eq(matrix3i a, matrix3i b)
Returns true if two matrices are exactly equal.
void vec4_floor_ptr(vector4 *res, const vector4 *v)
vector4i vec4i_z_axis(vm_int_t z)
Returns a vector4i along the z-axis.
vm_float_t poly_ease_in(vm_float_t f, vm_float_t n)
vector4i vec4i_y_scale(vm_int_t y)
Returns a vector4i for scaling along the y-axis.
void vec2_round_ptr(vector2 *res, const vector2 *v)
Applies the round function to each component of vector v, storing the result in res.
vector4i vec4i_add_scalar(vector4i v, vm_int_t s)
Adds a scalar to each component.
vm_float_t elastic_ease_in_out(vm_float_t f)
vector3 vec3_z_scale(vm_float_t z)
Returns a vector3 for scaling along the z-axis.
void quat_nlerp_ptr(quaternion *res, const quaternion *a, const quaternion *b, vm_float_t t)
Normalized-linearly interpolates from a to b by t.
vm_int_t vec3i_length_manhattan(vector3i v)
Returns the Manhattan (L1) length.
vector2 vec2_mul(vector2 a, vector2 b)
Multiplies two vectors component-wise (Hadamard product).
vector4 vec4_normalize(vector4 v)
Normalizes a vector4 to unit length.
vector4i vec4i_x_scale(vm_int_t x)
Returns a vector4i for scaling along the x-axis.
vector2 vec2_ceil(vector2 v)
Applies ceil to each component.
vector3i vec3i_z_scale(vm_int_t z)
Returns a vector3i for scaling along the z-axis.
vm_int_t vec3i_min_component(vector3i v)
Returns the smallest component.
matrix2i mat2i_transpose(matrix2i m)
Computes the transpose of a 2x2 integer matrix.
vm_float_t vec3i_angle(vector3i a, vector3i b)
Computes the angle between two non-zero vector3i in radians.
void vec4i_max_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Computes the component-wise maximum of two vector4i and stores the result in res.
void vec3_clamp_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t min, vm_float_t max)
Clamps each component to the scalar range [min, max].
vector3 vec3_max(vector3 a, vector3 b)
Computes the component-wise maximum of two vector3.
void mat3_mul_vec3_ptr(vector3 *res, const matrix3 *m, const vector3 *v)
Multiplies a 3x3 matrix by a vector3.
matrix4 mat4_rotation_z(vm_float_t degrees)
Builds a 4x4 rotation matrix around the Z axis (degrees).
static const double VM_DEG_TO_RAD_F64
void mat4_extract_rotation_ptr(quaternion *res, const matrix4 *m)
Extracts the rotation quaternion from a matrix4.
void vec4_sign_ptr(vector4 *res, const vector4 *v)
void vec4_lerp_ptr(vector4 *res, const vector4 *a, const vector4 *b, vm_float_t t)
vector3 vec3_zero(void)
Returns a zero-initialized vector3.
void vec2_tangent_ptr(vector2 *res, const vector2 *v)
Computes a tangent vector perpendicular to the input (90 degrees clockwise).
vector2i vec2i_splat(vm_int_t s)
Returns a vector with every component set to s.
void vec3i_abs_ptr(vector3i *res, const vector3i *v)
Computes the absolute value of each component of a vector3i.
vm_float_t vec2_aspect_ratio(vector2 v)
Computes the aspect ratio of the vector (x / y).
vector4i vec4i_mul(vector4i a, vector4i b)
Component-wise multiplication of two vectors.
void vec2i_neg_ptr(vector2i *res, const vector2i *v)
Negates the components of vector v, storing the result in res.
vm_int_t vec2i_distance_squared(vector2i a, vector2i b)
Returns the squared Euclidean distance between a and b.
bool vec2_eq(vector2 a, vector2 b)
Returns true if two vectors are equal within VECMAT_EPSILON.
vector4i vec4i_mod(vector4i a, vector4i b)
Component-wise floor modulo of a by b.
void mat3i_inverse_ptr(matrix3i *res, const matrix3i *m)
Computes the inverse of a 3x3 integer matrix using adjugate over determinant.
vector2 vec2_lerp(vector2 a, vector2 b, vm_float_t t)
Linearly interpolates from a to b by t.
void vec2_div_scalar_ptr(vector2 *res, const vector2 *v, vm_float_t s)
Divides vector v by scalar s component-wise, storing the result in res.
vector4i vec4i_splat(vm_int_t s)
Returns a vector with every component set to s.
matrix3 mat3_rotation_y(vm_float_t degrees)
Builds a 3x3 rotation matrix around the Y axis (degrees).
vector2i vec2i_wrap(vector2i v, vector2i period)
Wraps each component of v into [0, period).
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 vec3_rotate_axis_ptr(vector3 *res, const vector3 *v, const vector3 *axis, vm_float_t angle)
Rotates v around axis by angle radians.
matrix3 mat3_rotation_z(vm_float_t degrees)
Constructs the 3x3 rotation matrix around the Z-axis.
vector4 vec4_saturate(vector4 v)
Clamps each component to the range [0, 1].
vector2 vec2_reject(vector2 a, vector2 b)
Returns the component of a orthogonal to b.
vector2 vec2_project(vector2 a, vector2 b)
Projects the first vector onto the second.
vm_float_t vec3_sum(vector3 v)
Returns the sum of all components.
uint32_t vm_cpu_features_t
vm_float_t circular_ease_in_out(vm_float_t f)
vector4i vec4i_one(void)
Returns a vector4i with all components set to 1.
vector4i vec4i_w_scale(vm_int_t w)
Returns a vector4i for scaling along the w-axis.
vector2 vec2_scale(vector2 v, vm_float_t s)
Scales a vector by a scalar component-wise.
vector2 vec2_sign(vector2 v)
Returns the sign of each component (+1.0f, -1.0f, or 0.0f).
void vec2_scale_ptr(vector2 *res, const vector2 *v, vm_float_t s)
Scales a vector by a scalar component-wise, storing the result in res.
vector2 vec2(vm_float_t x, vm_float_t y)
Constructs a vector2 from x and y.
void vec3_add_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise addition of two vectors.
vector3 vec3_project(vector3 a, vector3 b)
Projects a onto b.
vector2 vec2_max(vector2 a, vector2 b)
Returns the component-wise maximum of two vectors.
void vec2_saturate_ptr(vector2 *res, const vector2 *v)
Clamps each component to the range [0, 1].
void vec3i_div_scalar_ptr(vector3i *res, const vector3i *v, vm_int_t s)
Scales a vector3i by the inverse of an integer scalar.
void vec2_assign(vector2 *dest, const vector2 *src)
Copies src into dest.
vector3 vec3i_normalize_to_vec3(vector3i v)
Converts to a unit-length vector3.
vector3 vec3_floor(vector3 v)
Applies the floor per component to a vector3.
void vec2_abs_ptr(vector2 *res, const vector2 *v)
Computes the absolute values of the components of vector v, storing the result in res.
vector3i vec3i_clamp(vector3i v, vector3i min, vector3i max)
Clamps a vector3i between min and max per component.
bool quat_eq(quaternion a, quaternion b)
Returns true if two quaternions are equal within VECMAT_EPSILON.
vm_float_t cubic_ease_in(vm_float_t f)
void vec4i_normalize_ptr(vector4i *res, const vector4i *v)
Normalizes a vector4i by dividing its components by the vector length and stores the result in res.
void vec3_sub_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise subtraction of two vectors.
vector2i vec2i_add(vector2i a, vector2i b)
Adds two vectors component-wise.
vector3i vec3i_lerp(vector3i a, vector3i b, vm_float_t t)
Linearly interpolates between two vector3i.
void vec3_add_assign(vector3 *dest, const vector3 *src)
Adds src to dest in place.
vm_int_t mat3i_determinant(matrix3i m)
Computes the determinant of a 3x3 integer matrix.
void vec3i_from_vec2i_ptr(vector3i *res, const vector2i *v, vm_int_t z)
Builds a vector3i from a vector2i and z.
vector3 vec3_clamp(vector3 v, vector3 min, vector3 max)
Clamps a vector3 between min and max per component.
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.
vm_float_t quartic_ease_in_out(vm_float_t f)
void vec2i_assign_xy(vector2i *dest, vm_int_t x, vm_int_t y)
Assigns x and y to dest.
quaternion quat_from_mat4(matrix4 m)
Builds a quaternion from the rotation of a 4x4 matrix.
void vec3_round_ptr(vector3 *res, const vector3 *v)
Component-wise round of a vector.
vector2 vec2_x_scale(vm_float_t x)
Returns a vector2 representing x-axis scaling (y = 1.0f).
void vec3_lerp_ptr(vector3 *res, const vector3 *a, const vector3 *b, vm_float_t t)
Linear interpolation between two vectors.
vector2i vec2i_max(vector2i a, vector2i b)
Returns the component-wise maximum of two vectors.
void vec4_homogenize_ptr(vector4 *res, const vector4 *v)
matrix3 mat3_transpose(matrix3 m)
Computes the transpose of a 3x3 matrix.
matrix3 mat3_translate(vector2 t)
Builds a 3x3 2D translation matrix.
matrix4i mat4i_identity(void)
Constructs the 4x4 identity matrix.
quaternion quat_identity(void)
Constructs the identity quaternion.
vector2i vec2i_abs(vector2i v)
Returns the absolute values of each component.
void quat_to_euler_ptr(vector3 *res, const quaternion *q)
Converts a quaternion to Euler angles in degrees (XYZ).
void quat_slerp_ptr(quaternion *res, const quaternion *a, const quaternion *b, vm_float_t t)
Spherical-linearly interpolates from a to b by t.
void vec4_add_ptr(vector4 *res, const vector4 *a, const vector4 *b)
vm_float_t sine_ease_out(vm_float_t f)
vm_float_t vec4i_length(vector4i v)
Computes the length (magnitude) of a vector4i.
matrix4 mat4_identity(void)
Constructs the 4x4 identity matrix.
vector2 vec2_tangent(vector2 v)
Returns the tangent vector perpendicular to the input (90 degrees clockwise).
void vec4_max_ptr(vector4 *res, const vector4 *a, const vector4 *b)
void vec2_add_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Adds vectors a and b component-wise, storing the result in res.
vector3 vec3_abs(vector3 v)
Computes the absolute value per component of a vector3.
void vec2i_sub_scalar_ptr(vector2i *res, const vector2i *v, vm_int_t s)
Subtracts a scalar from each component.
matrix4 mat4_mul(matrix4 a, matrix4 b)
Multiplies two 4x4 matrices (a * b).
vector2i vec2i_add_scalar(vector2i v, vm_int_t s)
Adds a scalar to each component.
vector4 vec4_y_scale(vm_float_t y)
Returns a vector4 for scaling along the y-axis.
vector4 vec4_sign(vector4 v)
Computes the sign per component of a vector4 (-1, 0, or 1).
vector2 vec2_from(const vector2i *v)
Converts a vector2i to a vector2.
void vec3i_mul_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Computes the component-wise product (Hadamard) of two vector3i.
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...
vector2i vec2i_y_axis(vm_int_t y)
Returns a vector2i along the y-axis (x = 0).
bool vec4_is_zero(vector4 v)
Returns true if every component is zero.
vector3i mat4i_mul_vec3i(matrix4i m, vector3i v, vm_int_t w)
Transforms a vector3i by a 4x4 integer matrix using homogeneous w.
void mat3_scale_ptr(matrix3 *res, const vector2 *s)
Builds a 3x3 2D scaling matrix.
void mat2_rotation_z_ptr(matrix2 *res, vm_float_t degrees)
Sets res to a 2x2 rotation matrix for rotation around the Z-axis.
matrix3i mat3i_mul(matrix3i a, matrix3i b)
Multiplies two 3x3 integer matrices.
vm_int_t vec2i_length_squared(vector2i v)
Returns the squared Euclidean length.
vm_float_t vec2_length_chebyshev(vector2 v)
Returns the Chebyshev (L-inf) length.
void mat4_inverse_ptr(matrix4 *res, const matrix4 *m)
Computes the inverse of a 4x4 matrix.
vm_float_t elastic_ease_in(vm_float_t f)
vm_float_t vec3_distance_squared(vector3 a, vector3 b)
Returns the squared Euclidean distance between a and b.
vector2 vec2_from_angle(vm_float_t angle)
Returns the unit vector at the given angle in radians.
vector4i vec4i_sub(vector4i a, vector4i b)
Component-wise subtraction of two vectors.
vm_float_t elastic_ease_out(vm_float_t f)
void mat2_identity_ptr(matrix2 *res)
Initializes the 2x2 matrix to identity (diagonal 1.0, others 0.0).
quaternion quat_conjugate(quaternion q)
Returns the conjugate of a quaternion.
vector4i vec4i_normalize(vector4i v)
Normalizes a vector4i to unit length.
void vec3i_xy_ptr(vector2i *res, const vector3i *v)
Returns the x and y components as a 2D vector.
void vec3_max_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise maximum of two vectors.
void vec2i_mod_ptr(vector2i *res, const vector2i *a, const vector2i *b)
Component-wise floor modulo of a by b.
vector2 vec2_min(vector2 a, vector2 b)
Returns the component-wise minimum of two vectors.
void vec4_fract_ptr(vector4 *res, const vector4 *v)
vector3 vec3_clamp_scalar(vector3 v, vm_float_t min, vm_float_t max)
Clamps each component to the scalar range [min, max].
void vec4_add_scalar_ptr(vector4 *res, const vector4 *v, vm_float_t s)
vector2i vec2i_perpendicular(vector2i v)
Returns the perpendicular vector (90 degrees counterclockwise).
matrix4 mat4_rotation_x(vm_float_t degrees)
Builds a 4x4 rotation matrix around the X axis (degrees).
vector3 mat3_mul_vec3(matrix3 m, vector3 v)
Multiplies a 3x3 matrix by a vector3.
matrix2 mat2_from_mat3(matrix3 m)
Copies the upper-left 2x2 of a matrix3.
vector3 quat_rotate_vec3(quaternion q, vector3 v)
Rotates a vector3 by a quaternion.
vector2 vec2_slide(vector2 v, vector2 normal)
Slides the input vector tangent to the normal (removes normal component).
void vec3i_add_scalar_ptr(vector3i *res, const vector3i *v, vm_int_t s)
Adds a scalar to each component.
void vec4_abs_ptr(vector4 *res, const vector4 *v)
void vec2_reject_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Returns the component of a orthogonal to b.
vector2 vec2_rotate(vector2 v, vm_float_t angle)
Rotates the input vector counterclockwise by the given angle (radians).
vm_float_t vec3_distance(vector3 a, vector3 b)
Computes the Euclidean distance between two vector3.
vector2 vec2_splat(vm_float_t s)
Returns a vector with every component set to s.
void vec4_saturate_ptr(vector4 *res, const vector4 *v)
void mat3i_mul_vec2i_ptr(vector2i *res, const matrix3i *m, const vector2i *v)
Applies a 3x3 integer affine transform to a vector2i.
vector3 vec3_x_axis(vm_float_t x)
Returns a vector3 along the x-axis.
vector3 vec3_div(vector3 a, vector3 b)
Divides two vectors component-wise.
vector4 vec4_reject(vector4 a, vector4 b)
Returns the component of a orthogonal to b.
void vec3_fract_ptr(vector3 *res, const vector3 *v)
Returns the fractional part of each component.
vector2 vec2_add(vector2 a, vector2 b)
Adds two vectors component-wise.
vm_float_t rad_to_deg(vm_float_t radians)
Converts radians to degrees.
vm_float_t vec3_length_chebyshev(vector3 v)
Returns the Chebyshev (L-inf) length.
void mat4_perspective_fov_ptr(matrix4 *res, vm_float_t fov, vm_float_t w, vm_float_t h, vm_float_t n, vm_float_t f)
Sets the matrix to a perspective projection matrix.
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).
vector4 vec4_clamp_scalar(vector4 v, vm_float_t min, vm_float_t max)
Clamps each component to the scalar range [min, max].
vm_float_t vec4_length(vector4 v)
Computes the length (magnitude) of a vector4.
vector4i vec4i_mul_scalar(vector4i v, vm_int_t s)
Component-wise multiplication of vector by scalar.
void vec3i_assign(vector3i *dest, const vector3i *src)
Copies src into dest.
vector3 vec3_splat(vm_float_t s)
Returns a vector with every component set to s.
vector2i vec2i_mod(vector2i a, vector2i b)
Component-wise floor modulo of a by b.
vector2i vec2i_x_scale(vm_int_t x)
Returns a vector2i representing x-axis scaling (y = 1).
vector2 vec2_y_scale(vm_float_t y)
Returns a vector2 representing y-axis scaling (x = 1.0f).
vector3i vec3i_from_floored(const vector3 *v)
Converts a vector3 to a vector3i by flooring each component.
void vec2_neg_ptr(vector2 *res, const vector2 *v)
Negates the components of vector v, storing the result in res.
vector2i vec2i_y_scale(vm_int_t y)
Returns a vector2i representing y-axis scaling (x = 1).
vector2 vec2_mul_scalar(vector2 v, vm_float_t s)
Multiplies a vector by a scalar component-wise.
void quat_to_mat3_ptr(matrix3 *res, const quaternion *q)
Converts a quaternion to a 3x3 rotation matrix.
vector3 vec3(vm_float_t x, vm_float_t y, vm_float_t z)
Constructs a vector3 from x, y, and z.
void vec2_div_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Divides two vectors component-wise.
void vec2_rotate_around_ptr(vector2 *res, const vector2 *v, const vector2 *pivot, vm_float_t angle)
Rotates v around pivot by angle radians.
void vec4_div_scalar_ptr(vector4 *res, const vector4 *v, vm_float_t s)
void vec3_slide_ptr(vector3 *res, const vector3 *v, const vector3 *normal)
Removes the component of v along normal.
vm_int_t vec4i_length_squared(vector4i v)
Returns the squared Euclidean length.
void vec4_mul_scalar_ptr(vector4 *res, const vector4 *v, vm_float_t s)
void vec2i_normalize_ptr(vector2i *res, const vector2i *v)
Normalizes vector v to approximate unit length (float length computation, truncated to int),...
void vec3i_add_assign(vector3i *dest, const vector3i *src)
Adds src to dest in place.
void vec3i_div_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Divides two vectors component-wise.
matrix4 mat4_inverse(matrix4 m)
Computes the inverse of a 4x4 matrix.
vector2 vec2_one(void)
Returns a vector2 with both components set to 1.0f.
void vec3i_mul_scalar_ptr(vector3i *res, const vector3i *v, vm_int_t s)
Scales a vector3i by an integer scalar.
matrix4 mat4_rotation_y(vm_float_t degrees)
Builds a 4x4 rotation matrix around the Y axis (degrees).
vm_int_t vec2i_sum(vector2i v)
Returns the sum of all components.
void mat4_perspective_infinite_ptr(matrix4 *res, vm_float_t fov_y, vm_float_t aspect, vm_float_t n)
Sets the matrix to an infinite perspective projection matrix.
void vec2i_lerp_ptr(vector2i *res, const vector2i *a, const vector2i *b, vm_float_t t)
Linearly interpolates from a to b by t.
bool vec2i_is_zero(vector2i v)
Returns true if every component is zero.
vm_int_t vec3i_length_chebyshev(vector3i v)
Returns the Chebyshev (L-inf) length.
vm_int_t vec2i_dot(vector2i a, vector2i b)
Computes the dot product of two vectors.
vector4i mat4i_mul_vec4i(matrix4i m, vector4i v)
Multiplies a 4x4 integer matrix by a vector4i.
void vec3_cross_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Compute cross-product of two vectors.
void vec2i_clamp_ptr(vector2i *res, const vector2i *v, const vector2i *min, const vector2i *max)
Clamps each component between min and max.
vector4 vec4_ceil(vector4 v)
Applies ceil per component to a vector4.
void vec2_project_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Projects vector a onto vector b (scalar projection scaled by b).
vm_float_t quat_dot(quaternion a, quaternion b)
Returns the dot product of two quaternions.
void quat_from_axis_angle_ptr(quaternion *res, const vector3 *axis, vm_float_t degrees)
Builds a quaternion from an axis and an angle in degrees.
static const float VM_RAD_TO_DEG_F32
vector3 vec3_min(vector3 a, vector3 b)
Computes the component-wise minimum of two vector3.
void vec3i_assign_xyz(vector3i *dest, vm_int_t x, vm_int_t y, vm_int_t z)
Assigns x, y, and z to dest.
void vec2_reflect_ptr(vector2 *res, const vector2 *v, const vector2 *normal)
Reflects vector v across the normal, storing the result in res.
vm_float_t vec2_min_component(vector2 v)
Returns the smallest component.
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 vec4i_mul_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Multiplies the components of two vector4i and stores the result in res.
vector3 vec3_y_axis(vm_float_t y)
Returns a vector3 along the y-axis.
vector2i vec2i_div(vector2i a, vector2i b)
Divides two vectors component-wise.
vector2 mat3_mul_vec2(matrix3 m, vector2 v)
Applies a 3x3 affine transform to a vector2.
vector3 vec3_refract(vector3 incident, vector3 normal, vm_float_t eta)
Refracts an incident vector across an interface with a given normal and ratio of refraction eta.
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 vec4_clamp_scalar_ptr(vector4 *res, const vector4 *v, vm_float_t min, vm_float_t max)
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 vec2i_add_scalar_ptr(vector2i *res, const vector2i *v, vm_int_t s)
Adds a scalar to each component.
bool vec3i_is_zero(vector3i v)
Returns true if every component is zero.
matrix3 mat3_scale(vector2 s)
Builds a 3x3 2D scaling matrix.
quaternion quat_inverse(quaternion q)
Returns the inverse of a quaternion.
vm_float_t exponential_ease_out(vm_float_t f)
vm_float_t circular_ease_in(vm_float_t f)
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.
vector4 vec4_splat(vm_float_t s)
Returns a vector with every component set to s.
void vec4i_add_scalar_ptr(vector4i *res, const vector4i *v, vm_int_t s)
Adds a scalar to each component.
void vec4i_neg_ptr(vector4i *res, const vector4i *v)
Negates the components of a vector4i and stores the result in res.
vm_int_t vec4i_min_component(vector4i v)
Returns the smallest component.
vector3i vec3i_add(vector3i a, vector3i b)
Component-wise addition of two vectors.
void mat4_rotation_z_ptr(matrix4 *res, vm_float_t degrees)
Builds a 4x4 rotation matrix around the Z axis (degrees).
void mat2_inverse_ptr(matrix2 *res, const matrix2 *m)
Computes the inverse of the input 2x2 matrix using determinant and stores in res.
void vec3_normalize_ptr(vector3 *res, const vector3 *v)
Normalize a vector to unit length.
vm_float_t mat3_determinant(matrix3 m)
Computes the determinant of a 3x3 matrix.
vector2 vec2_saturate(vector2 v)
Clamps each component to the range [0, 1].
vector4 vec4_x_scale(vm_float_t x)
Returns avector4 for scaling along the x-axis.
void mat4i_transpose_ptr(matrix4i *res, const matrix4i *m)
Transposes the given 4x4 integer matrix and stores the result in the provided matrix structure.
vector3i vec3i_sign(vector3i v)
Computes the sign per component of a vector3i (-1, 0, or 1).
vector2i vec2i_zero(void)
Returns a vector2i with both components set to 0.
matrix4i mat4i_mul(matrix4i a, matrix4i b)
Multiplies two 4x4 integer matrices.
vector3i vec3i_z_axis(vm_int_t z)
Returns a vector3i along the z-axis.
vm_float_t vec4_distance_squared(vector4 a, vector4 b)
Returns the squared Euclidean distance between a and b.
matrix4 quat_to_mat4(quaternion q)
Converts a quaternion to a 4x4 rotation matrix.
void vec4i_min_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Takes the component-wise minimum of two vector4i and stores the result in res.
vector2 vec2_neg(vector2 v)
Negates the vector (multiplies each component by -1.0f).
vector4 vec4_neg(vector4 v)
Negation of a vector.
void vec2_slide_ptr(vector2 *result, const vector2 *v, const vector2 *normal)
Slides the input vector tangent to the normal (removes normal component).
vector3 vec3_normalize(vector3 v)
Normalizes a vector3 to unit length.
vector3 mat4_extract_scale(matrix4 m)
Extracts the scale vector from a matrix4.
const char * vm_cpu_name(vm_cpu_features_t features)
void vec2_add_assign(vector2 *dest, const vector2 *src)
Adds src to dest in place.
vector2 vec2_clamp_scalar(vector2 v, vm_float_t min, vm_float_t max)
Clamps each component to the scalar range [min, max].
void vec4i_sub_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Subtracts the components of the second vector from the first vector4i and stores the result in res.
void vec4_project_ptr(vector4 *res, const vector4 *a, const vector4 *b)
Projects a onto b.
vector2i mat2i_mul_vec2i(matrix2i m, vector2i v)
Multiplies a 2x2 integer matrix by a vector2i.
void vec4_ceil_ptr(vector4 *res, const vector4 *v)
vector3i vec3i_mul_scalar(vector3i v, vm_int_t s)
Component-wise multiplication of vector by scalar.
void mat4i_inverse_ptr(matrix4i *res, const matrix4i *m)
Computes the inverse of the given 4x4 integer matrix and stores the result in the specified matrix.
matrix4 mat4_translate(vector3 v)
Constructs a translation matrix from the given vector.
vector4 vec4_sub(vector4 a, vector4 b)
Component-wise subtraction of two vectors.
void vec2_to_vec3_ptr(vector3 *res, const vector2 *v, vm_float_t z)
Converts a vector2 to a vector3 with the given z.
vm_float_t exponential_ease_in(vm_float_t f)
vector4i vec4i_sign(vector4i v)
Computes the sign per component of a vector4i (-1, 0, or 1).
matrix2 mat2_transpose(matrix2 m)
Computes the transpose of a 2x2 matrix.
void vec4_reject_ptr(vector4 *res, const vector4 *a, const vector4 *b)
Returns the component of a orthogonal to b.
void quat_from_euler_ptr(quaternion *res, const vector3 *euler)
Converts Euler angles (in degrees, XYZ order: pitch, yaw, roll) to a quaternion and stores in res.
vm_float_t cubic_ease_in_out(vm_float_t f)
vector3 vec4_to_vec3(vector4 v)
Converts a vector4 to a vector3 (discards the w component).
bool vec2_is_normalized(vector2 v)
Returns true if the vector has unit length.
vm_float_t vec3i_length(vector3i v)
Computes the length (magnitude) of a vector3i.
vector2 vec2_round(vector2 v)
Applies round to each component.
vector3 vec3_sub_scalar(vector3 v, vm_float_t s)
Subtracts a scalar from each component.
vector3 mat4_mul_vec3(matrix4 m, vector3 v, vm_float_t w)
Transforms a vector3 by a 4x4 matrix using homogeneous w.
vector3i vec3i_zero(void)
Returns a zero-initialized vector3i.
vector2i vec2i_from_rounded(const vector2 *v)
Converts a vector2 to a vector2i by rounding each component.
void mat3i_identity_ptr(matrix3i *res)
Fills the given 3x3 integer matrix with the identity matrix.
vector3 vec3_cross(vector3 a, vector3 b)
Computes the cross-product of two vector3.
vector4 vec4_lerp(vector4 a, vector4 b, vm_float_t t)
Linearly interpolates between two vector4.
quaternion quat_nlerp(quaternion a, quaternion b, vm_float_t t)
Normalized-linearly interpolates from a to b by t.
vm_float_t vec2_cross_scalar(vector2 a, vector2 b)
Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).
vector2 vec2_perpendicular(vector2 v)
Returns the perpendicular vector (90 degrees counterclockwise).
void vec3_ceil_ptr(vector3 *res, const vector3 *v)
Component-wise ceil of a vector.
vector4 vec4_round(vector4 v)
Applies round per component to a vector4.
vm_int_t vec2i_cross_scalar(vector2i a, vector2i b)
Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).
vector3 vec3_div_scalar(vector3 v, vm_float_t s)
Component-wise division of vector by scalar.
void mat3i_mul_vec3i_ptr(vector3i *res, const matrix3i *m, const vector3i *v)
Multiplies a 3x3 integer matrix by a vector3i.
void mat4_translate_ptr(matrix4 *res, const vector3 *v)
Sets the matrix to a translation matrix.
void mat4_extract_translation_ptr(vector3 *res, const matrix4 *m)
Extracts the translation vector from a matrix4.
void vec4_round_ptr(vector4 *res, const vector4 *v)
void quat_normalize_ptr(quaternion *res, const quaternion *q)
vector2 vec2_rotate_around(vector2 v, vector2 pivot, vm_float_t angle)
Rotates v around pivot by angle radians.
void vec3_reject_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Returns the component of a orthogonal to b.
vector4i vec4i_wrap(vector4i v, vector4i period)
Wraps each component of v into [0, period).
vector3i vec3i_abs(vector3i v)
Computes the absolute value per component of a vector3i.
vm_float_t vec2_angle(vector2 a, vector2 b)
Computes the angle between two vectors (in radians, range [0, PI]).
quaternion quat_slerp(quaternion a, quaternion b, vm_float_t t)
Spherical-linearly interpolates from a to b by t.
vm_float_t vec4_distance(vector4 a, vector4 b)
Computes the Euclidean distance between two vector4.
void vec2_sub_scalar_ptr(vector2 *res, const vector2 *v, vm_float_t s)
Subtracts a scalar from each component.
void mat4i_identity_ptr(matrix4i *res)
Sets the given 4x4 integer matrix to the identity matrix.
void vec2_add_scalar_ptr(vector2 *res, const vector2 *v, vm_float_t s)
Adds a scalar to each component.
vector4 vec4_homogenize(vector4 v)
Homogenizes a vector4 (divides x, y, z by w).
vector4 vec4_min(vector4 a, vector4 b)
Computes the component-wise minimum of two vector4.
void mat3_transpose_ptr(matrix3 *res, const matrix3 *m)
Computes the transpose of the input 3x3 matrix and stores in res.
void vec3_orthonormal_basis_ptr(const vector3 *n, vector3 *t, vector3 *b)
Builds a tangent and bitangent orthonormal to n.
void vec4_neg_ptr(vector4 *res, const vector4 *v)
void vec2_refract_ptr(vector2 *res, const vector2 *incident, const vector2 *normal, vm_float_t eta)
Computes the refraction of incident across normal with ratio eta.
vector3 vec3_slide(vector3 v, vector3 normal)
Removes the component of v along normal.
vector4i vec4i_y_axis(vm_int_t y)
Returns a vector4i along the y-axis.
matrix3i mat3i_inverse(matrix3i m)
Computes the inverse of a 3x3 integer matrix.
vm_int_t mat4i_determinant(matrix4i m)
Computes the determinant of a 4x4 integer matrix (Laplace expansion along first row).
void mat3_rotation_x_ptr(matrix3 *res, vm_float_t degrees)
Builds a 3x3 rotation matrix around the X axis (degrees).
void vec3i_lerp_ptr(vector3i *res, const vector3i *a, const vector3i *b, vm_float_t t)
Performs linear interpolation between two vector3i.
vector3i vec3i_x_axis(vm_int_t x)
Returns a vector3i along the x-axis.
vm_float_t vec2_max_component(vector2 v)
Returns the largest component.
void vec3_div_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Component-wise division of vector by scalar.
matrix3 mat3_from_mat4(matrix4 m)
Copies the upper-left 3x3 of a matrix4.
matrix4 mat4_scale(vector3 v)
Constructs a scaling matrix from the given scale vector.
vector2i mat3i_mul_vec2i(matrix3i m, vector2i v)
Applies a 3x3 integer affine transform to a vector2i.
void vec3i_min_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Computes the component-wise minimum of two vector3i.
vector4 vec4_abs(vector4 v)
Computes the absolute value per component of a vector4.
void vec4_normalize_ptr(vector4 *res, const vector4 *v)
void mat3i_transpose_ptr(matrix3i *res, const matrix3i *m)
Computes the transpose of a 3x3 integer matrix.
vector4i vec4i_w_axis(vm_int_t w)
Returns a vector4i along the w-axis.
vm_float_t vec2_heading(vector2 v)
Returns the heading angle of the vector in radians.
void vec2i_normalize_to_vec2_ptr(vector2 *res, const vector2i *v)
Converts to a unit-length vector2.
void vec3i_neg_ptr(vector3i *res, const vector3i *v)
Negates a vector3i (multiplies by -1).
vector3i vec3i_from_rounded(const vector3 *v)
Converts a vector3 to a vector3i by rounding each component.
vector4 vec4_add_scalar(vector4 v, vm_float_t s)
Adds a scalar to each component.
bool mat2i_eq(matrix2i a, matrix2i b)
Returns true if two matrices are exactly equal.
vector3i vec3i_sub_scalar(vector3i v, vm_int_t s)
Subtracts a scalar from each component.
vm_float_t vec2_dot(vector2 a, vector2 b)
Computes the dot product of two vectors.
void vec2i_wrap_ptr(vector2i *res, const vector2i *v, const vector2i *period)
Wraps each component of v into [0, period).
vector3 vec3_scale(vector3 v, vm_float_t s)
Scales the vector by a scalar.
void vec4i_div_floor_ptr(vector4i *res, const vector4i *a, const vector4i *b)
Component-wise floored division of a by b.
void vec2_mul_ptr(vector2 *res, const vector2 *a, const vector2 *b)
Multiplies vectors a and b component-wise, storing the result in res.
matrix4 mat4_ortho(vm_float_t left, vm_float_t right, vm_float_t bottom, vm_float_t top, vm_float_t near, vm_float_t far)
Constructs an orthographic projection matrix.
vector2 vec2_sub(vector2 a, vector2 b)
Subtracts the second vector from the first component-wise.
vector2i vec2i_from(const vector2 *v)
Converts a vector2 to a vector2i by truncation.
vm_float_t vec2_sum(vector2 v)
Returns the sum of all components.
vector2 vec2_cross(vector2 a, vector2 b)
Computes the 2D cross-product as a vector.
void quat_conjugate_ptr(quaternion *res, const quaternion *q)
Writes the conjugate of a quaternion.
vector3 vec3_add(vector3 a, vector3 b)
Component-wise addition of two vectors.
vm_float_t vec3_angle(vector3 a, vector3 b)
Computes the angle between two non-zero vector3 in radians.
vector2 mat2_mul_vec2(matrix2 m, vector2 v)
Multiplies a 2x2 matrix by a vector2.
vector3 vec3_rotate_axis(vector3 v, vector3 axis, vm_float_t angle)
Rotates v around axis by angle radians.
vector2 vec2_div_scalar(vector2 v, vm_float_t s)
Divides a vector by a scalar component-wise.
void vec3_assign(vector3 *dest, const vector3 *src)
Copies src into dest.
vector4 vec4_w_axis(vm_float_t w)
Returns a vector4 along the w-axis.
vm_float_t vec4i_distance(vector4i a, vector4i b)
Computes the Euclidean distance between two vector4i.
vector2i vec2i_lerp(vector2i a, vector2i b, vm_float_t t)
Linearly interpolates from a to b by t.
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.
vm_int_t vec2i_length_chebyshev(vector2i v)
Returns the Chebyshev (L-inf) length.
vector2i vec2i_normalize(vector2i v)
Normalizes the vector to approximate unit length (float length, truncated to int).
void quat_to_mat4_ptr(matrix4 *res, const quaternion *q)
Converts a unit quaternion to a 4x4 rotation matrix and stores in res.
bool vec4_eq(vector4 a, vector4 b)
Returns true if two vectors are equal within VECMAT_EPSILON.
void vec3i_sub_scalar_ptr(vector3i *res, const vector3i *v, vm_int_t s)
Subtracts a scalar from each component.
void vec3_mul_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Component-wise multiplication of vector by scalar.
vector3 vec3_neg(vector3 v)
Negation of a vector.
quaternion quat_mul(quaternion a, quaternion b)
Multiplies two quaternions (a * b).
vm_float_t back_ease_in_out(vm_float_t f)
matrix4 mat4_from_mat3(matrix3 m)
Embeds a matrix3 into the upper-left of a matrix4.
vm_int_t vec4i_max_component(vector4i v)
Returns the largest component.
vector4i vec4i_div(vector4i a, vector4i b)
Divides two vectors component-wise.
void vec4_slide_ptr(vector4 *res, const vector4 *v, const vector4 *normal)
Removes the component of v along normal.
vector2 vec2_floor(vector2 v)
Applies floor to each component.
vector4 vec4_sub_scalar(vector4 v, vm_float_t s)
Subtracts a scalar from each component.
void mat4_transpose_ptr(matrix4 *res, const matrix4 *m)
vm_int_t mat2i_determinant(matrix2i m)
Calculates the determinant of the given 2x2 integer matrix.
vector4i vec4i_abs(vector4i v)
Computes the absolute value per component of a vector4i.
vector4 vec4_mul_scalar(vector4 v, vm_float_t s)
Component-wise multiplication of vector by scalar.
vector4 vec4_max(vector4 a, vector4 b)
Computes the component-wise maximum of two vector4.
vm_float_t quartic_ease_out(vm_float_t f)
vm_float_t vec2_length(vector2 v)
Computes the length (magnitude) of the vector.
vector4i vec4i_zero(void)
Returns a zero-initialized vector4i.
vector3 vec3_sign(vector3 v)
Computes the sign per component of a vector3 (-1, 0, or 1).
bool vec3i_eq(vector3i a, vector3i b)
Returns true if two vectors are exactly equal.
vector3i vec3i_y_scale(vm_int_t y)
Returns a vector3i for scaling along the y-axis.
vector2i vec2i_sub(vector2i a, vector2i b)
Subtracts the second vector from the first component-wise.
void vec3_project_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Projects a onto b.
vector3i vec3i_neg(vector3i v)
Negation of a vector.
vector3i vec3i_x_scale(vm_int_t x)
Returns a vector3i for scaling along the x-axis.
void vec3_floor_ptr(vector3 *res, const vector3 *v)
Component-wise floor of a vector.
bool quat_near(quaternion a, quaternion b, vm_float_t eps)
Returns true if a and b are within eps of each other.
void vec3_assign_xyz(vector3 *dest, vm_float_t x, vm_float_t y, vm_float_t z)
Assigns x, y, and z to dest.
vector3i vec3i_from_vec2i(vector2i v, vm_int_t z)
Builds a vector3i from a vector2i and z.
quaternion quat_from_mat3(matrix3 m)
Builds a quaternion from a 3x3 rotation matrix.
bool mat4_eq(matrix4 a, matrix4 b)
Returns true if two matrices are equal within VECMAT_EPSILON.
vm_float_t deg_to_rad(vm_float_t degrees)
Converts degrees to radians.
matrix3i mat3i_identity(void)
Constructs the 3x3 identity matrix.
vector3i vec3i_min(vector3i a, vector3i b)
Computes the component-wise minimum of two vector3i.
void vec2i_to_vec3i_ptr(vector3i *res, const vector2i *v, vm_int_t z)
Converts a vector4i to a vector3i by dropping w.
vector3i vec3i_max(vector3i a, vector3i b)
Computes the component-wise maximum of two vector3i.
void vec3_limit_length_ptr(vector3 *res, const vector3 *v, vm_float_t max_len)
Clamps the vector length to max_len.
void mat4_from_mat3_ptr(matrix4 *res, const matrix3 *m)
Embeds a matrix3 into the upper-left of a matrix4.
quaternion quat_from_axis_angle(vector3 axis, vm_float_t degrees)
Builds a quaternion from an axis and an angle in degrees.
vm_float_t back_ease_out(vm_float_t f)
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.
vm_float_t quartic_ease_in(vm_float_t f)
void vec4i_sign_ptr(vector4i *res, const vector4i *v)
Computes the sign (-1, 0, or 1) of each component of a vector4i and stores the result in res.
vector2 vec2_zero(void)
Returns a vector2 with both components set to 0.0f.
vector4i vec4i_z_scale(vm_int_t z)
Returns a vector4i for scaling along the z-axis.
vm_float_t vec2i_aspect_ratio(vector2i v)
Computes the aspect ratio of the vector (x / y).
bool mat4i_eq(matrix4i a, matrix4i b)
Returns true if two matrices are exactly equal.
void vec4_mul_ptr(vector4 *res, const vector4 *a, const vector4 *b)
vm_int_t vec2i_min_component(vector2i v)
Returns the smallest component.
vm_float_t exponential_ease_in_out(vm_float_t f)
vector4 vec4_project(vector4 a, vector4 b)
Projects a onto b.
vector4 vec4_w_scale(vm_float_t w)
Returns a vector4 for scaling along the w-axis.
vector4i vec4i_sub_scalar(vector4i v, vm_int_t s)
Subtracts a scalar from each component.
vector2 vec2_reflect(vector2 v, vector2 normal)
Reflects vector v across the normal, storing the result in res.
vm_int_t vec3i_sum(vector3i v)
Returns the sum of all components.
vector2i vec2i_cross(vector2i a, vector2i b)
Computes the 2D cross-product as a vector.
void mat4i_mul_vec4i_ptr(vector4i *res, const matrix4i *m, const vector4i *v)
Multiplies a 4x4 integer matrix by a vector4i.
vector4i vec4i_neg(vector4i v)
Negation of a vector.
vector3 vec3_reject(vector3 a, vector3 b)
Returns the component of a orthogonal to b.
void mat3_rotation_z_ptr(matrix3 *res, vm_float_t degrees)
Sets the 3x3 matrix to a rotation around the Z-axis by the given angle in degrees.
void vec4i_wrap_ptr(vector4i *res, const vector4i *v, const vector4i *period)
Wraps each component of v into [0, period).
vm_float_t quintic_ease_in(vm_float_t f)
void mat4_mul_ptr(matrix4 *res, const matrix4 *a, const matrix4 *b)
vm_int_t vec3i_distance_squared(vector3i a, vector3i b)
Returns the squared Euclidean distance between a and b.
void vec3_refract_ptr(vector3 *res, const vector3 *incident, const vector3 *normal, vm_float_t eta)
Compute refraction of the incident vector through normal with eta.
bool vec3_is_normalized(vector3 v)
Returns true if the vector has unit length.
vm_float_t sine_ease_in_out(vm_float_t f)
vector4i vec4i_max(vector4i a, vector4i b)
Computes the component-wise maximum of two vector4i.
vector3 vec3_saturate(vector3 v)
Clamps each component to the range [0, 1].
matrix4 mat4_trs(vector3 translation, quaternion rotation, vector3 scale)
Builds a 4x4 TRS matrix from translation, rotation, and scale.
vector3i vec3i(vm_int_t x, vm_int_t y, vm_int_t z)
Constructs a vector3i from x, y, and z.
void vec3_neg_ptr(vector3 *res, const vector3 *v)
Negation of a vector.
void vec3_reflect_ptr(vector3 *res, const vector3 *incident, const vector3 *normal)
Compute reflection of the incident vector over normal.
void vec2_assign_xy(vector2 *dest, vm_float_t x, vm_float_t y)
Assigns x and y to dest.
matrix2i mat2i_inverse(matrix2i m)
Computes the inverse of a 2x2 integer matrix.
vector4 vec4_z_scale(vm_float_t z)
Returns a vector4for scaling along the z-axis.
matrix2 mat2_scale(vector2 s)
Builds a 2x2 scaling matrix from a vector2.
void vec3i_sub_ptr(vector3i *res, const vector3i *a, const vector3i *b)
Computes the component-wise difference of two vector3i (a minus b).
vector3 vec2_to_vec3(vector2 v, vm_float_t z)
Converts a vector2 to a vector3 using z.
vector4i vec4i_clamp(vector4i v, vector4i min, vector4i max)
Clamps each component of the input vector to the range defined by the minimum and maximum vectors.
void vec3i_normalize_to_vec3_ptr(vector3 *res, const vector3i *v)
Converts to a unit-length vector3.
matrix2 mat2_rotation_z(vm_float_t degrees)
Constructs a 2x2 Z-axis rotation matrix.
void mat4_perspective_ptr(matrix4 *res, vm_float_t fov, vm_float_t aspect, vm_float_t near, vm_float_t far)
Creates a perspective projection matrix.
vm_float_t bounce_ease_in_out(vm_float_t f)
vector3 mat4_extract_translation(matrix4 m)
Extracts the translation vector from a matrix4.
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,...
vm_int_t vec2i_max_component(vector2i v)
Returns the largest component.
vector3 vec3_sub(vector3 a, vector3 b)
Component-wise subtraction of two vectors.
vm_float_t quintic_ease_out(vm_float_t f)
void vec2_fract_ptr(vector2 *res, const vector2 *v)
Returns the fractional part of each component.
void vec2_lerp_ptr(vector2 *res, const vector2 *a, const vector2 *b, vm_float_t t)
Linearly interpolates from a to b by t.
vm_float_t back_ease_in(vm_float_t f)
vm_float_t mat2_determinant(matrix2 m)
Calculates the determinant of the given 2x2 matrix.
void vec4_sub_ptr(vector4 *res, const vector4 *a, const vector4 *b)
vm_float_t vec2_length_manhattan(vector2 v)
Returns the Manhattan (L1) length.
vector4i vec4i_add(vector4i a, vector4i b)
Component-wise addition of two vectors.
void quat_identity_ptr(quaternion *res)
Sets the quaternion to the identity quaternion (x=0, y=0, z=0, w=1).
bool mat2_eq(matrix2 a, matrix2 b)
Returns true if two matrices are equal within VECMAT_EPSILON.
void mat4_identity_ptr(matrix4 *res)
Sets the matrix to the identity matrix.
vector2i vec2i_sign(vector2i v)
Returns the sign of each component (+1, -1, or 0).
vector3 vec3_round(vector3 v)
Applies round per component to a vector3.
vm_int_t vec3i_dot(vector3i a, vector3i b)
Computes the dot product of two vector3i.
void mat4_trs_ptr(matrix4 *res, const vector3 *translation, const quaternion *rotation, const vector3 *scale)
Builds a 4x4 TRS matrix from translation, rotation, and scale.
vm_cpu_features_t vm_cpu_runtime_features(void)
void vec3_orthonormal_basis(vector3 n, vector3 *t, vector3 *b)
Builds a tangent and bitangent orthonormal to n.
vm_float_t poly_ease_out(vm_float_t f, vm_float_t n)
vm_cpu_features_t vm_cpu_selected_features(void)
vector2i vec2i_neg(vector2i v)
Negates the vector (multiplies each component by -1).
void mat2_mul_vec2_ptr(vector2 *res, const matrix2 *m, const vector2 *v)
Multiplies a 2x2 matrix by a vector2.
vm_float_t bounce_ease_in(vm_float_t f)
void quat_inverse_ptr(quaternion *res, const quaternion *q)
Writes the inverse of a quaternion.
void vec2_floor_ptr(vector2 *res, const vector2 *v)
Applies the floor function to each component of vector v, storing the result in res.
vm_int_t vec4i_dot(vector4i a, vector4i b)
Computes the dot product of two vector4i.
void mat3_rotation_y_ptr(matrix3 *res, vm_float_t degrees)
Builds a 3x3 rotation matrix around the Y axis (degrees).
vector3i vec3i_mul(vector3i a, vector3i b)
Component-wise multiplication of two vectors.
bool vec2_near(vector2 a, vector2 b, vm_float_t eps)
Returns true if a and b are within eps of each other.
void mat2_from_mat3_ptr(matrix2 *res, const matrix3 *m)
Copies the upper-left 2x2 of a matrix3.
vector3i mat3i_mul_vec3i(matrix3i m, vector3i v)
Multiplies a 3x3 integer matrix by a vector3i.
void mat4_rotation_y_ptr(matrix4 *res, vm_float_t degrees)
Builds a 4x4 rotation matrix around the Y axis (degrees).
matrix3i mat3i_transpose(matrix3i m)
Computes the transpose of a 3x3 integer matrix.
vm_float_t sine_ease_in(vm_float_t f)
vm_float_t poly_ease_in_out(vm_float_t f, vm_float_t n)
bool vec4_is_normalized(vector4 v)
Returns true if the vector has unit length.
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...
vector2i vec2i_div_scalar(vector2i v, vm_int_t s)
Divides a vector by a scalar component-wise (float division, truncated to int).
void vec4_clamp_ptr(vector4 *res, const vector4 *v, const vector4 *min, const vector4 *max)
vector3i vec3i_sub(vector3i a, vector3i b)
Component-wise subtraction of two vectors.
vector3i vec3i_cross(vector3i a, vector3i b)
Computes the cross-product of two vector3i.
vm_float_t vec2i_length(vector2i v)
Computes the length (magnitude) of the vector.
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.
vector2 vec2_y_axis(vm_float_t y)
Returns a vector2 along the y-axis (x = 0.0f).
matrix2i mat2i_mul(matrix2i a, matrix2i b)
Multiplies two 2x2 integer matrices (a * b).