Vecmat 0.2.3
C math and linear algebra library for 2D/3D graphics, physics, and science.
Loading...
Searching...
No Matches
vecmat.h File Reference
#include <math.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  vector2
struct  vector3
struct  vector4
struct  vector2i
struct  vector3i
struct  vector4i
struct  matrix2
struct  matrix3
struct  matrix4
struct  matrix2i
struct  matrix3i
struct  matrix4i
struct  quaternion

Macros

#define VECMAT_VERSION_MAJOR   0
#define VECMAT_VERSION_MINOR   2
#define VECMAT_VERSION_PATCH   3
#define VECMAT_STR_HELPER(x)
#define VECMAT_STR(x)
#define VECMAT_VERSION
#define VEC_API
#define M_E   2.71828182845904523536
#define M_LOG2E   1.44269504088896340736
#define M_LOG10E   0.434294481903251827651
#define M_LN2   0.693147180559945309417
#define M_LN10   2.30258509299404568402
#define M_PI   3.14159265358979323846
#define M_PI_2   1.57079632679489661923
#define M_PI_4   0.785398163397448309616
#define M_1_PI   0.318309886183790671538
#define M_2_PI   0.636619772367581343076
#define M_2_SQRTPI   1.12837916709551257390
#define M_SQRT2   1.41421356237309504880
#define M_SQRT1_2   0.707106781186547524401
#define VECMAT_FLT_MAX   __FLT_MAX__
#define VECMAT_DBL_MAX   __DBL_MAX__
#define VECMAT_FLT_MIN   __FLT_MIN__
#define VECMAT_DBL_MIN   __DBL_MIN__
#define VECMAT_VEC2_SIZE   2
#define VECMAT_VEC3_SIZE   3
#define VECMAT_VEC4_SIZE   4
#define VECMAT_MAT2_SIZE   4
#define VECMAT_MAT3_SIZE   9
#define VECMAT_MAT4_SIZE   16
#define VECMAT_QUAT_SIZE   4
#define VM_F(x)
#define VEC_INT_MAX   INT8_MAX
#define VEC_INT_MIN   INT8_MIN
#define VECMAT_EPS_F32   1e-6f
#define VECMAT_EPS_F64   1e-12
#define VECMAT_EPSILON   VECMAT_EPS_F64
#define FLOAT_EQ(a, b, eps)
 Checks if two floats are approximately equal within tolerance.
#define DOUBLE_EQ(a, b, eps)
 Checks if two doubles are approximately equal within tolerance.
#define VECMAT_EQ(a, b, eps)
#define VECMAT_FABS(x)
#define VECMAT_SQRT(x)
#define VECMAT_SIN(x)
#define VECMAT_COS(x)
#define VECMAT_TAN(x)
#define VECMAT_ASIN(x)
#define VECMAT_ACOS(x)
#define VECMAT_ATAN(x)
#define VECMAT_ATAN2(y, x)
#define VECMAT_FMIN(a, b)
#define VECMAT_FMAX(a, b)
#define VECMAT_FLOOR(x)
#define VECMAT_CEIL(x)
#define VECMAT_ROUND(x)
#define VECMAT_POW(x, y)
#define VECMAT_COPYSIGN(x, y)

Typedefs

typedef double vm_float_t
typedef int8_t vm_int_t
typedef uint32_t vm_cpu_features_t

Enumerations

enum  {
  VM_CPU_SCALAR = 1u << 0 , VM_CPU_AVX2 = 1u << 1 , VM_CPU_SVE = 1u << 2 , VM_CPU_AVX512 = 1u << 3 ,
  VM_CPU_SVE2 = 1u << 4 , VM_CPU_AVX = 1u << 5
}

Functions

vm_cpu_features_t vm_cpu_compiled_features (void)
vm_cpu_features_t vm_cpu_runtime_features (void)
vm_cpu_features_t vm_cpu_selected_features (void)
const char * vm_cpu_name (vm_cpu_features_t features)
void vm_cpu_init (void)
vector2 vec2_add (vector2 a, vector2 b)
 Adds two vectors component-wise.
vector2 vec2_sub (vector2 a, vector2 b)
 Subtracts the second vector from the first component-wise.
vector2 vec2_mul_scalar (vector2 v, vm_float_t s)
 Multiplies a vector by a scalar component-wise.
vector2 vec2_div_scalar (vector2 v, vm_float_t s)
 Divides a vector by a scalar component-wise.
vector2 vec2_mul (vector2 a, vector2 b)
 Multiplies two vectors component-wise (Hadamard product).
vector2 vec2_neg (vector2 v)
 Negates the vector (multiplies each component by -1.0f).
vector2 vec2_abs (vector2 v)
 Returns the absolute values of each component.
vector2 vec2_zero (void)
 Returns a vector2 with both components set to 0.0f.
vector2 vec2_one (void)
 Returns a vector2 with both components set to 1.0f.
vector2 vec2_x_axis (vm_float_t x)
 Returns a vector2 along the x-axis (y = 0.0f).
vector2 vec2_y_axis (vm_float_t y)
 Returns a vector2 along the y-axis (x = 0.0f).
vector2 vec2_x_scale (vm_float_t x)
 Returns a vector2 representing x-axis scaling (y = 1.0f).
vector2 vec2_y_scale (vm_float_t y)
 Returns a vector2 representing y-axis scaling (x = 1.0f).
vector2 vec2_scale (vector2 v, vm_float_t s)
 Scales a vector by a scalar component-wise.
vector2 vec2_cross (vector2 a, vector2 b)
 Computes the 2D cross-product as a vector.
vector2 vec2_normalize (vector2 v)
 Normalizes the vector to unit length.
vector2 vec2_min (vector2 a, vector2 b)
 Returns the component-wise minimum of two vectors.
vector2 vec2_max (vector2 a, vector2 b)
 Returns the component-wise maximum of two vectors.
vector2 vec2_sign (vector2 v)
 Returns the sign of each component (+1.0f, -1.0f, or 0.0f).
vector2 vec2_floor (vector2 v)
 Applies floor to each component.
vector2 vec2_ceil (vector2 v)
 Applies ceil to each component.
vector2 vec2_round (vector2 v)
 Applies round to each component.
vector2 vec2_perpendicular (vector2 v)
 Returns the perpendicular vector (90 degrees counterclockwise).
vector2 vec2_reflect (vector2 v, vector2 normal)
 Reflects vector v across the normal, storing the result in res.
vector2 vec2_project (vector2 a, vector2 b)
 Projects the first vector onto the second.
vector2 vec2_tangent (vector2 v)
 Returns the tangent vector perpendicular to the input (90 degrees clockwise).
vector2 vec2_rotate (vector2 v, vm_float_t angle)
 Rotates the input vector counterclockwise by the given angle (radians).
vector2 vec2_slide (vector2 v, vector2 normal)
 Slides the input vector tangent to the normal (removes normal component).
vector2 vec2_clamp (vector2 v, vector2 min, vector2 max)
 Clamps vector v component-wise between min and max.
vector2 vec2_lerp (vector2 a, vector2 b, vm_float_t t)
 Linearly interpolates from a to b by t.
vector2 vec2_div (vector2 a, vector2 b)
 Divides two vectors component-wise.
vector2 vec2_add_scalar (vector2 v, vm_float_t s)
 Adds a scalar to each component.
vector2 vec2_sub_scalar (vector2 v, vm_float_t s)
 Subtracts a scalar from each component.
vector2 vec2_clamp_scalar (vector2 v, vm_float_t min, vm_float_t max)
 Clamps each component to the scalar range [min, max].
vector2 vec2_saturate (vector2 v)
 Clamps each component to the range [0, 1].
vector2 vec2_fract (vector2 v)
 Returns the fractional part of each component.
vector2 vec2_refract (vector2 incident, vector2 normal, vm_float_t eta)
 Computes the refraction of incident across normal with ratio eta.
vector2 vec2_reject (vector2 a, vector2 b)
 Returns the component of a orthogonal to b.
vector2 vec2_splat (vm_float_t s)
 Returns a vector with every component set to s.
vector2 vec2_from_angle (vm_float_t angle)
 Returns the unit vector at the given angle in radians.
vector2 vec2_rotate_around (vector2 v, vector2 pivot, vm_float_t angle)
 Rotates v around pivot by angle radians.
vector2 vec2_move_toward (vector2 current, vector2 target, vm_float_t max_delta)
 Moves current toward target by at most max_delta.
vector2 vec2_limit_length (vector2 v, vm_float_t max_len)
 Clamps the vector length to max_len.
vector3 vec2_to_vec3 (vector2 v, vm_float_t z)
 Converts a vector2 to a vector3 using z.
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.
vm_float_t vec2_length_squared (vector2 v)
 Returns the squared Euclidean length.
vm_float_t vec2_length_manhattan (vector2 v)
 Returns the Manhattan (L1) length.
vm_float_t vec2_length_chebyshev (vector2 v)
 Returns the Chebyshev (L-inf) length.
vm_float_t vec2_aspect_ratio (vector2 v)
 Computes the aspect ratio of the vector (x / y).
vm_float_t vec2_distance (vector2 a, vector2 b)
 Computes the Euclidean distance between two vectors (treated as points).
vm_float_t vec2_distance_squared (vector2 a, vector2 b)
 Returns the squared Euclidean distance between a and b.
vm_float_t vec2_angle (vector2 a, vector2 b)
 Computes the angle between two vectors (in radians, range [0, PI]).
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).
vm_float_t vec2_heading (vector2 v)
 Returns the heading angle of the vector in radians.
vm_float_t vec2_min_component (vector2 v)
 Returns the smallest component.
vm_float_t vec2_max_component (vector2 v)
 Returns the largest component.
vm_float_t vec2_sum (vector2 v)
 Returns the sum of all components.
bool vec2_is_zero (vector2 v)
 Returns true if every component is zero.
bool vec2_is_normalized (vector2 v)
 Returns true if the vector has unit length.
bool vec2_near (vector2 a, vector2 b, vm_float_t eps)
 Returns true if a and b are within eps of each other.
vector3 vec3_add (vector3 a, vector3 b)
 Component-wise addition of two vectors.
vector3 vec3_sub (vector3 a, vector3 b)
 Component-wise subtraction of two vectors.
vector3 vec3_mul_scalar (vector3 v, vm_float_t s)
 Component-wise multiplication of vector by scalar.
vector3 vec3_div_scalar (vector3 v, vm_float_t s)
 Component-wise division of vector by scalar.
vector3 vec3_mul (vector3 a, vector3 b)
 Component-wise multiplication of two vectors.
vector3 vec3_neg (vector3 v)
 Negation of a vector.
vector3 vec3_abs (vector3 v)
 Computes the absolute value per component of a vector3.
vector3 vec3_zero (void)
 Returns a zero-initialized vector3.
vector3 vec3_one (void)
 Returns a vector3 with all components set to 1.0f.
vector3 vec3_x_axis (vm_float_t x)
 Returns a vector3 along the x-axis.
vector3 vec3_y_axis (vm_float_t y)
 Returns a vector3 along the y-axis.
vector3 vec3_z_axis (vm_float_t z)
 Returns a vector3 along the z-axis.
vector3 vec3_x_scale (vm_float_t x)
 Returns a vector3 for scaling along the x-axis.
vector3 vec3_y_scale (vm_float_t y)
 Returns a vector3 for scaling along the y-axis.
vector3 vec3_z_scale (vm_float_t z)
 Returns a vector3 for scaling along the z-axis.
vector3 vec3_cross (vector3 a, vector3 b)
 Computes the cross-product of two vector3.
vector3 vec3_normalize (vector3 v)
 Normalizes a vector3 to unit length.
vector3 vec3_min (vector3 a, vector3 b)
 Computes the component-wise minimum of two vector3.
vector3 vec3_max (vector3 a, vector3 b)
 Computes the component-wise maximum of two vector3.
vector3 vec3_sign (vector3 v)
 Computes the sign per component of a vector3 (-1, 0, or 1).
vector3 vec3_floor (vector3 v)
 Applies the floor per component to a vector3.
vector3 vec3_ceil (vector3 v)
 Applies ceil per component to a vector3.
vector3 vec3_round (vector3 v)
 Applies round per component to a vector3.
vector3 vec3_reflect (vector3 incident, vector3 normal)
 Reflects an incident vector over normal.
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.
vector3 vec3_lerp (vector3 a, vector3 b, vm_float_t t)
 Linearly interpolates between two vector3.
vector3 vec3_clamp (vector3 v, vector3 min, vector3 max)
 Clamps a vector3 between min and max per component.
vector3 vec3_scale (vector3 v, vm_float_t s)
 Scales the vector by a scalar.
vector3 vec3_div (vector3 a, vector3 b)
 Divides two vectors component-wise.
vector3 vec3_add_scalar (vector3 v, vm_float_t s)
 Adds a scalar to each component.
vector3 vec3_sub_scalar (vector3 v, vm_float_t s)
 Subtracts a scalar from each component.
vector3 vec3_clamp_scalar (vector3 v, vm_float_t min, vm_float_t max)
 Clamps each component to the scalar range [min, max].
vector3 vec3_saturate (vector3 v)
 Clamps each component to the range [0, 1].
vector3 vec3_fract (vector3 v)
 Returns the fractional part of each component.
vector3 vec3_project (vector3 a, vector3 b)
 Projects a onto b.
vector3 vec3_slide (vector3 v, vector3 normal)
 Removes the component of v along normal.
vector3 vec3_reject (vector3 a, vector3 b)
 Returns the component of a orthogonal to b.
vector3 vec3_rotate_axis (vector3 v, vector3 axis, vm_float_t angle)
 Rotates v around axis by angle radians.
vector3 vec3_splat (vm_float_t s)
 Returns a vector with every component set to s.
vector3 vec3_from_vec2 (vector2 v, vm_float_t z)
 Builds a vector3 from a vector2 and z.
vector3 vec3_move_toward (vector3 current, vector3 target, vm_float_t max_delta)
 Moves current toward target by at most max_delta.
vector3 vec3_limit_length (vector3 v, vm_float_t max_len)
 Clamps the vector length to max_len.
vector2 vec3_xy (vector3 v)
 Returns the x and y components as a 2D vector.
void vec3_orthonormal_basis (vector3 n, vector3 *t, vector3 *b)
 Builds a tangent and bitangent orthonormal to n.
vm_float_t vec3_dot (vector3 a, vector3 b)
 Computes the dot product of two vector3.
vm_float_t vec3_length (vector3 v)
 Computes the length (magnitude) of a vector3.
vm_float_t vec3_length_squared (vector3 v)
 Returns the squared Euclidean length.
vm_float_t vec3_length_manhattan (vector3 v)
 Returns the Manhattan (L1) length.
vm_float_t vec3_length_chebyshev (vector3 v)
 Returns the Chebyshev (L-inf) length.
vm_float_t vec3_distance (vector3 a, vector3 b)
 Computes the Euclidean distance between two vector3.
vm_float_t vec3_distance_squared (vector3 a, vector3 b)
 Returns the squared Euclidean distance between a and b.
vm_float_t vec3_angle (vector3 a, vector3 b)
 Computes the angle between two non-zero vector3 in radians.
vm_float_t vec3_signed_angle (vector3 a, vector3 b, vector3 axis)
 Returns the signed angle from a to b around axis.
vm_float_t vec3_min_component (vector3 v)
 Returns the smallest component.
vm_float_t vec3_max_component (vector3 v)
 Returns the largest component.
vm_float_t vec3_sum (vector3 v)
 Returns the sum of all components.
bool vec3_is_zero (vector3 v)
 Returns true if every component is zero.
bool vec3_is_normalized (vector3 v)
 Returns true if the vector has unit length.
bool vec3_near (vector3 a, vector3 b, vm_float_t eps)
 Returns true if a and b are within eps of each other.
vector4 vec4_add (vector4 a, vector4 b)
 Component-wise addition of two vectors.
vector4 vec4_sub (vector4 a, vector4 b)
 Component-wise subtraction of two vectors.
vector4 vec4_mul_scalar (vector4 v, vm_float_t s)
 Component-wise multiplication of vector by scalar.
vector4 vec4_div_scalar (vector4 v, vm_float_t s)
 Component-wise division of vector by scalar.
vector4 vec4_mul (vector4 a, vector4 b)
 Component-wise multiplication of two vectors.
vector4 vec4_neg (vector4 v)
 Negation of a vector.
vector4 vec4_abs (vector4 v)
 Computes the absolute value per component of a vector4.
vector4 vec4_zero (void)
 Returns a zero-initialized vector4.
vector4 vec4_one (void)
 Returns a vector4 with all components set to 1.0f.
vector4 vec4_x_axis (vm_float_t x)
 Returns a vector4 along the x-axis.
vector4 vec4_y_axis (vm_float_t y)
 Returns a vector4 along the y-axis.
vector4 vec4_z_axis (vm_float_t z)
 Returns a vector4 along the z-axis.
vector4 vec4_w_axis (vm_float_t w)
 Returns a vector4 along the w-axis.
vector4 vec4_x_scale (vm_float_t x)
 Returns avector4 for scaling along the x-axis.
vector4 vec4_y_scale (vm_float_t y)
 Returns a vector4 for scaling along the y-axis.
vector4 vec4_z_scale (vm_float_t z)
 Returns a vector4for scaling along the z-axis.
vector4 vec4_w_scale (vm_float_t w)
 Returns a vector4 for scaling along the w-axis.
vector4 vec4_normalize (vector4 v)
 Normalizes a vector4 to unit length.
vector4 vec4_min (vector4 a, vector4 b)
 Computes the component-wise minimum of two vector4.
vector4 vec4_max (vector4 a, vector4 b)
 Computes the component-wise maximum of two vector4.
vector4 vec4_sign (vector4 v)
 Computes the sign per component of a vector4 (-1, 0, or 1).
vector4 vec4_floor (vector4 v)
 Applies the floor per component to a vector4.
vector4 vec4_ceil (vector4 v)
 Applies ceil per component to a vector4.
vector4 vec4_round (vector4 v)
 Applies round per component to a vector4.
vector4 vec4_lerp (vector4 a, vector4 b, vm_float_t t)
 Linearly interpolates between two vector4.
vector4 vec4_clamp (vector4 v, vector4 min, vector4 max)
 Clamps a vector4 between min and max per component.
vector4 vec4_homogenize (vector4 v)
 Homogenizes a vector4 (divides x, y, z by w).
vector4 vec4_div (vector4 a, vector4 b)
 Divides two vectors component-wise.
vector4 vec4_add_scalar (vector4 v, vm_float_t s)
 Adds a scalar to each component.
vector4 vec4_sub_scalar (vector4 v, vm_float_t s)
 Subtracts a scalar from each component.
vector4 vec4_clamp_scalar (vector4 v, vm_float_t min, vm_float_t max)
 Clamps each component to the scalar range [min, max].
vector4 vec4_saturate (vector4 v)
 Clamps each component to the range [0, 1].
vector4 vec4_fract (vector4 v)
 Returns the fractional part of each component.
vector4 vec4_project (vector4 a, vector4 b)
 Projects a onto b.
vector4 vec4_reject (vector4 a, vector4 b)
 Returns the component of a orthogonal to b.
vector4 vec4_slide (vector4 v, vector4 normal)
 Removes the component of v along normal.
vector4 vec4_splat (vm_float_t s)
 Returns a vector with every component set to s.
vector3 vec4_to_vec3 (vector4 v)
 Converts a vector4 to a vector3 (discards the w component).
vm_float_t vec4_dot (vector4 a, vector4 b)
 Computes the dot product of two vector4.
vm_float_t vec4_length (vector4 v)
 Computes the length (magnitude) of a vector4.
vm_float_t vec4_length_squared (vector4 v)
 Returns the squared Euclidean length.
vm_float_t vec4_distance (vector4 a, vector4 b)
 Computes the Euclidean distance between two vector4.
vm_float_t vec4_distance_squared (vector4 a, vector4 b)
 Returns the squared Euclidean distance between a and b.
bool vec4_is_zero (vector4 v)
 Returns true if every component is zero.
bool vec4_is_normalized (vector4 v)
 Returns true if the vector has unit length.
bool vec4_near (vector4 a, vector4 b, vm_float_t eps)
 Returns true if a and b are within eps of each other.
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_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_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 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.
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_neg_ptr (vector2 *res, const vector2 *v)
 Negates the components of vector v, storing the result in res.
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_normalize_ptr (vector2 *res, const vector2 *v)
 Normalizes vector v to unit length, storing the result in res.
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_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_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_floor_ptr (vector2 *res, const vector2 *v)
 Applies the floor function to each component of vector v, storing the result in res.
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_round_ptr (vector2 *res, const vector2 *v)
 Applies the round function to each component of vector v, storing the result in res.
void vec2_perpendicular_ptr (vector2 *res, const vector2 *v)
 Computes the perpendicular vector to v (90 degrees counterclockwise rotation), storing the result in res.
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.
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.
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_project_ptr (vector2 *res, const vector2 *a, const vector2 *b)
 Projects vector a onto vector b (scalar projection scaled by b).
void vec2_tangent_ptr (vector2 *res, const vector2 *v)
 Computes a tangent vector perpendicular to the input (90 degrees clockwise).
void vec2_rotate_ptr (vector2 *result, const vector2 *v, vm_float_t angle)
 Rotates the input vector counterclockwise by the given angle (radians).
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_clamp_ptr (vector2 *res, const vector2 *v, const vector2 *min, const vector2 *max)
 Clamps vector v component-wise between min and max.
void vec2_lerp_ptr (vector2 *res, const vector2 *a, const vector2 *b, vm_float_t t)
 Linearly interpolates from a to b by t.
void vec2_div_ptr (vector2 *res, const vector2 *a, const vector2 *b)
 Divides two vectors component-wise.
void vec2_add_scalar_ptr (vector2 *res, const vector2 *v, vm_float_t s)
 Adds a scalar to each component.
void vec2_sub_scalar_ptr (vector2 *res, const vector2 *v, vm_float_t s)
 Subtracts a scalar from each component.
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].
void vec2_saturate_ptr (vector2 *res, const vector2 *v)
 Clamps each component to the range [0, 1].
void vec2_fract_ptr (vector2 *res, const vector2 *v)
 Returns the fractional part of each component.
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.
void vec2_reject_ptr (vector2 *res, const vector2 *a, const vector2 *b)
 Returns the component of a orthogonal to b.
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 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 vec2_limit_length_ptr (vector2 *res, const vector2 *v, vm_float_t max_len)
 Clamps the vector length to max_len.
void vec2_to_vec3_ptr (vector3 *res, const vector2 *v, vm_float_t z)
 Converts a vector2 to a vector3 with the given z.
void vec3_add_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Component-wise addition of two vectors.
void vec3_sub_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Component-wise subtraction of two vectors.
void vec3_mul_scalar_ptr (vector3 *res, const vector3 *v, vm_float_t s)
 Component-wise multiplication of vector by scalar.
void vec3_div_scalar_ptr (vector3 *res, const vector3 *v, vm_float_t s)
 Component-wise division of vector by scalar.
void vec3_mul_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Component-wise multiplication of two vectors.
void vec3_neg_ptr (vector3 *res, const vector3 *v)
 Negation of a vector.
void vec3_abs_ptr (vector3 *res, const vector3 *v)
 Computes the absolute value per component of a vector3.
void vec3_normalize_ptr (vector3 *res, const vector3 *v)
 Normalize a vector to unit length.
void vec3_cross_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Compute cross-product of two vectors.
void vec3_min_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Component-wise minimum of two vectors.
void vec3_max_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Component-wise maximum of two vectors.
void vec3_sign_ptr (vector3 *res, const vector3 *v)
 Component-wise sign of a vector.
void vec3_floor_ptr (vector3 *res, const vector3 *v)
 Component-wise floor of a vector.
void vec3_ceil_ptr (vector3 *res, const vector3 *v)
 Component-wise ceil of a vector.
void vec3_round_ptr (vector3 *res, const vector3 *v)
 Component-wise round of a vector.
void vec3_reflect_ptr (vector3 *res, const vector3 *incident, const vector3 *normal)
 Compute reflection of the incident vector over normal.
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.
void vec3_lerp_ptr (vector3 *res, const vector3 *a, const vector3 *b, vm_float_t t)
 Linear interpolation between two vectors.
void vec3_clamp_ptr (vector3 *res, const vector3 *v, const vector3 *min, const vector3 *max)
 Clamp vector components between min and max.
void vec3_scale_ptr (vector3 *res, const vector3 *v, vm_float_t s)
 Scales the vector by a scalar.
void vec3_div_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Divides two vectors component-wise.
void vec3_add_scalar_ptr (vector3 *res, const vector3 *v, vm_float_t s)
 Adds a scalar to each component.
void vec3_sub_scalar_ptr (vector3 *res, const vector3 *v, vm_float_t s)
 Subtracts a scalar from each component.
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].
void vec3_saturate_ptr (vector3 *res, const vector3 *v)
 Clamps each component to the range [0, 1].
void vec3_fract_ptr (vector3 *res, const vector3 *v)
 Returns the fractional part of each component.
void vec3_project_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Projects a onto b.
void vec3_slide_ptr (vector3 *res, const vector3 *v, const vector3 *normal)
 Removes the component of v along normal.
void vec3_reject_ptr (vector3 *res, const vector3 *a, const vector3 *b)
 Returns the component of a orthogonal to b.
void vec3_rotate_axis_ptr (vector3 *res, const vector3 *v, const vector3 *axis, vm_float_t angle)
 Rotates v around axis by angle radians.
void vec3_from_vec2_ptr (vector3 *res, const vector2 *v, vm_float_t z)
 Builds a higher-dimension vector from a vector2.
void vec3_xy_ptr (vector2 *res, const vector3 *v)
 Returns the x and y components as a 2D vector.
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 vec3_limit_length_ptr (vector3 *res, const vector3 *v, vm_float_t max_len)
 Clamps the vector length to max_len.
void vec3_orthonormal_basis_ptr (const vector3 *n, vector3 *t, vector3 *b)
 Builds a tangent and bitangent orthonormal to n.
void vec4_add_ptr (vector4 *res, const vector4 *a, const vector4 *b)
void vec4_sub_ptr (vector4 *res, const vector4 *a, const vector4 *b)
void vec4_mul_scalar_ptr (vector4 *res, const vector4 *v, vm_float_t s)
void vec4_div_scalar_ptr (vector4 *res, const vector4 *v, vm_float_t s)
void vec4_mul_ptr (vector4 *res, const vector4 *a, const vector4 *b)
void vec4_neg_ptr (vector4 *res, const vector4 *v)
void vec4_abs_ptr (vector4 *res, const vector4 *v)
void vec4_normalize_ptr (vector4 *res, const vector4 *v)
void vec4_min_ptr (vector4 *res, const vector4 *a, const vector4 *b)
void vec4_max_ptr (vector4 *res, const vector4 *a, const vector4 *b)
void vec4_sign_ptr (vector4 *res, const vector4 *v)
void vec4_floor_ptr (vector4 *res, const vector4 *v)
void vec4_ceil_ptr (vector4 *res, const vector4 *v)
void vec4_round_ptr (vector4 *res, const vector4 *v)
void vec4_lerp_ptr (vector4 *res, const vector4 *a, const vector4 *b, vm_float_t t)
void vec4_clamp_ptr (vector4 *res, const vector4 *v, const vector4 *min, const vector4 *max)
void vec4_homogenize_ptr (vector4 *res, const vector4 *v)
void vec4_div_ptr (vector4 *res, const vector4 *a, const vector4 *b)
void vec4_add_scalar_ptr (vector4 *res, const vector4 *v, vm_float_t s)
void vec4_sub_scalar_ptr (vector4 *res, const vector4 *v, vm_float_t s)
void vec4_clamp_scalar_ptr (vector4 *res, const vector4 *v, vm_float_t min, vm_float_t max)
void vec4_saturate_ptr (vector4 *res, const vector4 *v)
void vec4_fract_ptr (vector4 *res, const vector4 *v)
void vec4_project_ptr (vector4 *res, const vector4 *a, const vector4 *b)
 Projects a onto b.
void vec4_reject_ptr (vector4 *res, const vector4 *a, const vector4 *b)
 Returns the component of a orthogonal to b.
void vec4_slide_ptr (vector4 *res, const vector4 *v, const vector4 *normal)
 Removes the component of v along normal.
void vec4_to_vec3_ptr (vector3 *res, const vector4 *v)
 Copies the x, y, z components from a vector4 to a vector3.
vector2i vec2i_add (vector2i a, vector2i b)
 Adds two vectors component-wise.
vector2i vec2i_sub (vector2i a, vector2i b)
 Subtracts the second vector from the first component-wise.
vector2i vec2i_mul_scalar (vector2i v, vm_int_t s)
 Multiplies a vector by a scalar component-wise.
vector2i vec2i_div_scalar (vector2i v, vm_int_t s)
 Divides a vector by a scalar component-wise (float division, truncated to int).
vector2i vec2i_mul (vector2i a, vector2i b)
 Multiplies two vectors component-wise (Hadamard product).
vector2i vec2i_neg (vector2i v)
 Negates the vector (multiplies each component by -1).
vector2i vec2i_abs (vector2i v)
 Returns the absolute values of each component.
vector2i vec2i_zero (void)
 Returns a vector2i with both components set to 0.
vector2i vec2i_one (void)
 Returns a vector2i with both components set to 1.
vector2i vec2i_x_axis (vm_int_t x)
 Returns a vector2i along the x-axis (y = 0).
vector2i vec2i_y_axis (vm_int_t y)
 Returns a vector2i along the y-axis (x = 0).
vector2i vec2i_x_scale (vm_int_t x)
 Returns a vector2i representing x-axis scaling (y = 1).
vector2i vec2i_y_scale (vm_int_t y)
 Returns a vector2i representing y-axis scaling (x = 1).
vector2i vec2i_cross (vector2i a, vector2i b)
 Computes the 2D cross-product as a vector.
vector2i vec2i_normalize (vector2i v)
 Normalizes the vector to approximate unit length (float length, truncated to int).
vector2i vec2i_min (vector2i a, vector2i b)
 Returns the component-wise minimum of two vectors.
vector2i vec2i_max (vector2i a, vector2i b)
 Returns the component-wise maximum of two vectors.
vector2i vec2i_sign (vector2i v)
 Returns the sign of each component (+1, -1, or 0).
vector2i vec2i_perpendicular (vector2i v)
 Returns the perpendicular vector (90 degrees counterclockwise).
vector2i vec2i_lerp (vector2i a, vector2i b, vm_float_t t)
 Linearly interpolates from a to b by t.
vector2i vec2i_clamp (vector2i v, vector2i min, vector2i max)
 Clamps each component between min and max.
vector2i vec2i_div (vector2i a, vector2i b)
 Divides two vectors component-wise.
vector2i vec2i_add_scalar (vector2i v, vm_int_t s)
 Adds a scalar to each component.
vector2i vec2i_sub_scalar (vector2i v, vm_int_t s)
 Subtracts a scalar from each component.
vector2i vec2i_mod (vector2i a, vector2i b)
 Component-wise floor modulo of a by b.
vector2i vec2i_div_floor (vector2i a, vector2i b)
 Component-wise floored division of a by b.
vector2i vec2i_wrap (vector2i v, vector2i period)
 Wraps each component of v into [0, period).
vector2i vec2i_splat (vm_int_t s)
 Returns a vector with every component set to s.
vector3i vec2i_to_vec3i (vector2i v, vm_int_t z)
 Converts a vector2i to a vector3i using z.
vector2 vec2i_normalize_to_vec2 (vector2i v)
 Converts to a unit-length vector2.
vm_int_t vec2i_dot (vector2i a, vector2i b)
 Computes the dot product of two vectors.
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).
vm_int_t vec2i_length_squared (vector2i v)
 Returns the squared Euclidean length.
vm_int_t vec2i_distance_squared (vector2i a, vector2i b)
 Returns the squared Euclidean distance between a and b.
vm_int_t vec2i_length_manhattan (vector2i v)
 Returns the Manhattan (L1) length.
vm_int_t vec2i_length_chebyshev (vector2i v)
 Returns the Chebyshev (L-inf) length.
vm_int_t vec2i_min_component (vector2i v)
 Returns the smallest component.
vm_int_t vec2i_max_component (vector2i v)
 Returns the largest component.
vm_int_t vec2i_sum (vector2i v)
 Returns the sum of all components.
vm_float_t vec2i_length (vector2i v)
 Computes the length (magnitude) of the vector.
vm_float_t vec2i_distance (vector2i a, vector2i b)
 Computes the Euclidean distance between two vectors (treated as points).
vm_float_t vec2i_angle (vector2i a, vector2i b)
 Computes the signed angle between two vectors (in radians, range [-PI, PI]) using atan2(cross, dot).
vm_float_t vec2i_aspect_ratio (vector2i v)
 Computes the aspect ratio of the vector (x / y).
bool vec2i_is_zero (vector2i v)
 Returns true if every component is zero.
vector3i vec3i_add (vector3i a, vector3i b)
 Component-wise addition of two vectors.
vector3i vec3i_sub (vector3i a, vector3i b)
 Component-wise subtraction of two vectors.
vector3i vec3i_mul_scalar (vector3i v, vm_int_t s)
 Component-wise multiplication of vector by scalar.
vector3i vec3i_div_scalar (vector3i v, vm_int_t s)
 Component-wise division of vector by scalar.
vector3i vec3i_mul (vector3i a, vector3i b)
 Component-wise multiplication of two vectors.
vector3i vec3i_neg (vector3i v)
 Negation of a vector.
vector3i vec3i_abs (vector3i v)
 Computes the absolute value per component of a vector3i.
vector3i vec3i_zero (void)
 Returns a zero-initialized vector3i.
vector3i vec3i_one (void)
 Returns a vector3i with all components set to 1.
vector3i vec3i_x_axis (vm_int_t x)
 Returns a vector3i along the x-axis.
vector3i vec3i_y_axis (vm_int_t y)
 Returns a vector3i along the y-axis.
vector3i vec3i_z_axis (vm_int_t z)
 Returns a vector3i along the z-axis.
vector3i vec3i_x_scale (vm_int_t x)
 Returns a vector3i for scaling along the x-axis.
vector3i vec3i_y_scale (vm_int_t y)
 Returns a vector3i for scaling along the y-axis.
vector3i vec3i_z_scale (vm_int_t z)
 Returns a vector3i for scaling along the z-axis.
vector3i vec3i_cross (vector3i a, vector3i b)
 Computes the cross-product of two vector3i.
vector3i vec3i_normalize (vector3i v)
 Normalizes a vector3i to unit length.
vector3i vec3i_min (vector3i a, vector3i b)
 Computes the component-wise minimum of two vector3i.
vector3i vec3i_max (vector3i a, vector3i b)
 Computes the component-wise maximum of two vector3i.
vector3i vec3i_sign (vector3i v)
 Computes the sign per component of a vector3i (-1, 0, or 1).
vector3i vec3i_lerp (vector3i a, vector3i b, vm_float_t t)
 Linearly interpolates between two vector3i.
vector3i vec3i_clamp (vector3i v, vector3i min, vector3i max)
 Clamps a vector3i between min and max per component.
vector3i vec3i_div (vector3i a, vector3i b)
 Divides two vectors component-wise.
vector3i vec3i_add_scalar (vector3i v, vm_int_t s)
 Adds a scalar to each component.
vector3i vec3i_sub_scalar (vector3i v, vm_int_t s)
 Subtracts a scalar from each component.
vector3i vec3i_mod (vector3i a, vector3i b)
 Component-wise floor modulo of a by b.
vector3i vec3i_div_floor (vector3i a, vector3i b)
 Component-wise floored division of a by b.
vector3i vec3i_wrap (vector3i v, vector3i period)
 Wraps each component of v into [0, period).
vector3i vec3i_splat (vm_int_t s)
 Returns a vector with every component set to s.
vector3i vec3i_from_vec2i (vector2i v, vm_int_t z)
 Builds a vector3i from a vector2i and z.
vector2i vec3i_xy (vector3i v)
 Returns the x and y components as a 2D vector.
vector3 vec3i_normalize_to_vec3 (vector3i v)
 Converts to a unit-length vector3.
vm_int_t vec3i_dot (vector3i a, vector3i b)
 Computes the dot product of two vector3i.
vm_int_t vec3i_length_squared (vector3i v)
 Returns the squared Euclidean length.
vm_int_t vec3i_distance_squared (vector3i a, vector3i b)
 Returns the squared Euclidean distance between a and b.
vm_int_t vec3i_length_manhattan (vector3i v)
 Returns the Manhattan (L1) length.
vm_int_t vec3i_length_chebyshev (vector3i v)
 Returns the Chebyshev (L-inf) length.
vm_int_t vec3i_min_component (vector3i v)
 Returns the smallest component.
vm_int_t vec3i_max_component (vector3i v)
 Returns the largest component.
vm_int_t vec3i_sum (vector3i v)
 Returns the sum of all components.
vm_float_t vec3i_length (vector3i v)
 Computes the length (magnitude) of a vector3i.
vm_float_t vec3i_distance (vector3i a, vector3i b)
 Computes the Euclidean distance between two vector3i.
vm_float_t vec3i_angle (vector3i a, vector3i b)
 Computes the angle between two non-zero vector3i in radians.
bool vec3i_is_zero (vector3i v)
 Returns true if every component is zero.
vector4i vec4i_add (vector4i a, vector4i b)
 Component-wise addition of two vectors.
vector4i vec4i_sub (vector4i a, vector4i b)
 Component-wise subtraction of two vectors.
vector4i vec4i_mul_scalar (vector4i v, vm_int_t s)
 Component-wise multiplication of vector by scalar.
vector4i vec4i_div_scalar (vector4i v, vm_int_t s)
 Component-wise division of vector by scalar.
vector4i vec4i_mul (vector4i a, vector4i b)
 Component-wise multiplication of two vectors.
vector4i vec4i_neg (vector4i v)
 Negation of a vector.
vector4i vec4i_abs (vector4i v)
 Computes the absolute value per component of a vector4i.
vector4i vec4i_zero (void)
 Returns a zero-initialized vector4i.
vector4i vec4i_one (void)
 Returns a vector4i with all components set to 1.
vector4i vec4i_x_axis (vm_int_t x)
 Returns a vector4i along the x-axis.
vector4i vec4i_y_axis (vm_int_t y)
 Returns a vector4i along the y-axis.
vector4i vec4i_z_axis (vm_int_t z)
 Returns a vector4i along the z-axis.
vector4i vec4i_w_axis (vm_int_t w)
 Returns a vector4i along the w-axis.
vector4i vec4i_x_scale (vm_int_t x)
 Returns a vector4i for scaling along the x-axis.
vector4i vec4i_y_scale (vm_int_t y)
 Returns a vector4i for scaling along the y-axis.
vector4i vec4i_z_scale (vm_int_t z)
 Returns a vector4i for scaling along the z-axis.
vector4i vec4i_w_scale (vm_int_t w)
 Returns a vector4i for scaling along the w-axis.
vector4i vec4i_normalize (vector4i v)
 Normalizes a vector4i to unit length.
vector4i vec4i_min (vector4i a, vector4i b)
 Computes the component-wise minimum of two vector4i.
vector4i vec4i_max (vector4i a, vector4i b)
 Computes the component-wise maximum of two vector4i.
vector4i vec4i_sign (vector4i v)
 Computes the sign per component of a vector4i (-1, 0, or 1).
vector4i vec4i_lerp (vector4i a, vector4i b, vm_float_t t)
 Linearly interpolates between two vector4i.
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.
vector4i vec4i_div (vector4i a, vector4i b)
 Divides two vectors component-wise.
vector4i vec4i_add_scalar (vector4i v, vm_int_t s)
 Adds a scalar to each component.
vector4i vec4i_sub_scalar (vector4i v, vm_int_t s)
 Subtracts a scalar from each component.
vector4i vec4i_mod (vector4i a, vector4i b)
 Component-wise floor modulo of a by b.
vector4i vec4i_div_floor (vector4i a, vector4i b)
 Component-wise floored division of a by b.
vector4i vec4i_wrap (vector4i v, vector4i period)
 Wraps each component of v into [0, period).
vector4i vec4i_splat (vm_int_t s)
 Returns a vector with every component set to s.
vector3i vec4i_to_vec3i (vector4i v)
 Converts a vector4i to a vector3i (discards the w component).
vm_int_t vec4i_dot (vector4i a, vector4i b)
 Computes the dot product of two vector4i.
vm_int_t vec4i_length_squared (vector4i v)
 Returns the squared Euclidean length.
vm_int_t vec4i_distance_squared (vector4i a, vector4i b)
 Returns the squared Euclidean distance between a and b.
vm_int_t vec4i_length_manhattan (vector4i v)
 Returns the Manhattan (L1) length.
vm_int_t vec4i_length_chebyshev (vector4i v)
 Returns the Chebyshev (L-inf) length.
vm_int_t vec4i_min_component (vector4i v)
 Returns the smallest component.
vm_int_t vec4i_max_component (vector4i v)
 Returns the largest component.
vm_int_t vec4i_sum (vector4i v)
 Returns the sum of all components.
vm_float_t vec4i_length (vector4i v)
 Computes the length (magnitude) of a vector4i.
vm_float_t vec4i_distance (vector4i a, vector4i b)
 Computes the Euclidean distance between two vector4i.
bool vec4i_is_zero (vector4i v)
 Returns true if every component is zero.
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_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_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_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 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_neg_ptr (vector2i *res, const vector2i *v)
 Negates the components of vector v, 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.
void vec2i_normalize_ptr (vector2i *res, const vector2i *v)
 Normalizes vector v to approximate unit length (float length computation, truncated to int), storing the result in res.
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_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_sign_ptr (vector2i *res, const vector2i *v)
 Sets each component of res to the sign of the corresponding component in v (+1, -1, or 0).
void vec2i_perpendicular_ptr (vector2i *res, const vector2i *v)
 Computes the perpendicular vector to v (90 degrees counterclockwise rotation), 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_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_div_ptr (vector2i *res, const vector2i *a, const vector2i *b)
 Divides two vectors component-wise.
void vec2i_add_scalar_ptr (vector2i *res, const vector2i *v, vm_int_t s)
 Adds a scalar to each component.
void vec2i_sub_scalar_ptr (vector2i *res, const vector2i *v, vm_int_t s)
 Subtracts a scalar from each component.
void vec2i_mod_ptr (vector2i *res, const vector2i *a, const vector2i *b)
 Component-wise floor modulo of a by b.
void vec2i_div_floor_ptr (vector2i *res, const vector2i *a, const vector2i *b)
 Component-wise floored division of a by b.
void vec2i_wrap_ptr (vector2i *res, const vector2i *v, const vector2i *period)
 Wraps each component of v into [0, period).
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_normalize_to_vec2_ptr (vector2 *res, const vector2i *v)
 Converts to a unit-length vector2.
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, vm_int_t s)
 Scales a vector3i by an integer scalar.
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 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, 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.
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, vm_int_t s)
 Adds a scalar to each component.
void vec3i_sub_scalar_ptr (vector3i *res, const vector3i *v, 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, 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.
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 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 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.
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 vec4i_mul_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Multiplies the components of two vector4i and stores the result in res.
void vec4i_neg_ptr (vector4i *res, const vector4i *v)
 Negates the components of a vector4i and stores the result in res.
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 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 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.
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 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.
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,1]) and stores the result in res.
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.
void vec4i_div_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Divides two vectors component-wise.
void vec4i_add_scalar_ptr (vector4i *res, const vector4i *v, vm_int_t s)
 Adds a scalar to each component.
void vec4i_sub_scalar_ptr (vector4i *res, const vector4i *v, vm_int_t s)
 Subtracts a scalar from each component.
void vec4i_mod_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Component-wise floor modulo of a by b.
void vec4i_div_floor_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Component-wise floored division of a by b.
void vec4i_wrap_ptr (vector4i *res, const vector4i *v, const vector4i *period)
 Wraps each component of v into [0, period).
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.
matrix2 mat2_identity (void)
 Constructs the 2x2 identity matrix.
matrix2 mat2_mul (matrix2 a, matrix2 b)
 Multiplies two 2x2 matrices (a * b).
matrix2 mat2_transpose (matrix2 m)
 Computes the transpose of a 2x2 matrix.
matrix2 mat2_inverse (matrix2 m)
 Computes the inverse of a 2x2 matrix.
matrix2 mat2_rotation_z (vm_float_t degrees)
 Constructs a 2x2 Z-axis rotation matrix.
matrix2 mat2_scale (vector2 s)
 Builds a 2x2 scaling matrix from a vector2.
matrix2 mat2_from_mat3 (matrix3 m)
 Copies the upper-left 2x2 of a matrix3.
vector2 mat2_mul_vec2 (matrix2 m, vector2 v)
 Multiplies a 2x2 matrix by a vector2.
vm_float_t mat2_determinant (matrix2 m)
 Calculates the determinant of the given 2x2 matrix.
matrix3 mat3_identity (void)
 Constructs the 3x3 identity matrix.
matrix3 mat3_mul (matrix3 a, matrix3 b)
 Multiplies two 3x3 matrices.
matrix3 mat3_transpose (matrix3 m)
 Computes the transpose of a 3x3 matrix.
matrix3 mat3_inverse (matrix3 m)
 Computes the inverse of a 3x3 matrix.
matrix3 mat3_rotation_x (vm_float_t degrees)
 Builds a 3x3 rotation matrix around the X axis (degrees).
matrix3 mat3_rotation_y (vm_float_t degrees)
 Builds a 3x3 rotation matrix around the Y axis (degrees).
matrix3 mat3_rotation_z (vm_float_t degrees)
 Constructs the 3x3 rotation matrix around the Z-axis.
matrix3 mat3_translate (vector2 t)
 Builds a 3x3 2D translation matrix.
matrix3 mat3_scale (vector2 s)
 Builds a 3x3 2D scaling matrix.
matrix3 mat3_from_mat4 (matrix4 m)
 Copies the upper-left 3x3 of a matrix4.
vector3 mat3_mul_vec3 (matrix3 m, vector3 v)
 Multiplies a 3x3 matrix by a vector3.
vector2 mat3_mul_vec2 (matrix3 m, vector2 v)
 Applies a 3x3 affine transform to a vector2.
vm_float_t mat3_determinant (matrix3 m)
 Computes the determinant of a 3x3 matrix.
matrix4 mat4_identity (void)
 Constructs the 4x4 identity matrix.
matrix4 mat4_mul (matrix4 a, matrix4 b)
 Multiplies two 4x4 matrices (a * b).
matrix4 mat4_transpose (matrix4 m)
 Computes the transpose of a 4x4 matrix.
matrix4 mat4_inverse (matrix4 m)
 Computes the inverse of a 4x4 matrix.
matrix4 mat4_translate (vector3 v)
 Constructs a translation matrix from the given vector.
matrix4 mat4_scale (vector3 v)
 Constructs a scaling matrix from the given scale vector.
matrix4 mat4_rotation (vector3 axis, vm_float_t angle)
 Constructs a rotation matrix around the given axis by the specified angle (in radians).
matrix4 mat4_rotation_x (vm_float_t degrees)
 Builds a 4x4 rotation matrix around the X axis (degrees).
matrix4 mat4_rotation_y (vm_float_t degrees)
 Builds a 4x4 rotation matrix around the Y axis (degrees).
matrix4 mat4_rotation_z (vm_float_t degrees)
 Builds a 4x4 rotation matrix around the Z axis (degrees).
matrix4 mat4_trs (vector3 translation, quaternion rotation, vector3 scale)
 Builds a 4x4 TRS matrix from translation, rotation, and scale.
matrix4 mat4_from_mat3 (matrix3 m)
 Embeds a matrix3 into the upper-left of a matrix4.
matrix4 mat4_perspective (vm_float_t fov, vm_float_t aspect, vm_float_t near, vm_float_t far)
 Constructs a perspective projection matrix.
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.
matrix4 mat4_look_at (vector3 position, vector3 target, vector3 up)
 Constructs a view matrix from eye position, target, and up vector.
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.
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.
vector3 mat4_extract_translation (matrix4 m)
 Extracts the translation vector from a matrix4.
vector3 mat4_extract_scale (matrix4 m)
 Extracts the scale vector from a matrix4.
vector3 mat4_mul_vec3 (matrix4 m, vector3 v, vm_float_t w)
 Transforms a vector3 by a 4x4 matrix using homogeneous w.
vector4 mat4_mul_vec4 (matrix4 m, vector4 v)
 Multiplies a 4x4 matrix by a vector4.
quaternion mat4_extract_rotation (matrix4 m)
 Extracts the rotation quaternion from a matrix4.
vm_float_t mat4_determinant (matrix4 m)
 Calculates the determinant of the given 4x4 matrix.
void mat2_identity_ptr (matrix2 *res)
 Initializes the 2x2 matrix to identity (diagonal 1.0, others 0.0).
void mat2_mul_ptr (matrix2 *res, const matrix2 *a, const matrix2 *b)
 Multiplies two 2x2 matrices (a * b) in column-major / column-vector convention.
void mat2_transpose_ptr (matrix2 *res, const matrix2 *m)
 Computes the transpose of the input 2x2 matrix and stores in res.
void mat2_inverse_ptr (matrix2 *res, const matrix2 *m)
 Computes the inverse of the input 2x2 matrix using determinant and stores in res.
void mat2_rotation_z_ptr (matrix2 *res, vm_float_t degrees)
 Sets res to a 2x2 rotation matrix for rotation around the Z-axis.
void mat2_scale_ptr (matrix2 *res, const vector2 *s)
 Builds a 2x2 scaling matrix from a vector2.
void mat2_from_mat3_ptr (matrix2 *res, const matrix3 *m)
 Copies the upper-left 2x2 of a matrix3.
void mat2_mul_vec2_ptr (vector2 *res, const matrix2 *m, const vector2 *v)
 Multiplies a 2x2 matrix by a vector2.
void mat3_identity_ptr (matrix3 *res)
 Initializes the 3x3 matrix to identity (diagonal 1.0, others 0.0).
void mat3_mul_ptr (matrix3 *res, const matrix3 *a, const matrix3 *b)
 Multiplies two 3x3 matrices (a * b) in column-major / column-vector convention.
void mat3_transpose_ptr (matrix3 *res, const matrix3 *m)
 Computes the transpose of the input 3x3 matrix and stores in res.
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.
void mat3_rotation_x_ptr (matrix3 *res, vm_float_t degrees)
 Builds a 3x3 rotation matrix around the X axis (degrees).
void mat3_rotation_y_ptr (matrix3 *res, vm_float_t degrees)
 Builds a 3x3 rotation matrix around the Y axis (degrees).
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 mat3_translate_ptr (matrix3 *res, const vector2 *t)
 Builds a 3x3 2D translation matrix.
void mat3_scale_ptr (matrix3 *res, const vector2 *s)
 Builds a 3x3 2D scaling matrix.
void mat3_from_mat4_ptr (matrix3 *res, const matrix4 *m)
 Copies the upper-left 3x3 of a matrix4.
void mat3_mul_vec3_ptr (vector3 *res, const matrix3 *m, const vector3 *v)
 Multiplies a 3x3 matrix by a vector3.
void mat3_mul_vec2_ptr (vector2 *res, const matrix3 *m, const vector2 *v)
 Applies a 3x3 affine transform to a vector2.
void mat4_identity_ptr (matrix4 *res)
 Sets the matrix to the identity matrix.
void mat4_mul_ptr (matrix4 *res, const matrix4 *a, const matrix4 *b)
void mat4_transpose_ptr (matrix4 *res, const matrix4 *m)
void mat4_inverse_ptr (matrix4 *res, const matrix4 *m)
 Computes the inverse of a 4x4 matrix.
void mat4_translate_ptr (matrix4 *res, const vector3 *v)
 Sets the matrix to a translation matrix.
void mat4_scale_ptr (matrix4 *res, const vector3 *v)
 Sets the matrix to a scaling matrix using the provided scale vector.
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.
void mat4_rotation_x_ptr (matrix4 *res, vm_float_t degrees)
 Builds a 4x4 rotation matrix around the X axis (degrees).
void mat4_rotation_y_ptr (matrix4 *res, vm_float_t degrees)
 Builds a 4x4 rotation matrix around the Y axis (degrees).
void mat4_rotation_z_ptr (matrix4 *res, vm_float_t degrees)
 Builds a 4x4 rotation matrix around the Z axis (degrees).
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.
void mat4_from_mat3_ptr (matrix4 *res, const matrix3 *m)
 Embeds a matrix3 into the upper-left of a matrix4.
void mat4_extract_translation_ptr (vector3 *res, const matrix4 *m)
 Extracts the translation vector from a matrix4.
void mat4_extract_scale_ptr (vector3 *res, const matrix4 *m)
 Extracts the scale vector from a matrix4.
void mat4_extract_rotation_ptr (quaternion *res, const matrix4 *m)
 Extracts the rotation quaternion from a matrix4.
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.
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_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, with a specified up direction.
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 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 mat4_mul_vec4_ptr (vector4 *res, const matrix4 *m, const vector4 *v)
void mat4_mul_vec3_ptr (vector3 *res, const matrix4 *m, const vector3 *v, vm_float_t w)
matrix2i mat2i_identity (void)
 Constructs the 2x2 integer identity matrix.
matrix2i mat2i_mul (matrix2i a, matrix2i b)
 Multiplies two 2x2 integer matrices (a * b).
matrix2i mat2i_transpose (matrix2i m)
 Computes the transpose of a 2x2 integer matrix.
matrix2i mat2i_inverse (matrix2i m)
 Computes the inverse of a 2x2 integer matrix.
vector2i mat2i_mul_vec2i (matrix2i m, vector2i v)
 Multiplies a 2x2 integer matrix by a vector2i.
vm_int_t mat2i_determinant (matrix2i m)
 Calculates the determinant of the given 2x2 integer matrix.
matrix3i mat3i_identity (void)
 Constructs the 3x3 identity matrix.
matrix3i mat3i_mul (matrix3i a, matrix3i b)
 Multiplies two 3x3 integer matrices.
matrix3i mat3i_transpose (matrix3i m)
 Computes the transpose of a 3x3 integer matrix.
matrix3i mat3i_inverse (matrix3i m)
 Computes the inverse of a 3x3 integer matrix.
vector3i mat3i_mul_vec3i (matrix3i m, vector3i v)
 Multiplies a 3x3 integer matrix by a vector3i.
vector2i mat3i_mul_vec2i (matrix3i m, vector2i v)
 Applies a 3x3 integer affine transform to a vector2i.
vm_int_t mat3i_determinant (matrix3i m)
 Computes the determinant of a 3x3 integer matrix.
matrix4i mat4i_identity (void)
 Constructs the 4x4 identity matrix.
matrix4i mat4i_mul (matrix4i a, matrix4i b)
 Multiplies two 4x4 integer matrices.
matrix4i mat4i_transpose (matrix4i m)
 Computes the transpose of a 4x4 integer matrix.
matrix4i mat4i_inverse (matrix4i m)
 Computes the inverse of a 4x4 integer matrix.
vector4i mat4i_mul_vec4i (matrix4i m, vector4i v)
 Multiplies a 4x4 integer matrix by a vector4i.
vector3i mat4i_mul_vec3i (matrix4i m, vector3i v, vm_int_t w)
 Transforms a vector3i by a 4x4 integer matrix using homogeneous w.
vm_int_t mat4i_determinant (matrix4i m)
 Computes the determinant of a 4x4 integer matrix (Laplace expansion along first row).
void mat2i_identity_ptr (matrix2i *res)
 Initializes the integer 2x2 matrix to identity (diagonal 1, others 0).
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.
void mat2i_transpose_ptr (matrix2i *res, const matrix2i *m)
 Computes the transpose of the input integer 2x2 matrix and stores in res.
void mat2i_inverse_ptr (matrix2i *res, const matrix2i *m)
 Computes the inverse of the input integer 2x2 matrix and stores in res.
void mat2i_mul_vec2i_ptr (vector2i *res, const matrix2i *m, const vector2i *v)
 Multiplies a 2x2 integer matrix by a vector2i.
void mat3i_identity_ptr (matrix3i *res)
 Fills the given 3x3 integer matrix with the identity matrix.
void mat3i_mul_ptr (matrix3i *res, const matrix3i *a, const matrix3i *b)
 Multiplies two 3x3 integer matrices (standard matrix multiplication).
void mat3i_transpose_ptr (matrix3i *res, const matrix3i *m)
 Computes the transpose of a 3x3 integer matrix.
void mat3i_inverse_ptr (matrix3i *res, const matrix3i *m)
 Computes the inverse of a 3x3 integer matrix using adjugate over determinant.
void mat3i_mul_vec3i_ptr (vector3i *res, const matrix3i *m, const vector3i *v)
 Multiplies a 3x3 integer matrix by a vector3i.
void mat3i_mul_vec2i_ptr (vector2i *res, const matrix3i *m, const vector2i *v)
 Applies a 3x3 integer affine transform to a vector2i.
void mat4i_identity_ptr (matrix4i *res)
 Sets the given 4x4 integer matrix to the identity matrix.
void mat4i_mul_ptr (matrix4i *res, const matrix4i *a, const matrix4i *b)
 Performs matrix multiplication of two 4x4 matrices and stores the result.
void mat4i_transpose_ptr (matrix4i *res, const matrix4i *m)
 Transposes the given 4x4 integer matrix and stores the result in the provided matrix structure.
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.
void mat4i_mul_vec4i_ptr (vector4i *res, const matrix4i *m, const vector4i *v)
 Multiplies a 4x4 integer matrix by a vector4i.
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.
quaternion quat_identity (void)
 Constructs the identity quaternion.
quaternion quat_mul (quaternion a, quaternion b)
 Multiplies two quaternions (a * b).
quaternion quat_normalize (quaternion q)
 Normalizes a quaternion.
quaternion quat_conjugate (quaternion q)
 Returns the conjugate of a quaternion.
quaternion quat_inverse (quaternion q)
 Returns the inverse of a quaternion.
quaternion quat_from_euler (vector3 euler)
 Constructs a quaternion from Euler angles (in radians, XYZ order).
quaternion quat_from_axis_angle (vector3 axis, vm_float_t degrees)
 Builds a quaternion from an axis and an angle in degrees.
quaternion quat_from_mat3 (matrix3 m)
 Builds a quaternion from a 3x3 rotation matrix.
quaternion quat_from_mat4 (matrix4 m)
 Builds a quaternion from the rotation of a 4x4 matrix.
quaternion quat_slerp (quaternion a, quaternion b, vm_float_t t)
 Spherical-linearly interpolates from a to b by t.
quaternion quat_nlerp (quaternion a, quaternion b, vm_float_t t)
 Normalized-linearly interpolates from a to b by t.
vector3 quat_rotate_vec3 (quaternion q, vector3 v)
 Rotates a vector3 by a quaternion.
vector3 quat_to_euler (quaternion q)
 Converts a quaternion to Euler angles in degrees (XYZ).
vector3 quat_to_axis_angle (quaternion q, vm_float_t *degrees)
 Converts a quaternion to an axis and an angle in degrees.
matrix4 quat_to_mat4 (quaternion q)
 Converts a quaternion to a 4x4 rotation matrix.
matrix3 quat_to_mat3 (quaternion q)
 Converts a quaternion to a 3x3 rotation matrix.
vm_float_t quat_dot (quaternion a, quaternion b)
 Returns the dot product of two quaternions.
bool quat_near (quaternion a, quaternion b, vm_float_t eps)
 Returns true if a and b are within eps of each other.
void quat_identity_ptr (quaternion *res)
 Sets the quaternion to the identity quaternion (x=0, y=0, z=0, w=1).
void quat_mul_ptr (quaternion *res, const quaternion *a, const quaternion *b)
void quat_normalize_ptr (quaternion *res, const quaternion *q)
void quat_conjugate_ptr (quaternion *res, const quaternion *q)
 Writes the conjugate of a quaternion.
void quat_inverse_ptr (quaternion *res, const quaternion *q)
 Writes the inverse of a quaternion.
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.
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.
void quat_from_mat3_ptr (quaternion *res, const matrix3 *m)
 Builds a quaternion from a 3x3 rotation matrix.
void quat_from_mat4_ptr (quaternion *res, const matrix4 *m)
 Builds a quaternion from the rotation of a 4x4 matrix.
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 quat_nlerp_ptr (quaternion *res, const quaternion *a, const quaternion *b, vm_float_t t)
 Normalized-linearly interpolates from a to b by t.
void quat_rotate_vec3_ptr (vector3 *res, const quaternion *q, const vector3 *v)
 Rotates a vector3 by a quaternion.
void quat_to_euler_ptr (vector3 *res, const quaternion *q)
 Converts a quaternion to Euler angles in degrees (XYZ).
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.
void quat_to_mat4_ptr (matrix4 *res, const quaternion *q)
 Converts a unit quaternion to a 4x4 rotation matrix and stores in res.
void quat_to_mat3_ptr (matrix3 *res, const quaternion *q)
 Converts a quaternion to a 3x3 rotation matrix.
vector2 vec2_from (const vector2i *v)
 Converts a vector2i to a vector2.
vector2i vec2i_from (const vector2 *v)
 Converts a vector2 to a vector2i by truncation.
vector2i vec2i_from_floored (const vector2 *v)
 Converts a vector2 to a vector2i by flooring each component.
vector2i vec2i_from_rounded (const vector2 *v)
 Converts a vector2 to a vector2i by rounding each component.
vector3 vec3_from (const vector3i *v)
 Converts a vector3i to a vector3.
vector3i vec3i_from (const vector3 *v)
 Converts a vector3 to a vector3i by truncation.
vector3i vec3i_from_floored (const vector3 *v)
 Converts a vector3 to a vector3i by flooring each component.
vector3i vec3i_from_rounded (const vector3 *v)
 Converts a vector3 to a vector3i by rounding each component.
vm_float_t deg_to_rad (vm_float_t degrees)
 Converts degrees to radians.
vm_float_t rad_to_deg (vm_float_t radians)
 Converts radians to degrees.
vector2 vec2 (vm_float_t x, vm_float_t y)
 Constructs a vector2 from x and y.
void vec2_assign (vector2 *dest, const vector2 *src)
 Copies src into dest.
void vec2_assign_xy (vector2 *dest, vm_float_t x, vm_float_t y)
 Assigns x and y to dest.
void vec2_add_assign (vector2 *dest, const vector2 *src)
 Adds src to dest in place.
vector3 vec3 (vm_float_t x, vm_float_t y, vm_float_t z)
 Constructs a vector3 from x, y, and z.
void vec3_assign (vector3 *dest, const vector3 *src)
 Copies src into dest.
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.
void vec3_add_assign (vector3 *dest, const vector3 *src)
 Adds src to dest in place.
vector2i vec2i (vm_int_t x, vm_int_t y)
 Constructs a vector2i from x and y.
void vec2i_assign (vector2i *dest, const vector2i *src)
 Copies src into dest.
void vec2i_assign_xy (vector2i *dest, vm_int_t x, vm_int_t y)
 Assigns x and y to dest.
void vec2i_add_assign (vector2i *dest, const vector2i *src)
 Adds src to dest in place.
vector3i vec3i (vm_int_t x, vm_int_t y, vm_int_t z)
 Constructs a vector3i from x, y, and z.
void vec3i_assign (vector3i *dest, const vector3i *src)
 Copies src into dest.
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 vec3i_add_assign (vector3i *dest, const vector3i *src)
 Adds src to dest in place.
bool vec2_eq (vector2 a, vector2 b)
 Returns true if two vectors are equal within VECMAT_EPSILON.
bool vec3_eq (vector3 a, vector3 b)
 Returns true if two vectors are equal within VECMAT_EPSILON.
bool vec4_eq (vector4 a, vector4 b)
 Returns true if two vectors are equal within VECMAT_EPSILON.
bool vec2i_eq (vector2i a, vector2i b)
 Returns true if two vectors are exactly equal.
bool vec3i_eq (vector3i a, vector3i b)
 Returns true if two vectors are exactly equal.
bool vec4i_eq (vector4i a, vector4i b)
 Returns true if two vectors are exactly equal.
bool mat2_eq (matrix2 a, matrix2 b)
 Returns true if two matrices are equal within VECMAT_EPSILON.
bool mat3_eq (matrix3 a, matrix3 b)
 Returns true if two matrices are equal within VECMAT_EPSILON.
bool mat4_eq (matrix4 a, matrix4 b)
 Returns true if two matrices are equal within VECMAT_EPSILON.
bool mat2i_eq (matrix2i a, matrix2i b)
 Returns true if two matrices are exactly equal.
bool mat3i_eq (matrix3i a, matrix3i b)
 Returns true if two matrices are exactly equal.
bool mat4i_eq (matrix4i a, matrix4i b)
 Returns true if two matrices are exactly equal.
bool quat_eq (quaternion a, quaternion b)
 Returns true if two quaternions are equal within VECMAT_EPSILON.
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)
vm_float_t poly_ease_in (vm_float_t f, vm_float_t n)
vm_float_t poly_ease_out (vm_float_t f, vm_float_t n)
vm_float_t poly_ease_in_out (vm_float_t f, vm_float_t n)
vm_float_t quadratic_ease_out (vm_float_t f)
vm_float_t quadratic_ease_in (vm_float_t f)
vm_float_t quadratic_ease_in_out (vm_float_t f)
vm_float_t cubic_ease_out (vm_float_t f)
vm_float_t cubic_ease_in (vm_float_t f)
vm_float_t cubic_ease_in_out (vm_float_t f)
vm_float_t quartic_ease_out (vm_float_t f)
vm_float_t quartic_ease_in (vm_float_t f)
vm_float_t quartic_ease_in_out (vm_float_t f)
vm_float_t quintic_ease_out (vm_float_t f)
vm_float_t quintic_ease_in (vm_float_t f)
vm_float_t quintic_ease_in_out (vm_float_t f)
vm_float_t sine_ease_out (vm_float_t f)
vm_float_t sine_ease_in (vm_float_t f)
vm_float_t sine_ease_in_out (vm_float_t f)
vm_float_t circular_ease_out (vm_float_t f)
vm_float_t circular_ease_in (vm_float_t f)
vm_float_t circular_ease_in_out (vm_float_t f)
vm_float_t exponential_ease_out (vm_float_t f)
vm_float_t exponential_ease_in (vm_float_t f)
vm_float_t exponential_ease_in_out (vm_float_t f)
vm_float_t elastic_ease_out (vm_float_t f)
vm_float_t elastic_ease_in (vm_float_t f)
vm_float_t elastic_ease_in_out (vm_float_t f)
vm_float_t back_ease_out (vm_float_t f)
vm_float_t back_ease_in (vm_float_t f)
vm_float_t back_ease_in_out (vm_float_t f)
vm_float_t bounce_ease_out (vm_float_t f)
vm_float_t bounce_ease_in (vm_float_t f)
vm_float_t bounce_ease_in_out (vm_float_t f)

Variables

static const float VM_DEG_TO_RAD_F32 = 0.017453292519943295769236907684886f
static const float VM_RAD_TO_DEG_F32 = 57.295779513082320876798154814105f
static const double VM_DEG_TO_RAD_F64 = 0.017453292519943295769236907684886
static const double VM_RAD_TO_DEG_F64 = 57.295779513082320876798154814105
static const vm_float_t VM_DEG_TO_RAD = VM_DEG_TO_RAD_F64
static const vm_float_t VM_RAD_TO_DEG = VM_RAD_TO_DEG_F64

Macro Definition Documentation

◆ DOUBLE_EQ

#define DOUBLE_EQ ( a,
b,
eps )
Value:
(fabs((a) - (b)) < (eps))

Checks if two doubles are approximately equal within tolerance.

Parameters
aFirst value
bSecond value
epsTolerance threshold
Returns
True if values are equal within the given tolerance.

Definition at line 400 of file vecmat.h.

◆ FLOAT_EQ

#define FLOAT_EQ ( a,
b,
eps )
Value:
(fabsf((a) - (b)) < (eps))

Checks if two floats are approximately equal within tolerance.

Parameters
aFirst value
bSecond value
epsTolerance threshold
Returns
True if values are equal within the given tolerance.

Definition at line 390 of file vecmat.h.

◆ M_1_PI

#define M_1_PI   0.318309886183790671538

Definition at line 46 of file vecmat.h.

◆ M_2_PI

#define M_2_PI   0.636619772367581343076

Definition at line 47 of file vecmat.h.

◆ M_2_SQRTPI

#define M_2_SQRTPI   1.12837916709551257390

Definition at line 48 of file vecmat.h.

◆ M_E

#define M_E   2.71828182845904523536

Definition at line 38 of file vecmat.h.

◆ M_LN10

#define M_LN10   2.30258509299404568402

Definition at line 42 of file vecmat.h.

◆ M_LN2

#define M_LN2   0.693147180559945309417

Definition at line 41 of file vecmat.h.

◆ M_LOG10E

#define M_LOG10E   0.434294481903251827651

Definition at line 40 of file vecmat.h.

◆ M_LOG2E

#define M_LOG2E   1.44269504088896340736

Definition at line 39 of file vecmat.h.

◆ M_PI

#define M_PI   3.14159265358979323846

◆ M_PI_2

#define M_PI_2   1.57079632679489661923

Definition at line 44 of file vecmat.h.

Referenced by quat_to_euler_ptr().

◆ M_PI_4

#define M_PI_4   0.785398163397448309616

Definition at line 45 of file vecmat.h.

◆ M_SQRT1_2

#define M_SQRT1_2   0.707106781186547524401

Definition at line 50 of file vecmat.h.

◆ M_SQRT2

#define M_SQRT2   1.41421356237309504880

Definition at line 49 of file vecmat.h.

◆ VEC_API

#define VEC_API

Definition at line 30 of file vecmat.h.

◆ VEC_INT_MAX

#define VEC_INT_MAX   INT8_MAX

Definition at line 104 of file vecmat.h.

◆ VEC_INT_MIN

#define VEC_INT_MIN   INT8_MIN

Definition at line 105 of file vecmat.h.

◆ VECMAT_ACOS

#define VECMAT_ACOS ( x)
Value:
acos((x))

Definition at line 419 of file vecmat.h.

Referenced by quat_slerp_ptr(), quat_to_axis_angle_ptr(), vec2_angle(), vec3_angle(), and vec3i_angle().

◆ VECMAT_ASIN

#define VECMAT_ASIN ( x)
Value:
asin((x))

Definition at line 418 of file vecmat.h.

Referenced by quat_to_euler_ptr().

◆ VECMAT_ATAN

#define VECMAT_ATAN ( x)
Value:
atan((x))

Definition at line 420 of file vecmat.h.

◆ VECMAT_ATAN2

#define VECMAT_ATAN2 ( y,
x )
Value:
atan2((y), (x))

Definition at line 421 of file vecmat.h.

Referenced by quat_to_euler_ptr(), vec2_heading(), vec2i_angle(), and vec3_signed_angle().

◆ VECMAT_CEIL

#define VECMAT_CEIL ( x)
Value:
ceil((x))

Definition at line 425 of file vecmat.h.

Referenced by vec2_ceil_ptr(), vec3_ceil_ptr(), and vec4_ceil_ptr_scalar().

◆ VECMAT_COPYSIGN

#define VECMAT_COPYSIGN ( x,
y )
Value:
copysign((x), (y))

Definition at line 428 of file vecmat.h.

Referenced by quat_to_euler_ptr(), and vec2_sign_ptr().

◆ VECMAT_COS

◆ VECMAT_DBL_MAX

#define VECMAT_DBL_MAX   __DBL_MAX__

Definition at line 59 of file vecmat.h.

◆ VECMAT_DBL_MIN

#define VECMAT_DBL_MIN   __DBL_MIN__

Definition at line 62 of file vecmat.h.

◆ VECMAT_EPS_F32

#define VECMAT_EPS_F32   1e-6f

Definition at line 373 of file vecmat.h.

◆ VECMAT_EPS_F64

#define VECMAT_EPS_F64   1e-12

Definition at line 374 of file vecmat.h.

◆ VECMAT_EPSILON

◆ VECMAT_EQ

#define VECMAT_EQ ( a,
b,
eps )
Value:
DOUBLE_EQ((a), (b), (eps))
#define DOUBLE_EQ(a, b, eps)
Checks if two doubles are approximately equal within tolerance.
Definition vecmat.h:400

Definition at line 403 of file vecmat.h.

◆ VECMAT_FABS

◆ VECMAT_FLOOR

#define VECMAT_FLOOR ( x)

◆ VECMAT_FLT_MAX

#define VECMAT_FLT_MAX   __FLT_MAX__

Definition at line 58 of file vecmat.h.

◆ VECMAT_FLT_MIN

#define VECMAT_FLT_MIN   __FLT_MIN__

Definition at line 61 of file vecmat.h.

◆ VECMAT_FMAX

◆ VECMAT_FMIN

◆ VECMAT_MAT2_SIZE

#define VECMAT_MAT2_SIZE   4

Definition at line 68 of file vecmat.h.

◆ VECMAT_MAT3_SIZE

#define VECMAT_MAT3_SIZE   9

Definition at line 69 of file vecmat.h.

◆ VECMAT_MAT4_SIZE

#define VECMAT_MAT4_SIZE   16

Definition at line 70 of file vecmat.h.

◆ VECMAT_POW

◆ VECMAT_QUAT_SIZE

#define VECMAT_QUAT_SIZE   4

Definition at line 72 of file vecmat.h.

◆ VECMAT_ROUND

#define VECMAT_ROUND ( x)
Value:
round((x))

Definition at line 426 of file vecmat.h.

Referenced by vec2_round_ptr(), vec2i_from_rounded(), vec3_round_ptr(), vec3i_from_rounded(), and vec4_round_ptr_scalar().

◆ VECMAT_SIN

◆ VECMAT_SQRT

◆ VECMAT_STR

#define VECMAT_STR ( x)
Value:
#define VECMAT_STR_HELPER(x)
Definition vecmat.h:17

Definition at line 18 of file vecmat.h.

◆ VECMAT_STR_HELPER

#define VECMAT_STR_HELPER ( x)
Value:
#x

Definition at line 17 of file vecmat.h.

◆ VECMAT_TAN

#define VECMAT_TAN ( x)
Value:
tan((x))

Definition at line 417 of file vecmat.h.

Referenced by mat4_perspective_fov_ptr(), mat4_perspective_infinite_ptr(), and mat4_perspective_ptr().

◆ VECMAT_VEC2_SIZE

#define VECMAT_VEC2_SIZE   2

Definition at line 64 of file vecmat.h.

◆ VECMAT_VEC3_SIZE

#define VECMAT_VEC3_SIZE   3

Definition at line 65 of file vecmat.h.

◆ VECMAT_VEC4_SIZE

#define VECMAT_VEC4_SIZE   4

Definition at line 66 of file vecmat.h.

◆ VECMAT_VERSION

#define VECMAT_VERSION
Value:
#define VECMAT_STR(x)
Definition vecmat.h:18
#define VECMAT_VERSION_PATCH
Definition vecmat.h:15
#define VECMAT_VERSION_MINOR
Definition vecmat.h:14
#define VECMAT_VERSION_MAJOR
Definition vecmat.h:13

Definition at line 19 of file vecmat.h.

◆ VECMAT_VERSION_MAJOR

#define VECMAT_VERSION_MAJOR   0

Definition at line 13 of file vecmat.h.

◆ VECMAT_VERSION_MINOR

#define VECMAT_VERSION_MINOR   2

Definition at line 14 of file vecmat.h.

◆ VECMAT_VERSION_PATCH

#define VECMAT_VERSION_PATCH   3

Definition at line 15 of file vecmat.h.

◆ VM_F

#define VM_F ( x)
Value:
x

Definition at line 93 of file vecmat.h.

Typedef Documentation

◆ vm_cpu_features_t

typedef uint32_t vm_cpu_features_t

Definition at line 452 of file vecmat.h.

◆ vm_float_t

typedef double vm_float_t

Definition at line 79 of file vecmat.h.

◆ vm_int_t

typedef int8_t vm_int_t

Definition at line 103 of file vecmat.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VM_CPU_SCALAR 
VM_CPU_AVX2 
VM_CPU_SVE 
VM_CPU_AVX512 
VM_CPU_SVE2 
VM_CPU_AVX 

Definition at line 454 of file vecmat.h.

Function Documentation

◆ back_ease_in()

vm_float_t back_ease_in ( vm_float_t f)

Definition at line 164 of file easing.c.

◆ back_ease_in_out()

vm_float_t back_ease_in_out ( vm_float_t f)

Definition at line 169 of file easing.c.

References VECMAT_POW.

◆ back_ease_out()

vm_float_t back_ease_out ( vm_float_t f)

Definition at line 159 of file easing.c.

References VECMAT_POW.

◆ bounce_ease_in()

vm_float_t bounce_ease_in ( vm_float_t f)

Definition at line 195 of file easing.c.

References bounce_ease_out().

◆ bounce_ease_in_out()

vm_float_t bounce_ease_in_out ( vm_float_t f)

Definition at line 200 of file easing.c.

References bounce_ease_out().

◆ bounce_ease_out()

vm_float_t bounce_ease_out ( vm_float_t f)

Definition at line 177 of file easing.c.

Referenced by bounce_ease_in(), and bounce_ease_in_out().

◆ circular_ease_in()

vm_float_t circular_ease_in ( vm_float_t f)

Definition at line 112 of file easing.c.

References VECMAT_SQRT.

◆ circular_ease_in_out()

vm_float_t circular_ease_in_out ( vm_float_t f)

Definition at line 117 of file easing.c.

References VECMAT_SQRT.

◆ circular_ease_out()

vm_float_t circular_ease_out ( vm_float_t f)

Definition at line 107 of file easing.c.

References VECMAT_SQRT.

◆ cubic_ease_in()

vm_float_t cubic_ease_in ( vm_float_t f)

Definition at line 52 of file easing.c.

References poly_ease_in().

◆ cubic_ease_in_out()

vm_float_t cubic_ease_in_out ( vm_float_t f)

Definition at line 57 of file easing.c.

References poly_ease_in_out().

◆ cubic_ease_out()

vm_float_t cubic_ease_out ( vm_float_t f)

Definition at line 47 of file easing.c.

References poly_ease_out().

◆ deg_to_rad()

vm_float_t deg_to_rad ( const vm_float_t degrees)

◆ elastic_ease_in()

vm_float_t elastic_ease_in ( vm_float_t f)

Definition at line 145 of file easing.c.

References elastic_oscillation().

◆ elastic_ease_in_out()

vm_float_t elastic_ease_in_out ( vm_float_t f)

Definition at line 151 of file easing.c.

References elastic_oscillation().

◆ elastic_ease_out()

vm_float_t elastic_ease_out ( vm_float_t f)

Definition at line 139 of file easing.c.

References elastic_oscillation().

◆ elastic_oscillation()

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 )

Definition at line 7 of file easing.c.

References M_PI, VECMAT_POW, and VECMAT_SIN.

Referenced by elastic_ease_in(), elastic_ease_in_out(), and elastic_ease_out().

◆ exponential_ease_in()

vm_float_t exponential_ease_in ( vm_float_t f)

Definition at line 128 of file easing.c.

References VECMAT_POW.

◆ exponential_ease_in_out()

vm_float_t exponential_ease_in_out ( vm_float_t f)

Definition at line 133 of file easing.c.

References VECMAT_POW.

◆ exponential_ease_out()

vm_float_t exponential_ease_out ( vm_float_t f)

Definition at line 123 of file easing.c.

References VECMAT_POW.

◆ mat2_determinant()

vm_float_t mat2_determinant ( const matrix2 m)

Calculates the determinant of the given 2x2 matrix.

Parameters
mThe matrix.
Returns
The determinant value (m.v[0]*m.v[3] - m.v[1]*m.v[2]).

Definition at line 88 of file matrix2.c.

References matrix2::v.

Referenced by mat2_inverse_ptr().

◆ mat2_eq()

bool mat2_eq ( const matrix2 a,
const matrix2 b )

Returns true if two matrices are equal within VECMAT_EPSILON.

Parameters
aFirst matrix.
bSecond matrix.
Returns
True if a and b are approximately equal.

Definition at line 115 of file vecmat.c.

References matrix2::v, VECMAT_EPSILON, and VECMAT_FABS.

◆ mat2_from_mat3()

matrix2 mat2_from_mat3 ( const matrix3 m)

Copies the upper-left 2x2 of a matrix3.

See mat2_from_mat3_ptr instead.

Parameters
mInput matrix.
Returns
The resulting matrix2.

Definition at line 132 of file matrix2.c.

References mat2_from_mat3_ptr().

◆ mat2_from_mat3_ptr()

void mat2_from_mat3_ptr ( matrix2 * res,
const matrix3 * m )

Copies the upper-left 2x2 of a matrix3.

Parameters
resOutput value.
mInput matrix.

Definition at line 128 of file matrix2_ptr.c.

References matrix3::m11, matrix3::m12, matrix3::m21, and matrix3::m22.

Referenced by mat2_from_mat3().

◆ mat2_identity()

matrix2 mat2_identity ( void )

Constructs the 2x2 identity matrix.

See mat2_identity_ptr instead.

Returns
The identity matrix2.

Definition at line 14 of file matrix2.c.

References mat2_identity_ptr().

◆ mat2_identity_ptr()

void mat2_identity_ptr ( matrix2 * res)

Initializes the 2x2 matrix to identity (diagonal 1.0, others 0.0).

Parameters
resPointer to the output matrix2.

Definition at line 12 of file matrix2_ptr.c.

References matrix2::v.

Referenced by mat2_identity(), and mat2_inverse_ptr().

◆ mat2_inverse()

matrix2 mat2_inverse ( const matrix2 m)

Computes the inverse of a 2x2 matrix.

See mat2_inverse_ptr instead.

Parameters
mThe input matrix.
Returns
The inverse matrix2.

Definition at line 60 of file matrix2.c.

References mat2_inverse_ptr().

◆ mat2_inverse_ptr()

void mat2_inverse_ptr ( matrix2 * res,
const matrix2 * m )

Computes the inverse of the input 2x2 matrix using determinant and stores in res.

If the determinant is zero, sets res to identity matrix.

Parameters
resPointer to the output matrix2.
mPointer to the input matrix.

Definition at line 60 of file matrix2_ptr.c.

References mat2_determinant(), mat2_identity_ptr(), and matrix2::v.

Referenced by mat2_inverse().

◆ mat2_mul()

matrix2 mat2_mul ( const matrix2 a,
const matrix2 b )

Multiplies two 2x2 matrices (a * b).

See mat2_mul_ptr instead.

Parameters
aThe first matrix.
bThe second matrix.
Returns
The resulting product matrix2.

Definition at line 30 of file matrix2.c.

References mat2_mul_ptr().

◆ mat2_mul_ptr()

void mat2_mul_ptr ( matrix2 * res,
const matrix2 * a,
const matrix2 * b )

Multiplies two 2x2 matrices (a * b) in column-major / column-vector convention.

Parameters
resPointer to the output matrix2.
aPointer to the first matrix.
bPointer to the second matrix.

Definition at line 26 of file matrix2_ptr.c.

References matrix2::m11, matrix2::m12, matrix2::m21, and matrix2::m22.

Referenced by mat2_mul().

◆ mat2_mul_vec2()

vector2 mat2_mul_vec2 ( const matrix2 m,
const vector2 v )

Multiplies a 2x2 matrix by a vector2.

See mat2_mul_vec2_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector2.

Definition at line 102 of file matrix2.c.

References mat2_mul_vec2_ptr().

◆ mat2_mul_vec2_ptr()

void mat2_mul_vec2_ptr ( vector2 * res,
const matrix2 * m,
const vector2 * v )

Multiplies a 2x2 matrix by a vector2.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 81 of file matrix2_ptr.c.

References matrix2::m11, matrix2::m12, matrix2::m21, matrix2::m22, vector2::x, and vector2::y.

Referenced by mat2_mul_vec2().

◆ mat2_rotation_z()

matrix2 mat2_rotation_z ( const vm_float_t degrees)

Constructs a 2x2 Z-axis rotation matrix.

See mat2_rotation_z_ptr instead.

Parameters
degreesRotation angle in degrees.
Returns
The rotation matrix2.

Definition at line 75 of file matrix2.c.

References mat2_rotation_z_ptr().

◆ mat2_rotation_z_ptr()

void mat2_rotation_z_ptr ( matrix2 * res,
const vm_float_t degrees )

Sets res to a 2x2 rotation matrix for rotation around the Z-axis.

Converts degrees to radians; positive is counter-clockwise.

Parameters
resPointer to the output matrix2.
degreesRotation angle in degrees.

Definition at line 97 of file matrix2_ptr.c.

References deg_to_rad(), VECMAT_COS, and VECMAT_SIN.

Referenced by mat2_rotation_z().

◆ mat2_scale()

matrix2 mat2_scale ( const vector2 s)

Builds a 2x2 scaling matrix from a vector2.

See mat2_scale_ptr instead.

Parameters
sScale vector.
Returns
The resulting matrix2.

Definition at line 117 of file matrix2.c.

References mat2_scale_ptr().

◆ mat2_scale_ptr()

void mat2_scale_ptr ( matrix2 * res,
const vector2 * s )

Builds a 2x2 scaling matrix from a vector2.

Parameters
resOutput value.
sScale vector.

Definition at line 114 of file matrix2_ptr.c.

References vector2::x, and vector2::y.

Referenced by mat2_scale().

◆ mat2_transpose()

matrix2 mat2_transpose ( const matrix2 m)

Computes the transpose of a 2x2 matrix.

See mat2_transpose_ptr instead.

Parameters
mThe input matrix.
Returns
The transposed matrix2.

Definition at line 45 of file matrix2.c.

References mat2_transpose_ptr().

◆ mat2_transpose_ptr()

void mat2_transpose_ptr ( matrix2 * res,
const matrix2 * m )

Computes the transpose of the input 2x2 matrix and stores in res.

Parameters
resPointer to the output matrix2.
mPointer to the input matrix.

Definition at line 43 of file matrix2_ptr.c.

References matrix2::v.

Referenced by mat2_transpose().

◆ mat2i_determinant()

vm_int_t mat2i_determinant ( const matrix2i m)

Calculates the determinant of the given 2x2 integer matrix.

Parameters
mThe matrix.
Returns
The determinant value (m.v[0]*m.v[3] - m.v[1]*m.v[2]).

Definition at line 73 of file matrix2i.c.

References matrix2i::v.

Referenced by mat2i_inverse_ptr().

◆ mat2i_eq()

bool mat2i_eq ( const matrix2i a,
const matrix2i b )

Returns true if two matrices are exactly equal.

Parameters
aFirst matrix.
bSecond matrix.
Returns
True if a and b are equal.

Definition at line 160 of file vecmat.c.

References matrix2i::v.

◆ mat2i_identity()

matrix2i mat2i_identity ( void )

Constructs the 2x2 integer identity matrix.

See mat2i_identity_ptr instead.

Returns
The identity matrix2i.

Definition at line 14 of file matrix2i.c.

References mat2i_identity_ptr().

◆ mat2i_identity_ptr()

void mat2i_identity_ptr ( matrix2i * res)

Initializes the integer 2x2 matrix to identity (diagonal 1, others 0).

Parameters
resPointer to the output matrix2i.

Definition at line 12 of file matrix2i_ptr.c.

References matrix2i::v.

Referenced by mat2i_identity(), and mat2i_inverse_ptr().

◆ mat2i_inverse()

matrix2i mat2i_inverse ( const matrix2i m)

Computes the inverse of a 2x2 integer matrix.

See mat2i_inverse_ptr instead.

Parameters
mThe input matrix.
Returns
The inverse matrix2i.

Definition at line 60 of file matrix2i.c.

References mat2i_inverse_ptr().

◆ mat2i_inverse_ptr()

void mat2i_inverse_ptr ( matrix2i * res,
const matrix2i * m )

Computes the inverse of the input integer 2x2 matrix and stores in res.

Uses double precision for inversion, truncates to int; sets to identity if det=0.

Parameters
resPointer to the output matrix2i.
mPointer to the input matrix.

Definition at line 60 of file matrix2i_ptr.c.

References mat2i_determinant(), mat2i_identity_ptr(), and matrix2i::v.

Referenced by mat2i_inverse().

◆ mat2i_mul()

matrix2i mat2i_mul ( const matrix2i a,
const matrix2i b )

Multiplies two 2x2 integer matrices (a * b).

See mat2i_mul_ptr instead.

Parameters
aThe first matrix.
bThe second matrix.
Returns
The resulting product matrix2i.

Definition at line 30 of file matrix2i.c.

References mat2i_mul_ptr().

◆ mat2i_mul_ptr()

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.

Parameters
resPointer to the output matrix2i.
aPointer to the first matrix.
bPointer to the second matrix.

Definition at line 27 of file matrix2i_ptr.c.

References matrix2i::m11, matrix2i::m12, matrix2i::m21, and matrix2i::m22.

Referenced by mat2i_mul().

◆ mat2i_mul_vec2i()

vector2i mat2i_mul_vec2i ( const matrix2i m,
const vector2i v )

Multiplies a 2x2 integer matrix by a vector2i.

See mat2i_mul_vec2i_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector2i.

Definition at line 87 of file matrix2i.c.

References mat2i_mul_vec2i_ptr().

◆ mat2i_mul_vec2i_ptr()

void mat2i_mul_vec2i_ptr ( vector2i * res,
const matrix2i * m,
const vector2i * v )

Multiplies a 2x2 integer matrix by a vector2i.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 81 of file matrix2i_ptr.c.

References matrix2i::m11, matrix2i::m12, matrix2i::m21, matrix2i::m22, vector2i::x, and vector2i::y.

Referenced by mat2i_mul_vec2i().

◆ mat2i_transpose()

matrix2i mat2i_transpose ( const matrix2i m)

Computes the transpose of a 2x2 integer matrix.

See mat2i_transpose_ptr instead.

Parameters
mThe input matrix.
Returns
The transposed matrix2i.

Definition at line 45 of file matrix2i.c.

References mat2i_transpose_ptr().

◆ mat2i_transpose_ptr()

void mat2i_transpose_ptr ( matrix2i * res,
const matrix2i * m )

Computes the transpose of the input integer 2x2 matrix and stores in res.

Parameters
resPointer to the output matrix2i.
mPointer to the input matrix.

Definition at line 44 of file matrix2i_ptr.c.

References matrix2i::v.

Referenced by mat2i_transpose().

◆ mat3_determinant()

vm_float_t mat3_determinant ( const matrix3 m)

Computes the determinant of a 3x3 matrix.

Parameters
mThe input matrix.
Returns
The determinant value.

Definition at line 88 of file matrix3.c.

References matrix3::v.

◆ mat3_eq()

bool mat3_eq ( const matrix3 a,
const matrix3 b )

Returns true if two matrices are equal within VECMAT_EPSILON.

Parameters
aFirst matrix.
bSecond matrix.
Returns
True if a and b are approximately equal.

Definition at line 130 of file vecmat.c.

References matrix3::v, VECMAT_EPSILON, and VECMAT_FABS.

◆ mat3_from_mat4()

matrix3 mat3_from_mat4 ( const matrix4 m)

Copies the upper-left 3x3 of a matrix4.

See mat3_from_mat4_ptr instead.

Parameters
mInput matrix.
Returns
The resulting matrix3.

Definition at line 195 of file matrix3.c.

References mat3_from_mat4_ptr().

◆ mat3_from_mat4_ptr()

void mat3_from_mat4_ptr ( matrix3 * res,
const matrix4 * m )

Copies the upper-left 3x3 of a matrix4.

Parameters
resOutput value.
mInput matrix.

Definition at line 199 of file matrix3_ptr.c.

References matrix3::m11, matrix4::m11, matrix3::m12, matrix4::m12, matrix3::m13, matrix4::m13, matrix3::m21, matrix4::m21, matrix3::m22, matrix4::m22, matrix3::m23, matrix4::m23, matrix3::m31, matrix4::m31, matrix3::m32, matrix4::m32, matrix3::m33, and matrix4::m33.

Referenced by mat3_from_mat4().

◆ mat3_identity()

matrix3 mat3_identity ( void )

Constructs the 3x3 identity matrix.

See mat3_identity_ptr instead.

Returns
The identity matrix3.

Definition at line 14 of file matrix3.c.

References mat3_identity_ptr().

◆ mat3_identity_ptr()

void mat3_identity_ptr ( matrix3 * res)

Initializes the 3x3 matrix to identity (diagonal 1.0, others 0.0).

Parameters
resPointer to the output matrix3.

Definition at line 12 of file matrix3_ptr.c.

References matrix3::v.

Referenced by mat3_identity(), mat3_inverse_ptr(), mat3_scale_ptr(), and mat3_translate_ptr().

◆ mat3_inverse()

matrix3 mat3_inverse ( const matrix3 m)

Computes the inverse of a 3x3 matrix.

See mat3_inverse_ptr instead.

Parameters
mThe input matrix.
Returns
The inverse matrix.

Definition at line 60 of file matrix3.c.

References mat3_inverse_ptr().

◆ mat3_inverse_ptr()

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.

If the determinant is zero, sets res to identity.

Parameters
resPointer to the output matrix3.
mPointer to the input matrix.

Definition at line 78 of file matrix3_ptr.c.

References mat3_identity_ptr(), and matrix3::v.

Referenced by mat3_inverse().

◆ mat3_mul()

matrix3 mat3_mul ( const matrix3 a,
const matrix3 b )

Multiplies two 3x3 matrices.

See mat3_mul_ptr instead.

Parameters
aThe first matrix.
bThe second matrix.
Returns
The product matrix.

Definition at line 30 of file matrix3.c.

References mat3_mul_ptr().

◆ mat3_mul_ptr()

void mat3_mul_ptr ( matrix3 * res,
const matrix3 * a,
const matrix3 * b )

Multiplies two 3x3 matrices (a * b) in column-major / column-vector convention.

Accumulates into a temporary matrix.

Parameters
resPointer to the output matrix3.
aPointer to the first matrix.
bPointer to the second matrix.

Definition at line 34 of file matrix3_ptr.c.

References matrix3::m11, matrix3::m12, matrix3::m13, matrix3::m21, matrix3::m22, matrix3::m23, matrix3::m31, matrix3::m32, and matrix3::m33.

Referenced by mat3_mul().

◆ mat3_mul_vec2()

vector2 mat3_mul_vec2 ( const matrix3 m,
const vector2 v )

Applies a 3x3 affine transform to a vector2.

See mat3_mul_vec2_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector2.

Definition at line 120 of file matrix3.c.

References mat3_mul_vec2_ptr().

◆ mat3_mul_vec2_ptr()

void mat3_mul_vec2_ptr ( vector2 * res,
const matrix3 * m,
const vector2 * v )

Applies a 3x3 affine transform to a vector2.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 230 of file matrix3_ptr.c.

References matrix3::m11, matrix3::m12, matrix3::m13, matrix3::m21, matrix3::m22, matrix3::m23, vector2::x, and vector2::y.

Referenced by mat3_mul_vec2().

◆ mat3_mul_vec3()

vector3 mat3_mul_vec3 ( const matrix3 m,
const vector3 v )

Multiplies a 3x3 matrix by a vector3.

See mat3_mul_vec3_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector3.

Definition at line 104 of file matrix3.c.

References mat3_mul_vec3_ptr().

◆ mat3_mul_vec3_ptr()

void mat3_mul_vec3_ptr ( vector3 * res,
const matrix3 * m,
const vector3 * v )

Multiplies a 3x3 matrix by a vector3.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 213 of file matrix3_ptr.c.

References matrix3::m11, matrix3::m12, matrix3::m13, matrix3::m21, matrix3::m22, matrix3::m23, matrix3::m31, matrix3::m32, matrix3::m33, vector3::x, vector3::y, and vector3::z.

Referenced by mat3_mul_vec3().

◆ mat3_rotation_x()

matrix3 mat3_rotation_x ( const vm_float_t degrees)

Builds a 3x3 rotation matrix around the X axis (degrees).

See mat3_rotation_x_ptr instead.

Parameters
degreesRotation angle in degrees.
Returns
The resulting matrix3.

Definition at line 135 of file matrix3.c.

References mat3_rotation_x_ptr().

◆ mat3_rotation_x_ptr()

void mat3_rotation_x_ptr ( matrix3 * res,
const vm_float_t degrees )

Builds a 3x3 rotation matrix around the X axis (degrees).

Parameters
resOutput value.
degreesRotation angle in degrees.

Definition at line 137 of file matrix3_ptr.c.

References deg_to_rad(), VECMAT_COS, and VECMAT_SIN.

Referenced by mat3_rotation_x().

◆ mat3_rotation_y()

matrix3 mat3_rotation_y ( const vm_float_t degrees)

Builds a 3x3 rotation matrix around the Y axis (degrees).

See mat3_rotation_y_ptr instead.

Parameters
degreesRotation angle in degrees.
Returns
The resulting matrix3.

Definition at line 150 of file matrix3.c.

References mat3_rotation_y_ptr().

◆ mat3_rotation_y_ptr()

void mat3_rotation_y_ptr ( matrix3 * res,
const vm_float_t degrees )

Builds a 3x3 rotation matrix around the Y axis (degrees).

Parameters
resOutput value.
degreesRotation angle in degrees.

Definition at line 155 of file matrix3_ptr.c.

References deg_to_rad(), VECMAT_COS, and VECMAT_SIN.

Referenced by mat3_rotation_y().

◆ mat3_rotation_z()

matrix3 mat3_rotation_z ( const vm_float_t degrees)

Constructs the 3x3 rotation matrix around the Z-axis.

See mat3_rotation_z_ptr instead.

Parameters
degreesThe rotation angle in degrees.
Returns
The rotation matrix3.

Definition at line 75 of file matrix3.c.

References mat3_rotation_z_ptr().

◆ mat3_rotation_z_ptr()

void mat3_rotation_z_ptr ( matrix3 * res,
const vm_float_t degrees )

Sets the 3x3 matrix to a rotation around the Z-axis by the given angle in degrees.

Parameters
resPointer to the output matrix3.
degreesRotation angle in degrees.

Definition at line 112 of file matrix3_ptr.c.

References matrix3::m11, matrix3::m12, matrix3::m13, matrix3::m21, matrix3::m22, matrix3::m23, matrix3::m31, matrix3::m32, matrix3::m33, M_PI, VECMAT_COS, and VECMAT_SIN.

Referenced by mat3_rotation_z().

◆ mat3_scale()

matrix3 mat3_scale ( const vector2 s)

Builds a 3x3 2D scaling matrix.

See mat3_scale_ptr instead.

Parameters
sScale vector.
Returns
The resulting matrix3.

Definition at line 180 of file matrix3.c.

References mat3_scale_ptr().

◆ mat3_scale_ptr()

void mat3_scale_ptr ( matrix3 * res,
const vector2 * s )

Builds a 3x3 2D scaling matrix.

Parameters
resOutput value.
sScale vector.

Definition at line 186 of file matrix3_ptr.c.

References matrix3::m11, matrix3::m22, mat3_identity_ptr(), vector2::x, and vector2::y.

Referenced by mat3_scale().

◆ mat3_translate()

matrix3 mat3_translate ( const vector2 t)

Builds a 3x3 2D translation matrix.

See mat3_translate_ptr instead.

Parameters
tTranslation vector.
Returns
The resulting matrix3.

Definition at line 165 of file matrix3.c.

References mat3_translate_ptr().

◆ mat3_translate_ptr()

void mat3_translate_ptr ( matrix3 * res,
const vector2 * t )

Builds a 3x3 2D translation matrix.

Parameters
resOutput value.
tTranslation vector.

Definition at line 173 of file matrix3_ptr.c.

References matrix3::m13, matrix3::m23, mat3_identity_ptr(), vector2::x, and vector2::y.

Referenced by mat3_translate().

◆ mat3_transpose()

matrix3 mat3_transpose ( const matrix3 m)

Computes the transpose of a 3x3 matrix.

See mat3_transpose_ptr instead.

Parameters
mThe input matrix.
Returns
The transposed matrix.

Definition at line 45 of file matrix3.c.

References mat3_transpose_ptr().

◆ mat3_transpose_ptr()

void mat3_transpose_ptr ( matrix3 * res,
const matrix3 * m )

Computes the transpose of the input 3x3 matrix and stores in res.

Parameters
resPointer to the output matrix3.
mPointer to the input matrix.

Definition at line 58 of file matrix3_ptr.c.

References matrix3::v.

Referenced by mat3_transpose().

◆ mat3i_determinant()

vm_int_t mat3i_determinant ( const matrix3i m)

Computes the determinant of a 3x3 integer matrix.

Parameters
mThe input matrix.
Returns
The determinant value.

Definition at line 58 of file matrix3i.c.

References matrix3i::v.

Referenced by mat3i_inverse_ptr().

◆ mat3i_eq()

bool mat3i_eq ( const matrix3i a,
const matrix3i b )

Returns true if two matrices are exactly equal.

Parameters
aFirst matrix.
bSecond matrix.
Returns
True if a and b are equal.

Definition at line 175 of file vecmat.c.

References matrix3i::v.

◆ mat3i_identity()

matrix3i mat3i_identity ( void )

Constructs the 3x3 identity matrix.

See mat3i_identity_ptr instead.

Returns
The identity matrix3i.

Definition at line 14 of file matrix3i.c.

References mat3i_identity_ptr().

◆ mat3i_identity_ptr()

void mat3i_identity_ptr ( matrix3i * res)

Fills the given 3x3 integer matrix with the identity matrix.

Parameters
resPointer to the result matrix.

Definition at line 12 of file matrix3i_ptr.c.

References matrix3i::m11, matrix3i::m12, matrix3i::m13, matrix3i::m21, matrix3i::m22, matrix3i::m23, matrix3i::m31, matrix3i::m32, and matrix3i::m33.

Referenced by mat3i_identity(), and mat3i_inverse_ptr().

◆ mat3i_inverse()

matrix3i mat3i_inverse ( const matrix3i m)

Computes the inverse of a 3x3 integer matrix.

See mat3i_inverse_ptr instead.

Parameters
mThe input matrix.
Returns
The inverse matrix.

Definition at line 73 of file matrix3i.c.

References mat3i_inverse_ptr().

◆ mat3i_inverse_ptr()

void mat3i_inverse_ptr ( matrix3i * res,
const matrix3i * m )

Computes the inverse of a 3x3 integer matrix using adjugate over determinant.

If the determinant is zero (singular), sets the result to the identity matrix.

Parameters
resPointer to the result matrix.
mPointer to the input matrix.

Definition at line 67 of file matrix3i_ptr.c.

References matrix3i::m11, matrix3i::m12, matrix3i::m13, matrix3i::m21, matrix3i::m22, matrix3i::m23, matrix3i::m31, matrix3i::m32, matrix3i::m33, mat3i_determinant(), and mat3i_identity_ptr().

Referenced by mat3i_inverse().

◆ mat3i_mul()

matrix3i mat3i_mul ( const matrix3i a,
const matrix3i b )

Multiplies two 3x3 integer matrices.

See mat3i_mul_ptr instead.

Parameters
aThe first matrix.
bThe second matrix.
Returns
The product matrix.

Definition at line 30 of file matrix3i.c.

References mat3i_mul_ptr().

◆ mat3i_mul_ptr()

void mat3i_mul_ptr ( matrix3i * res,
const matrix3i * a,
const matrix3i * b )

Multiplies two 3x3 integer matrices (standard matrix multiplication).

Parameters
resPointer to the result matrix.
aPointer to the first input matrix.
bPointer to the second input matrix.

Definition at line 26 of file matrix3i_ptr.c.

References matrix3i::m11, matrix3i::m12, matrix3i::m13, matrix3i::m21, matrix3i::m22, matrix3i::m23, matrix3i::m31, matrix3i::m32, and matrix3i::m33.

Referenced by mat3i_mul().

◆ mat3i_mul_vec2i()

vector2i mat3i_mul_vec2i ( const matrix3i m,
const vector2i v )

Applies a 3x3 integer affine transform to a vector2i.

See mat3i_mul_vec2i_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector2i.

Definition at line 105 of file matrix3i.c.

References mat3i_mul_vec2i_ptr().

◆ mat3i_mul_vec2i_ptr()

void mat3i_mul_vec2i_ptr ( vector2i * res,
const matrix3i * m,
const vector2i * v )

Applies a 3x3 integer affine transform to a vector2i.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 115 of file matrix3i_ptr.c.

References matrix3i::m11, matrix3i::m12, matrix3i::m13, matrix3i::m21, matrix3i::m22, matrix3i::m23, vector2i::x, and vector2i::y.

Referenced by mat3i_mul_vec2i().

◆ mat3i_mul_vec3i()

vector3i mat3i_mul_vec3i ( const matrix3i m,
const vector3i v )

Multiplies a 3x3 integer matrix by a vector3i.

See mat3i_mul_vec3i_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector3i.

Definition at line 89 of file matrix3i.c.

References mat3i_mul_vec3i_ptr().

◆ mat3i_mul_vec3i_ptr()

void mat3i_mul_vec3i_ptr ( vector3i * res,
const matrix3i * m,
const vector3i * v )

Multiplies a 3x3 integer matrix by a vector3i.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 98 of file matrix3i_ptr.c.

References matrix3i::m11, matrix3i::m12, matrix3i::m13, matrix3i::m21, matrix3i::m22, matrix3i::m23, matrix3i::m31, matrix3i::m32, matrix3i::m33, vector3i::x, vector3i::y, and vector3i::z.

Referenced by mat3i_mul_vec3i().

◆ mat3i_transpose()

matrix3i mat3i_transpose ( const matrix3i m)

Computes the transpose of a 3x3 integer matrix.

See mat3i_transpose_ptr instead.

Parameters
mThe input matrix.
Returns
The transposed matrix.

Definition at line 45 of file matrix3i.c.

References mat3i_transpose_ptr().

◆ mat3i_transpose_ptr()

void mat3i_transpose_ptr ( matrix3i * res,
const matrix3i * m )

Computes the transpose of a 3x3 integer matrix.

Parameters
resPointer to the result matrix.
mPointer to the input matrix.

Definition at line 50 of file matrix3i_ptr.c.

References matrix3i::m11, matrix3i::m12, matrix3i::m13, matrix3i::m21, matrix3i::m22, matrix3i::m23, matrix3i::m31, matrix3i::m32, and matrix3i::m33.

Referenced by mat3i_transpose().

◆ mat4_determinant()

vm_float_t mat4_determinant ( const matrix4 m)

Calculates the determinant of the given 4x4 matrix.

Uses cofactor expansion for computation.

Parameters
mThe matrix.
Returns
The determinant value as a vm_float_t.

Definition at line 214 of file matrix4.c.

References matrix4::v.

◆ mat4_eq()

bool mat4_eq ( const matrix4 a,
const matrix4 b )

Returns true if two matrices are equal within VECMAT_EPSILON.

Parameters
aFirst matrix.
bSecond matrix.
Returns
True if a and b are approximately equal.

Definition at line 145 of file vecmat.c.

References matrix4::v, VECMAT_EPSILON, and VECMAT_FABS.

◆ mat4_extract_rotation()

quaternion mat4_extract_rotation ( const matrix4 m)

Extracts the rotation quaternion from a matrix4.

See mat4_extract_rotation_ptr instead.

Parameters
mInput matrix.
Returns
The resulting quaternion.

Definition at line 379 of file matrix4.c.

References mat4_extract_rotation_ptr().

◆ mat4_extract_rotation_ptr()

void mat4_extract_rotation_ptr ( quaternion * res,
const matrix4 * m )

◆ mat4_extract_scale()

vector3 mat4_extract_scale ( const matrix4 m)

Extracts the scale vector from a matrix4.

See mat4_extract_scale_ptr instead.

Parameters
mInput matrix.
Returns
The resulting vector3.

Definition at line 364 of file matrix4.c.

References mat4_extract_scale_ptr().

◆ mat4_extract_scale_ptr()

void mat4_extract_scale_ptr ( vector3 * res,
const matrix4 * m )

Extracts the scale vector from a matrix4.

Parameters
resOutput value.
mInput matrix.

Definition at line 323 of file matrix4_ptr.c.

References matrix4::m11, matrix4::m12, matrix4::m13, matrix4::m21, matrix4::m22, matrix4::m23, matrix4::m31, matrix4::m32, matrix4::m33, VECMAT_SQRT, vector3::x, vector3::y, and vector3::z.

Referenced by mat4_extract_rotation_ptr(), and mat4_extract_scale().

◆ mat4_extract_translation()

vector3 mat4_extract_translation ( const matrix4 m)

Extracts the translation vector from a matrix4.

See mat4_extract_translation_ptr instead.

Parameters
mInput matrix.
Returns
The resulting vector3.

Definition at line 349 of file matrix4.c.

References mat4_extract_translation_ptr().

◆ mat4_extract_translation_ptr()

void mat4_extract_translation_ptr ( vector3 * res,
const matrix4 * m )

Extracts the translation vector from a matrix4.

Parameters
resOutput value.
mInput matrix.

Definition at line 310 of file matrix4_ptr.c.

References matrix4::m14, matrix4::m24, matrix4::m34, vector3::x, vector3::y, and vector3::z.

Referenced by mat4_extract_translation().

◆ mat4_from_mat3()

matrix4 mat4_from_mat3 ( const matrix3 m)

Embeds a matrix3 into the upper-left of a matrix4.

See mat4_from_mat3_ptr instead.

Parameters
mInput matrix.
Returns
The resulting matrix4.

Definition at line 334 of file matrix4.c.

References mat4_from_mat3_ptr().

◆ mat4_from_mat3_ptr()

void mat4_from_mat3_ptr ( matrix4 * res,
const matrix3 * m )

◆ mat4_identity()

matrix4 mat4_identity ( void )

Constructs the 4x4 identity matrix.

See mat4_identity_ptr instead.

Returns
The identity matrix4.

Definition at line 14 of file matrix4.c.

References mat4_identity_ptr().

Referenced by mat4_look_at_ptr().

◆ mat4_identity_ptr()

void mat4_identity_ptr ( matrix4 * res)

Sets the matrix to the identity matrix.

The identity matrix is a 4x4 matrix with 1s on the main diagonal and 0s elsewhere.

Parameters
resPointer to the matrix4 to set to identity.

Definition at line 16 of file matrix4_ptr.c.

References matrix4::v.

Referenced by mat4_from_mat3_ptr(), mat4_identity(), mat4_rotation_x_ptr(), mat4_rotation_y_ptr(), mat4_rotation_z_ptr(), and quat_to_mat4_ptr().

◆ mat4_inverse()

matrix4 mat4_inverse ( const matrix4 m)

Computes the inverse of a 4x4 matrix.

See mat4_inverse_ptr instead.

Parameters
mThe input matrix.
Returns
The inverse matrix4.

Definition at line 60 of file matrix4.c.

References mat4_inverse_ptr().

◆ mat4_inverse_ptr()

void mat4_inverse_ptr ( matrix4 * res,
const matrix4 * m )

Computes the inverse of a 4x4 matrix.

This function calculates the inverse of the given 4x4 matrix using the adjugate matrix and determinant. If the matrix is singular (determinant is zero), the result is set to the identity matrix.

Parameters
resPointer to the matrix4 where the inverse will be stored.
mPointer to the matrix4 to invert.

Definition at line 98 of file matrix4_ptr.c.

References matrix4::v.

Referenced by mat4_inverse().

◆ mat4_look_at()

matrix4 mat4_look_at ( const vector3 position,
const vector3 target,
const vector3 up )

Constructs a view matrix from eye position, target, and up vector.

See mat4_look_at_ptr instead.

Parameters
positionEye position.
targetTarget position.
upUp vector.
Returns
The view matrix4.

Definition at line 162 of file matrix4.c.

References mat4_look_at_ptr().

◆ mat4_look_at_ptr()

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, with a specified up direction.

This function computes a 4x4 view matrix that orients the camera at the position vector, directing it towards the target vector, while aligning the up direction. The matrix is stored in column-major order.

Parameters
resPointer to the matrix4 where the result is stored.
positionPointer to the vector3 representing the camera's position.
targetPointer to the vector3 representing the point the camera is looking at.
upPointer to the vector3 representing the up direction for the camera.

Definition at line 418 of file matrix4_ptr.c.

References mat4_identity(), matrix4::v, vec3_cross(), vec3_dot(), vec3_normalize(), vec3_sub(), vector3::x, vector3::y, and vector3::z.

Referenced by mat4_look_at().

◆ mat4_mul()

matrix4 mat4_mul ( const matrix4 a,
const matrix4 b )

Multiplies two 4x4 matrices (a * b).

See mat4_mul_ptr instead.

Parameters
aThe first matrix.
bThe second matrix.
Returns
The resulting product matrix4.

Definition at line 30 of file matrix4.c.

References mat4_mul_ptr().

◆ mat4_mul_ptr()

void mat4_mul_ptr ( matrix4 * res,
const matrix4 * a,
const matrix4 * b )

Definition at line 69 of file matrix4_ptr.c.

References mat4_mul_ptr_scalar(), and vm_cpu_init().

Referenced by mat4_mul().

◆ mat4_mul_vec3()

vector3 mat4_mul_vec3 ( const matrix4 m,
const vector3 v,
const vm_float_t w )

Transforms a vector3 by a 4x4 matrix using homogeneous w.

See mat4_mul_vec3_ptr instead.

Parameters
mInput matrix.
vInput vector.
wHomogeneous w component.
Returns
The resulting vector3.

Definition at line 257 of file matrix4.c.

References mat4_mul_vec3_ptr().

◆ mat4_mul_vec3_ptr()

void mat4_mul_vec3_ptr ( vector3 * res,
const matrix4 * m,
const vector3 * v,
vm_float_t w )

Definition at line 538 of file matrix4_ptr.c.

References mat4_mul_vec3_ptr_scalar(), and vm_cpu_init().

Referenced by mat4_mul_vec3().

◆ mat4_mul_vec4()

vector4 mat4_mul_vec4 ( const matrix4 m,
const vector4 v )

Multiplies a 4x4 matrix by a vector4.

See mat4_mul_vec4_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector4.

Definition at line 240 of file matrix4.c.

References mat4_mul_vec4_ptr().

◆ mat4_mul_vec4_ptr()

void mat4_mul_vec4_ptr ( vector4 * res,
const matrix4 * m,
const vector4 * v )

Definition at line 510 of file matrix4_ptr.c.

References mat4_mul_vec4_ptr_scalar(), and vm_cpu_init().

Referenced by mat4_mul_vec4().

◆ mat4_ortho()

matrix4 mat4_ortho ( const vm_float_t left,
const vm_float_t right,
const vm_float_t bottom,
const vm_float_t top,
const vm_float_t near,
const vm_float_t far )

Constructs an orthographic projection matrix.

See mat4_ortho_ptr instead.

Parameters
leftLeft clipping plane.
rightRight clipping plane.
bottomBottom clipping plane.
topTop clipping plane.
nearNear plane distance.
farFar plane distance.
Returns
The orthographic matrix4.

Definition at line 144 of file matrix4.c.

References mat4_ortho_ptr().

◆ mat4_ortho_ptr()

void mat4_ortho_ptr ( matrix4 * res,
const vm_float_t left,
const vm_float_t right,
const vm_float_t bottom,
const vm_float_t top,
const vm_float_t near,
const vm_float_t far )

Sets the matrix to an orthographic projection matrix.

This function configures the matrix for an orthographic projection, mapping a rectangular frustum defined by the clipping planes to the canonical view volume.

Parameters
resPointer to the matrix4 to set to the orthographic projection matrix.
leftThe left clipping plane coordinate.
rightThe right clipping plane coordinate.
bottomThe bottom clipping plane coordinate.
topThe top clipping plane coordinate.
nearThe near clipping plane coordinate.
farThe far clipping plane coordinate.

Definition at line 393 of file matrix4_ptr.c.

References matrix4::v.

Referenced by mat4_ortho().

◆ mat4_perspective()

matrix4 mat4_perspective ( const vm_float_t fov,
const vm_float_t aspect,
const vm_float_t near,
const vm_float_t far )

Constructs a perspective projection matrix.

See mat4_perspective_ptr instead.

Parameters
fovField of view (radians).
aspectAspect ratio (width/height).
nearNear plane distance.
farFar plane distance.
Returns
The perspective matrix4.

Definition at line 124 of file matrix4.c.

References mat4_perspective_ptr().

◆ mat4_perspective_fov()

matrix4 mat4_perspective_fov ( const vm_float_t fov,
const vm_float_t w,
const vm_float_t h,
const vm_float_t n,
const vm_float_t f )

Constructs a perspective projection matrix using FOV, width, and height.

See mat4_perspective_fov_ptr instead.

Parameters
fovVertical field of view (radians).
wViewport width.
hViewport height.
nNear plane.
fFar plane.
Returns
The perspective matrix4.

Definition at line 181 of file matrix4.c.

References mat4_perspective_fov_ptr().

◆ mat4_perspective_fov_ptr()

void mat4_perspective_fov_ptr ( matrix4 * res,
const vm_float_t fov,
const vm_float_t w,
const vm_float_t h,
const vm_float_t n,
const vm_float_t f )

Sets the matrix to a perspective projection matrix.

This function constructs a right-handed perspective projection matrix using the specified field of view, viewport width and height, near clipping plane, and far clipping plane.

Parameters
resPointer to the matrix4 to set to the perspective projection matrix.
fovField of view angle in degrees.
wViewport width.
hViewport height.
nNear clipping plane distance.
fFar clipping plane distance.

Definition at line 452 of file matrix4_ptr.c.

References deg_to_rad(), matrix4::v, and VECMAT_TAN.

Referenced by mat4_perspective_fov().

◆ mat4_perspective_infinite()

matrix4 mat4_perspective_infinite ( const vm_float_t fov_y,
const vm_float_t aspect,
const vm_float_t n )

Constructs an infinite far-plane perspective projection matrix.

See mat4_perspective_infinite_ptr instead.

Parameters
fov_yVertical field of view (radians).
aspectAspect ratio.
nNear plane distance.
Returns
The perspective matrix4.

Definition at line 199 of file matrix4.c.

References mat4_perspective_infinite_ptr().

◆ mat4_perspective_infinite_ptr()

void mat4_perspective_infinite_ptr ( matrix4 * res,
vm_float_t const fov_y,
vm_float_t const aspect,
vm_float_t const n )

Sets the matrix to an infinite perspective projection matrix.

This function constructs a perspective projection matrix with an infinite far plane, which is useful for rendering scenes where depth precision is less critical beyond the near plane. The matrix is set such that the field of view and aspect ratio are applied, with the near plane at distance n.

Parameters
resPointer to the matrix4 to set to the infinite perspective projection.
fov_yVertical field of view in degrees.
aspectAspect ratio of the viewport (width / height).
nDistance to the near clipping plane.

Definition at line 479 of file matrix4_ptr.c.

References deg_to_rad(), matrix4::v, and VECMAT_TAN.

Referenced by mat4_perspective_infinite().

◆ mat4_perspective_ptr()

void mat4_perspective_ptr ( matrix4 * res,
const vm_float_t fov,
const vm_float_t aspect,
const vm_float_t near,
const vm_float_t far )

Creates a perspective projection matrix.

This function computes a right-handed perspective projection matrix based on the given field of view, aspect ratio, and near and far clipping planes. The matrix is stored in the provided result pointer.

Parameters
resPointer to the matrix4 to store the perspective projection matrix.
fovField of view in degrees.
aspectAspect ratio of the viewport (width divided by height).
nearDistance to the near clipping plane.
farDistance to the far clipping plane.

Definition at line 365 of file matrix4_ptr.c.

References deg_to_rad(), matrix4::v, and VECMAT_TAN.

Referenced by mat4_perspective().

◆ mat4_rotation()

matrix4 mat4_rotation ( const vector3 axis,
const vm_float_t angle )

Constructs a rotation matrix around the given axis by the specified angle (in radians).

See mat4_rotation_ptr instead.

Parameters
axisThe rotation axis vector.
angleThe rotation angle in radians.
Returns
The rotation matrix4.

Definition at line 106 of file matrix4.c.

References mat4_rotation_ptr().

◆ mat4_rotation_ptr()

void mat4_rotation_ptr ( matrix4 * res,
const vector3 * axis,
const vm_float_t angle )

Sets the matrix to a rotation matrix around the specified axis by the given angle.

The rotation is performed around the normalized axis vector by the specified angle in degrees. The resulting matrix is a 4x4 rotation matrix stored in column-major order.

Parameters
resPointer to the matrix4 to store the resulting rotation matrix.
axisPointer to the vector3 representing the axis of rotation.
angleThe rotation angle in degrees.

Definition at line 195 of file matrix4_ptr.c.

References deg_to_rad(), matrix4::v, vec3_normalize(), VECMAT_COS, VECMAT_SIN, vector3::x, vector3::y, and vector3::z.

Referenced by mat4_rotation().

◆ mat4_rotation_x()

matrix4 mat4_rotation_x ( const vm_float_t degrees)

Builds a 4x4 rotation matrix around the X axis (degrees).

See mat4_rotation_x_ptr instead.

Parameters
degreesRotation angle in degrees.
Returns
The resulting matrix4.

Definition at line 272 of file matrix4.c.

References mat4_rotation_x_ptr().

◆ mat4_rotation_x_ptr()

void mat4_rotation_x_ptr ( matrix4 * res,
const vm_float_t degrees )

Builds a 4x4 rotation matrix around the X axis (degrees).

Parameters
resOutput value.
degreesRotation angle in degrees.

Definition at line 223 of file matrix4_ptr.c.

References deg_to_rad(), matrix4::m22, matrix4::m23, matrix4::m32, matrix4::m33, mat4_identity_ptr(), VECMAT_COS, and VECMAT_SIN.

Referenced by mat4_rotation_x().

◆ mat4_rotation_y()

matrix4 mat4_rotation_y ( const vm_float_t degrees)

Builds a 4x4 rotation matrix around the Y axis (degrees).

See mat4_rotation_y_ptr instead.

Parameters
degreesRotation angle in degrees.
Returns
The resulting matrix4.

Definition at line 287 of file matrix4.c.

References mat4_rotation_y_ptr().

◆ mat4_rotation_y_ptr()

void mat4_rotation_y_ptr ( matrix4 * res,
const vm_float_t degrees )

Builds a 4x4 rotation matrix around the Y axis (degrees).

Parameters
resOutput value.
degreesRotation angle in degrees.

Definition at line 241 of file matrix4_ptr.c.

References deg_to_rad(), matrix4::m11, matrix4::m13, matrix4::m31, matrix4::m33, mat4_identity_ptr(), VECMAT_COS, and VECMAT_SIN.

Referenced by mat4_rotation_y().

◆ mat4_rotation_z()

matrix4 mat4_rotation_z ( const vm_float_t degrees)

Builds a 4x4 rotation matrix around the Z axis (degrees).

See mat4_rotation_z_ptr instead.

Parameters
degreesRotation angle in degrees.
Returns
The resulting matrix4.

Definition at line 302 of file matrix4.c.

References mat4_rotation_z_ptr().

◆ mat4_rotation_z_ptr()

void mat4_rotation_z_ptr ( matrix4 * res,
const vm_float_t degrees )

Builds a 4x4 rotation matrix around the Z axis (degrees).

Parameters
resOutput value.
degreesRotation angle in degrees.

Definition at line 259 of file matrix4_ptr.c.

References deg_to_rad(), matrix4::m11, matrix4::m12, matrix4::m21, matrix4::m22, mat4_identity_ptr(), VECMAT_COS, and VECMAT_SIN.

Referenced by mat4_rotation_z().

◆ mat4_scale()

matrix4 mat4_scale ( const vector3 v)

Constructs a scaling matrix from the given scale vector.

See mat4_scale_ptr instead.

Parameters
vThe scale vector (x, y, z factors).
Returns
The resulting scaling matrix4.

Definition at line 90 of file matrix4.c.

References mat4_scale_ptr().

◆ mat4_scale_ptr()

void mat4_scale_ptr ( matrix4 * res,
const vector3 * v )

Sets the matrix to a scaling matrix using the provided scale vector.

This function constructs a 4x4 scaling matrix where the diagonal elements correspond to the x, y, and z scale factors from the input vector. The bottom-right element is set to 1.0f for homogeneous coordinates. All other elements are implicitly zero (not set, assuming the matrix is initialized).

Parameters
resPointer to the matrix4 to set as a scaling matrix.
vPointer to the vector3 containing the scale factors (x, y, z).

Definition at line 176 of file matrix4_ptr.c.

References matrix4::v, vector3::x, vector3::y, and vector3::z.

Referenced by mat4_scale().

◆ mat4_translate()

matrix4 mat4_translate ( const vector3 v)

Constructs a translation matrix from the given vector.

See mat4_translate_ptr instead.

Parameters
vThe translation vector (x, y, z).
Returns
The translation matrix4.

Definition at line 75 of file matrix4.c.

References mat4_translate_ptr().

◆ mat4_translate_ptr()

void mat4_translate_ptr ( matrix4 * res,
const vector3 * v )

Sets the matrix to a translation matrix.

This function initializes a 4x4 matrix to represent a translation transformation based on the provided vector, with the translation components placed in the last column and the rest forming an identity matrix.

Parameters
resPointer to the matrix4 to set.
vPointer to the vector3 containing the translation values.

Definition at line 145 of file matrix4_ptr.c.

References matrix4::v, vector3::x, vector3::y, and vector3::z.

Referenced by mat4_translate().

◆ mat4_transpose()

matrix4 mat4_transpose ( const matrix4 m)

Computes the transpose of a 4x4 matrix.

See mat4_transpose_ptr instead.

Parameters
mThe input matrix.
Returns
The transposed matrix4.

Definition at line 45 of file matrix4.c.

References mat4_transpose_ptr().

◆ mat4_transpose_ptr()

void mat4_transpose_ptr ( matrix4 * res,
const matrix4 * m )

Definition at line 79 of file matrix4_ptr.c.

References mat4_transpose_ptr_scalar(), and vm_cpu_init().

Referenced by mat4_transpose().

◆ mat4_trs()

matrix4 mat4_trs ( const vector3 translation,
const quaternion rotation,
const vector3 scale )

Builds a 4x4 TRS matrix from translation, rotation, and scale.

See mat4_trs_ptr instead.

Parameters
translationTranslation vector.
rotationRotation quaternion.
scaleScale vector.
Returns
The resulting matrix4.

Definition at line 319 of file matrix4.c.

References mat4_trs_ptr().

◆ mat4_trs_ptr()

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.

Parameters
resOutput value.
translationTranslation vector.
rotationRotation quaternion.
scaleScale vector.

Definition at line 293 of file matrix4_ptr.c.

References matrix4::m11, matrix4::m12, matrix4::m13, matrix4::m14, matrix4::m21, matrix4::m22, matrix4::m23, matrix4::m24, matrix4::m31, matrix4::m32, matrix4::m33, matrix4::m34, quat_to_mat4_ptr(), vector3::x, vector3::y, and vector3::z.

Referenced by mat4_trs().

◆ mat4i_determinant()

vm_int_t mat4i_determinant ( const matrix4i m)

Computes the determinant of a 4x4 integer matrix (Laplace expansion along first row).

Parameters
mThe input matrix.
Returns
The determinant value.

Definition at line 73 of file matrix4i.c.

References matrix4i::v.

◆ mat4i_eq()

bool mat4i_eq ( const matrix4i a,
const matrix4i b )

Returns true if two matrices are exactly equal.

Parameters
aFirst matrix.
bSecond matrix.
Returns
True if a and b are equal.

Definition at line 190 of file vecmat.c.

References matrix4i::v.

◆ mat4i_identity()

matrix4i mat4i_identity ( void )

Constructs the 4x4 identity matrix.

See mat4i_identity_ptr instead.

Returns
The identity matrix4i.

Definition at line 14 of file matrix4i.c.

References mat4i_identity_ptr().

◆ mat4i_identity_ptr()

void mat4i_identity_ptr ( matrix4i * res)

Sets the given 4x4 integer matrix to the identity matrix.

Parameters
resPointer to the matrix structure to set to identity.

Definition at line 12 of file matrix4i_ptr.c.

References matrix4i::v.

Referenced by mat4i_identity().

◆ mat4i_inverse()

matrix4i mat4i_inverse ( const matrix4i m)

Computes the inverse of a 4x4 integer matrix.

See mat4i_inverse_ptr instead.

Parameters
mThe input matrix.
Returns
The inverse matrix.

Definition at line 60 of file matrix4i.c.

References mat4i_inverse_ptr().

◆ mat4i_inverse_ptr()

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.

If the matrix is singular (determinant is zero), the result is set to the identity matrix.

Parameters
resPointer to the matrix structure to store the inverse matrix.
mPointer to the constant matrix to be inverted.

Definition at line 81 of file matrix4i_ptr.c.

References matrix4i::v.

Referenced by mat4i_inverse().

◆ mat4i_mul()

matrix4i mat4i_mul ( const matrix4i a,
const matrix4i b )

Multiplies two 4x4 integer matrices.

See mat4i_mul_ptr instead.

Parameters
aThe first matrix.
bThe second matrix.
Returns
The product matrix.

Definition at line 30 of file matrix4i.c.

References mat4i_mul_ptr().

◆ mat4i_mul_ptr()

void mat4i_mul_ptr ( matrix4i * res,
const matrix4i * a,
const matrix4i * b )

Performs matrix multiplication of two 4x4 matrices and stores the result.

Parameters
resPointer to the matrix structure to store the result of the multiplication.
aPointer to the first matrix operand.
bPointer to the second matrix operand.

Definition at line 29 of file matrix4i_ptr.c.

References matrix4i::m11, matrix4i::m12, matrix4i::m13, matrix4i::m14, matrix4i::m21, matrix4i::m22, matrix4i::m23, matrix4i::m24, matrix4i::m31, matrix4i::m32, matrix4i::m33, matrix4i::m34, matrix4i::m41, matrix4i::m42, matrix4i::m43, and matrix4i::m44.

Referenced by mat4i_mul().

◆ mat4i_mul_vec3i()

vector3i mat4i_mul_vec3i ( const matrix4i m,
const vector3i v,
const vm_int_t w )

Transforms a vector3i by a 4x4 integer matrix using homogeneous w.

See mat4i_mul_vec3i_ptr instead.

Parameters
mInput matrix.
vInput vector.
wHomogeneous w component.
Returns
The resulting vector3i.

Definition at line 116 of file matrix4i.c.

References mat4i_mul_vec3i_ptr().

◆ mat4i_mul_vec3i_ptr()

void mat4i_mul_vec3i_ptr ( vector3i * res,
const matrix4i * m,
const vector3i * v,
const vm_int_t w )

Transforms a vector3i by a 4x4 integer matrix using homogeneous w.

Parameters
resOutput value.
mInput matrix.
vInput vector.
wHomogeneous w component.

Definition at line 149 of file matrix4i_ptr.c.

References matrix4i::m11, matrix4i::m12, matrix4i::m13, matrix4i::m14, matrix4i::m21, matrix4i::m22, matrix4i::m23, matrix4i::m24, matrix4i::m31, matrix4i::m32, matrix4i::m33, matrix4i::m34, vector3i::x, vector3i::y, and vector3i::z.

Referenced by mat4i_mul_vec3i().

◆ mat4i_mul_vec4i()

vector4i mat4i_mul_vec4i ( const matrix4i m,
const vector4i v )

Multiplies a 4x4 integer matrix by a vector4i.

See mat4i_mul_vec4i_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector4i.

Definition at line 99 of file matrix4i.c.

References mat4i_mul_vec4i_ptr().

◆ mat4i_mul_vec4i_ptr()

void mat4i_mul_vec4i_ptr ( vector4i * res,
const matrix4i * m,
const vector4i * v )

Multiplies a 4x4 integer matrix by a vector4i.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 129 of file matrix4i_ptr.c.

References matrix4i::m11, matrix4i::m12, matrix4i::m13, matrix4i::m14, matrix4i::m21, matrix4i::m22, matrix4i::m23, matrix4i::m24, matrix4i::m31, matrix4i::m32, matrix4i::m33, matrix4i::m34, matrix4i::m41, matrix4i::m42, matrix4i::m43, matrix4i::m44, vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by mat4i_mul_vec4i().

◆ mat4i_transpose()

matrix4i mat4i_transpose ( const matrix4i m)

Computes the transpose of a 4x4 integer matrix.

See mat4i_transpose_ptr instead.

Parameters
mThe input matrix.
Returns
The transposed matrix.

Definition at line 45 of file matrix4i.c.

References mat4i_transpose_ptr().

◆ mat4i_transpose_ptr()

void mat4i_transpose_ptr ( matrix4i * res,
const matrix4i * m )

Transposes the given 4x4 integer matrix and stores the result in the provided matrix structure.

Parameters
resPointer to the matrix structure to store the transposed matrix.
mPointer to the input matrix to be transposed.

Definition at line 61 of file matrix4i_ptr.c.

References matrix4i::v.

Referenced by mat4i_transpose().

◆ poly_ease_in()

vm_float_t poly_ease_in ( vm_float_t f,
vm_float_t n )

Definition at line 17 of file easing.c.

References VECMAT_POW.

Referenced by cubic_ease_in(), quadratic_ease_in(), quartic_ease_in(), and quintic_ease_in().

◆ poly_ease_in_out()

vm_float_t poly_ease_in_out ( vm_float_t f,
vm_float_t n )

Definition at line 27 of file easing.c.

References VECMAT_POW.

Referenced by cubic_ease_in_out(), quadratic_ease_in_out(), quartic_ease_in_out(), and quintic_ease_in_out().

◆ poly_ease_out()

vm_float_t poly_ease_out ( vm_float_t f,
vm_float_t n )

Definition at line 22 of file easing.c.

References VECMAT_POW.

Referenced by cubic_ease_out(), quadratic_ease_out(), quartic_ease_out(), and quintic_ease_out().

◆ quadratic_ease_in()

vm_float_t quadratic_ease_in ( vm_float_t f)

Definition at line 37 of file easing.c.

References poly_ease_in().

◆ quadratic_ease_in_out()

vm_float_t quadratic_ease_in_out ( vm_float_t f)

Definition at line 42 of file easing.c.

References poly_ease_in_out().

◆ quadratic_ease_out()

vm_float_t quadratic_ease_out ( vm_float_t f)

Definition at line 32 of file easing.c.

References poly_ease_out().

◆ quartic_ease_in()

vm_float_t quartic_ease_in ( vm_float_t f)

Definition at line 67 of file easing.c.

References poly_ease_in().

◆ quartic_ease_in_out()

vm_float_t quartic_ease_in_out ( vm_float_t f)

Definition at line 72 of file easing.c.

References poly_ease_in_out().

◆ quartic_ease_out()

vm_float_t quartic_ease_out ( vm_float_t f)

Definition at line 62 of file easing.c.

References poly_ease_out().

◆ quat_conjugate()

quaternion quat_conjugate ( const quaternion q)

Returns the conjugate of a quaternion.

See quat_conjugate_ptr instead.

Parameters
qInput quaternion.
Returns
The resulting quaternion.

Definition at line 90 of file quaternion.c.

References quat_conjugate_ptr().

◆ quat_conjugate_ptr()

void quat_conjugate_ptr ( quaternion * res,
const quaternion * q )

Writes the conjugate of a quaternion.

Parameters
resOutput value.
qInput quaternion.

Definition at line 149 of file quaternion_ptr.c.

References quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by quat_conjugate().

◆ quat_dot()

vm_float_t quat_dot ( const quaternion a,
const quaternion b )

Returns the dot product of two quaternions.

Parameters
aFirst input quaternion.
bSecond input quaternion.
Returns
The resulting vm_float_t.

Definition at line 261 of file quaternion.c.

References quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by quat_nlerp_ptr(), and quat_slerp_ptr().

◆ quat_eq()

bool quat_eq ( const quaternion a,
const quaternion b )

Returns true if two quaternions are equal within VECMAT_EPSILON.

Parameters
aFirst quaternion.
bSecond quaternion.
Returns
True if a and b are approximately equal.

Definition at line 205 of file vecmat.c.

References VECMAT_EPSILON, VECMAT_FABS, quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

◆ quat_from_axis_angle()

quaternion quat_from_axis_angle ( const vector3 axis,
const vm_float_t degrees )

Builds a quaternion from an axis and an angle in degrees.

See quat_from_axis_angle_ptr instead.

Parameters
axisRotation axis.
degreesRotation angle in degrees.
Returns
The resulting quaternion.

Definition at line 121 of file quaternion.c.

References quat_from_axis_angle_ptr().

◆ quat_from_axis_angle_ptr()

void quat_from_axis_angle_ptr ( quaternion * res,
const vector3 * axis,
const vm_float_t degrees )

Builds a quaternion from an axis and an angle in degrees.

Parameters
resOutput value.
axisRotation axis.
degreesRotation angle in degrees.

Definition at line 184 of file quaternion_ptr.c.

References deg_to_rad(), vec3_normalize(), VECMAT_COS, VECMAT_SIN, quaternion::w, quaternion::x, vector3::x, quaternion::y, vector3::y, quaternion::z, and vector3::z.

Referenced by quat_from_axis_angle().

◆ quat_from_euler()

quaternion quat_from_euler ( const vector3 euler)

Constructs a quaternion from Euler angles (in radians, XYZ order).

See quat_from_euler_ptr instead.

Parameters
eulerThe Euler angles vector (x=pitch, y=yaw, z=roll).
Returns
The resulting quaternion.

Definition at line 60 of file quaternion.c.

References quat_from_euler_ptr().

◆ quat_from_euler_ptr()

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.

Internally converts to radians, computes quaternion, and normalizes.

Parameters
resPointer to the output quaternion.
eulerPointer to the input Euler angles vector.

Definition at line 91 of file quaternion_ptr.c.

References deg_to_rad(), quat_normalize_ptr(), VECMAT_COS, VECMAT_SIN, vector3::x, vector3::y, and vector3::z.

Referenced by quat_from_euler().

◆ quat_from_mat3()

quaternion quat_from_mat3 ( const matrix3 m)

Builds a quaternion from a 3x3 rotation matrix.

See quat_from_mat3_ptr instead.

Parameters
mInput matrix.
Returns
The resulting quaternion.

Definition at line 136 of file quaternion.c.

References quat_from_mat3_ptr().

◆ quat_from_mat3_ptr()

void quat_from_mat3_ptr ( quaternion * res,
const matrix3 * m )

Builds a quaternion from a 3x3 rotation matrix.

Parameters
resOutput value.
mInput matrix.

Definition at line 201 of file quaternion_ptr.c.

References matrix3::m11, matrix3::m12, matrix3::m13, matrix3::m21, matrix3::m22, matrix3::m23, matrix3::m31, matrix3::m32, matrix3::m33, quat_normalize_ptr(), VECMAT_SQRT, quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by mat4_extract_rotation_ptr(), quat_from_mat3(), and quat_from_mat4_ptr().

◆ quat_from_mat4()

quaternion quat_from_mat4 ( const matrix4 m)

Builds a quaternion from the rotation of a 4x4 matrix.

See quat_from_mat4_ptr instead.

Parameters
mInput matrix.
Returns
The resulting quaternion.

Definition at line 151 of file quaternion.c.

References quat_from_mat4_ptr().

◆ quat_from_mat4_ptr()

void quat_from_mat4_ptr ( quaternion * res,
const matrix4 * m )

Builds a quaternion from the rotation of a 4x4 matrix.

Parameters
resOutput value.
mInput matrix.

Definition at line 238 of file quaternion_ptr.c.

References matrix4::m11, matrix4::m12, matrix4::m13, matrix4::m21, matrix4::m22, matrix4::m23, matrix4::m31, matrix4::m32, matrix4::m33, and quat_from_mat3_ptr().

Referenced by quat_from_mat4().

◆ quat_identity()

quaternion quat_identity ( void )

Constructs the identity quaternion.

See quat_identity_ptr instead.

Returns
The identity quaternion.

Definition at line 14 of file quaternion.c.

References quat_identity_ptr().

◆ quat_identity_ptr()

void quat_identity_ptr ( quaternion * res)

Sets the quaternion to the identity quaternion (x=0, y=0, z=0, w=1).

Parameters
resPointer to the quaternion to initialize.

Definition at line 13 of file quaternion_ptr.c.

References quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by quat_identity().

◆ quat_inverse()

quaternion quat_inverse ( const quaternion q)

Returns the inverse of a quaternion.

See quat_inverse_ptr instead.

Parameters
qInput quaternion.
Returns
The resulting quaternion.

Definition at line 105 of file quaternion.c.

References quat_inverse_ptr().

◆ quat_inverse_ptr()

void quat_inverse_ptr ( quaternion * res,
const quaternion * q )

Writes the inverse of a quaternion.

Parameters
resOutput value.
qInput quaternion.

Definition at line 163 of file quaternion_ptr.c.

References quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by quat_inverse(), and quat_rotate_vec3_ptr().

◆ quat_mul()

quaternion quat_mul ( const quaternion a,
const quaternion b )

Multiplies two quaternions (a * b).

See quat_mul_ptr instead.

Parameters
aThe first quaternion.
bThe second quaternion.
Returns
The resulting product quaternion.

Definition at line 30 of file quaternion.c.

References quat_mul_ptr().

◆ quat_mul_ptr()

void quat_mul_ptr ( quaternion * res,
const quaternion * a,
const quaternion * b )

Definition at line 37 of file quaternion_ptr.c.

References quat_mul_ptr_scalar(), and vm_cpu_init().

Referenced by quat_mul(), and quat_rotate_vec3_ptr().

◆ quat_near()

bool quat_near ( const quaternion a,
const quaternion b,
const vm_float_t eps )

Returns true if a and b are within eps of each other.

Parameters
aFirst input quaternion.
bSecond input quaternion.
epsDistance tolerance.
Returns
True if a and b are within eps.

Definition at line 274 of file quaternion.c.

References VECMAT_FABS, quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

◆ quat_nlerp()

quaternion quat_nlerp ( const quaternion a,
const quaternion b,
const vm_float_t t )

Normalized-linearly interpolates from a to b by t.

See quat_nlerp_ptr instead.

Parameters
aFirst input quaternion.
bSecond input quaternion.
tInterpolation factor.
Returns
The resulting quaternion.

Definition at line 185 of file quaternion.c.

References quat_nlerp_ptr().

◆ quat_nlerp_ptr()

void quat_nlerp_ptr ( quaternion * res,
const quaternion * a,
const quaternion * b,
const vm_float_t t )

Normalized-linearly interpolates from a to b by t.

Parameters
resOutput value.
aFirst input quaternion.
bSecond input quaternion.
tInterpolation factor.

Definition at line 256 of file quaternion_ptr.c.

References quat_dot(), quat_normalize_ptr(), quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by quat_nlerp(), and quat_slerp_ptr().

◆ quat_normalize()

quaternion quat_normalize ( const quaternion q)

Normalizes a quaternion.

See quat_normalize_ptr instead.

Parameters
qThe input quaternion.
Returns
The normalized quaternion.

Definition at line 45 of file quaternion.c.

References quat_normalize_ptr().

◆ quat_normalize_ptr()

void quat_normalize_ptr ( quaternion * res,
const quaternion * q )

◆ quat_rotate_vec3()

vector3 quat_rotate_vec3 ( const quaternion q,
const vector3 v )

Rotates a vector3 by a quaternion.

See quat_rotate_vec3_ptr instead.

Parameters
qInput quaternion.
vInput vector.
Returns
The resulting vector3.

Definition at line 201 of file quaternion.c.

References quat_rotate_vec3_ptr().

◆ quat_rotate_vec3_ptr()

void quat_rotate_vec3_ptr ( vector3 * res,
const quaternion * q,
const vector3 * v )

Rotates a vector3 by a quaternion.

Parameters
resOutput value.
qInput quaternion.
vInput vector.

Definition at line 314 of file quaternion_ptr.c.

References quat_inverse_ptr(), quat_mul_ptr(), quaternion::x, vector3::x, quaternion::y, vector3::y, quaternion::z, and vector3::z.

Referenced by quat_rotate_vec3().

◆ quat_slerp()

quaternion quat_slerp ( const quaternion a,
const quaternion b,
const vm_float_t t )

Spherical-linearly interpolates from a to b by t.

See quat_slerp_ptr instead.

Parameters
aFirst input quaternion.
bSecond input quaternion.
tInterpolation factor.
Returns
The resulting quaternion.

Definition at line 168 of file quaternion.c.

References quat_slerp_ptr().

◆ quat_slerp_ptr()

void quat_slerp_ptr ( quaternion * res,
const quaternion * a,
const quaternion * b,
const vm_float_t t )

Spherical-linearly interpolates from a to b by t.

Parameters
resOutput value.
aFirst input quaternion.
bSecond input quaternion.
tInterpolation factor.

Definition at line 282 of file quaternion_ptr.c.

References quat_dot(), quat_nlerp_ptr(), VECMAT_ACOS, VECMAT_SIN, quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by quat_slerp().

◆ quat_to_axis_angle()

vector3 quat_to_axis_angle ( const quaternion q,
vm_float_t * degrees )

Converts a quaternion to an axis and an angle in degrees.

See quat_to_axis_angle_ptr instead.

Parameters
qInput quaternion.
degreesOptional output angle in degrees.
Returns
The rotation axis.

Definition at line 232 of file quaternion.c.

References quat_to_axis_angle_ptr().

◆ quat_to_axis_angle_ptr()

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.

Parameters
axisOutput rotation axis.
degreesOptional output angle in degrees.
qInput quaternion.

Definition at line 364 of file quaternion_ptr.c.

References quat_normalize_ptr(), rad_to_deg(), VECMAT_ACOS, VECMAT_EPSILON, VECMAT_SQRT, quaternion::w, quaternion::x, vector3::x, quaternion::y, vector3::y, quaternion::z, and vector3::z.

Referenced by quat_to_axis_angle().

◆ quat_to_euler()

vector3 quat_to_euler ( const quaternion q)

Converts a quaternion to Euler angles in degrees (XYZ).

See quat_to_euler_ptr instead.

Parameters
qInput quaternion.
Returns
The resulting vector3.

Definition at line 216 of file quaternion.c.

References quat_to_euler_ptr().

◆ quat_to_euler_ptr()

void quat_to_euler_ptr ( vector3 * res,
const quaternion * q )

Converts a quaternion to Euler angles in degrees (XYZ).

Parameters
resOutput value.
qInput quaternion.

Definition at line 334 of file quaternion_ptr.c.

References M_PI_2, VECMAT_ASIN, VECMAT_ATAN2, VECMAT_COPYSIGN, VECMAT_FABS, VM_RAD_TO_DEG, quaternion::w, quaternion::x, vector3::x, quaternion::y, vector3::y, quaternion::z, and vector3::z.

Referenced by quat_to_euler().

◆ quat_to_mat3()

matrix3 quat_to_mat3 ( const quaternion q)

Converts a quaternion to a 3x3 rotation matrix.

See quat_to_mat3_ptr instead.

Parameters
qInput quaternion.
Returns
The resulting matrix3.

Definition at line 247 of file quaternion.c.

References quat_to_mat3_ptr().

◆ quat_to_mat3_ptr()

void quat_to_mat3_ptr ( matrix3 * res,
const quaternion * q )

Converts a quaternion to a 3x3 rotation matrix.

Parameters
resOutput value.
qInput quaternion.

Definition at line 391 of file quaternion_ptr.c.

References matrix3::m11, matrix4::m11, matrix3::m12, matrix4::m12, matrix3::m13, matrix4::m13, matrix3::m21, matrix4::m21, matrix3::m22, matrix4::m22, matrix3::m23, matrix4::m23, matrix3::m31, matrix4::m31, matrix3::m32, matrix4::m32, matrix3::m33, matrix4::m33, and quat_to_mat4_ptr().

Referenced by quat_to_mat3().

◆ quat_to_mat4()

matrix4 quat_to_mat4 ( const quaternion q)

Converts a quaternion to a 4x4 rotation matrix.

See quat_to_mat4_ptr instead.

Parameters
qThe input quaternion.
Returns
The equivalent matrix4.

Definition at line 75 of file quaternion.c.

References quat_to_mat4_ptr().

◆ quat_to_mat4_ptr()

void quat_to_mat4_ptr ( matrix4 * res,
const quaternion * q )

Converts a unit quaternion to a 4x4 rotation matrix and stores in res.

Starts with the identity matrix and applies rotation components.

Parameters
resPointer to the output matrix4.
qPointer to the input quaternion (should be normalized).

Definition at line 118 of file quaternion_ptr.c.

References matrix4::m11, matrix4::m12, matrix4::m13, matrix4::m21, matrix4::m22, matrix4::m23, matrix4::m31, matrix4::m32, matrix4::m33, mat4_identity_ptr(), quaternion::w, quaternion::x, quaternion::y, and quaternion::z.

Referenced by mat4_trs_ptr(), quat_to_mat3_ptr(), and quat_to_mat4().

◆ quintic_ease_in()

vm_float_t quintic_ease_in ( vm_float_t f)

Definition at line 82 of file easing.c.

References poly_ease_in().

◆ quintic_ease_in_out()

vm_float_t quintic_ease_in_out ( vm_float_t f)

Definition at line 87 of file easing.c.

References poly_ease_in_out().

◆ quintic_ease_out()

vm_float_t quintic_ease_out ( vm_float_t f)

Definition at line 77 of file easing.c.

References poly_ease_out().

◆ rad_to_deg()

vm_float_t rad_to_deg ( const vm_float_t radians)

Converts radians to degrees.

Parameters
radiansAngle in radians.
Returns
The angle in degrees.

Definition at line 25 of file vecmat.c.

References VM_RAD_TO_DEG.

Referenced by quat_to_axis_angle_ptr().

◆ sine_ease_in()

vm_float_t sine_ease_in ( vm_float_t f)

Definition at line 97 of file easing.c.

References M_PI, and VECMAT_COS.

◆ sine_ease_in_out()

vm_float_t sine_ease_in_out ( vm_float_t f)

Definition at line 102 of file easing.c.

References M_PI, and VECMAT_COS.

◆ sine_ease_out()

vm_float_t sine_ease_out ( vm_float_t f)

Definition at line 92 of file easing.c.

References M_PI, and VECMAT_SIN.

◆ vec2()

vector2 vec2 ( const vm_float_t x,
const vm_float_t y )

Constructs a vector2 from x and y.

Parameters
xX component.
yY component.
Returns
The resulting vector2.

Definition at line 220 of file vecmat.c.

◆ vec2_abs()

vector2 vec2_abs ( const vector2 v)

Returns the absolute values of each component.

See vec2_abs_ptr instead.

Parameters
vThe input vector.
Returns
The absolute value vector2.

Definition at line 190 of file vector2.c.

References vec2_abs_ptr().

◆ vec2_abs_ptr()

void vec2_abs_ptr ( vector2 * res,
const vector2 * v )

Computes the absolute values of the components of vector v, storing the result in res.

Parameters
resOutput vector.
vInput vector.

Definition at line 95 of file vector2_ptr.c.

References VECMAT_FABS, vector2::x, and vector2::y.

Referenced by vec2_abs().

◆ vec2_add()

vector2 vec2_add ( const vector2 a,
const vector2 b )

Adds two vectors component-wise.

See vec2_add_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The sum vector2.

Definition at line 96 of file vector2.c.

References vec2_add_ptr().

◆ vec2_add_assign()

void vec2_add_assign ( vector2 * dest,
const vector2 * src )

Adds src to dest in place.

Parameters
destDestination vector.
srcVector to add.

Definition at line 256 of file vecmat.c.

References vector2::x, and vector2::y.

◆ vec2_add_ptr()

void vec2_add_ptr ( vector2 * res,
const vector2 * a,
const vector2 * b )

Adds vectors a and b component-wise, storing the result in res.

Parameters
resOutput vector.
aInput vector a.
bInput vector b.

Definition at line 14 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_add().

◆ vec2_add_scalar()

vector2 vec2_add_scalar ( const vector2 v,
const vm_float_t s )

Adds a scalar to each component.

See vec2_add_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector2.

Definition at line 543 of file vector2.c.

References vec2_add_scalar_ptr().

◆ vec2_add_scalar_ptr()

void vec2_add_scalar_ptr ( vector2 * res,
const vector2 * v,
const vm_float_t s )

Adds a scalar to each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 371 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_add_scalar().

◆ vec2_angle()

vm_float_t vec2_angle ( const vector2 a,
const vector2 b )

Computes the angle between two vectors (in radians, range [0, PI]).

Returns 0.0f if either vector has zero length.

Parameters
aThe first vector.
bThe second vector.
Returns
The angle scalar.

Definition at line 492 of file vector2.c.

References vec2_dot(), vec2_length(), and VECMAT_ACOS.

◆ vec2_aspect_ratio()

vm_float_t vec2_aspect_ratio ( const vector2 v)

Computes the aspect ratio of the vector (x / y).

Returns 0.0f if y == 0.0f.

Parameters
vThe input vector.
Returns
The aspect ratio scalar.

Definition at line 463 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_assign()

void vec2_assign ( vector2 * dest,
const vector2 * src )

Copies src into dest.

Parameters
destDestination vector.
srcSource vector.

Definition at line 231 of file vecmat.c.

References vector2::x, and vector2::y.

◆ vec2_assign_xy()

void vec2_assign_xy ( vector2 * dest,
const vm_float_t x,
const vm_float_t y )

Assigns x and y to dest.

Parameters
destDestination vector.
xX component.
yY component.

Definition at line 244 of file vecmat.c.

References vector2::x, and vector2::y.

◆ vec2_ceil()

vector2 vec2_ceil ( const vector2 v)

Applies ceil to each component.

See vec2_ceil_ptr instead.

Parameters
vThe input vector.
Returns
The ceiled vector2.

Definition at line 298 of file vector2.c.

References vec2_ceil_ptr().

◆ vec2_ceil_ptr()

void vec2_ceil_ptr ( vector2 * res,
const vector2 * v )

Applies the ceil function to each component of vector v, storing the result in res.

Parameters
resOutput vector.
vInput vector.

Definition at line 180 of file vector2_ptr.c.

References VECMAT_CEIL, vector2::x, and vector2::y.

Referenced by vec2_ceil().

◆ vec2_clamp()

vector2 vec2_clamp ( const vector2 v,
const vector2 min,
const vector2 max )

Clamps vector v component-wise between min and max.

See vec2_clamp_ptr instead.

Parameters
vThe input vector.
minThe minimum bounds vector.
maxThe maximum bounds vector.
Returns
The clamped vector2.

Definition at line 425 of file vector2.c.

References vec2_clamp_ptr().

◆ vec2_clamp_ptr()

void vec2_clamp_ptr ( vector2 * res,
const vector2 * v,
const vector2 * min,
const vector2 * max )

Clamps vector v component-wise between min and max.

Parameters
resOutput vector.
vInput vector to clamp.
minMinimum bounds vector.
maxMaximum bounds vector.

Definition at line 331 of file vector2_ptr.c.

References VECMAT_FMAX, VECMAT_FMIN, vector2::x, and vector2::y.

Referenced by vec2_clamp().

◆ vec2_clamp_scalar()

vector2 vec2_clamp_scalar ( const vector2 v,
const vm_float_t min,
const vm_float_t max )

Clamps each component to the scalar range [min, max].

See vec2_clamp_scalar_ptr instead.

Parameters
vInput vector.
minLower bound.
maxUpper bound.
Returns
The resulting vector2.

Definition at line 576 of file vector2.c.

References vec2_clamp_scalar_ptr().

◆ vec2_clamp_scalar_ptr()

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].

Parameters
resOutput vector.
vInput vector.
minLower bound.
maxUpper bound.

Definition at line 398 of file vector2_ptr.c.

References VECMAT_FMAX, VECMAT_FMIN, vector2::x, and vector2::y.

Referenced by vec2_clamp_scalar(), and vec2_saturate_ptr().

◆ vec2_cross()

vector2 vec2_cross ( const vector2 a,
const vector2 b )

Computes the 2D cross-product as a vector.

See vec2_cross_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The cross-product vector2.

Definition at line 206 of file vector2.c.

References vec2_cross_ptr().

◆ vec2_cross_ptr()

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.

Parameters
resOutput vector.
aInput vector a.
bInput vector b.

Definition at line 220 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_cross().

◆ vec2_cross_scalar()

vm_float_t vec2_cross_scalar ( const vector2 a,
const vector2 b )

Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 792 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_distance()

vm_float_t vec2_distance ( const vector2 a,
const vector2 b )

Computes the Euclidean distance between two vectors (treated as points).

Parameters
aThe first point.
bThe second point.
Returns
The distance scalar.

Definition at line 476 of file vector2.c.

References VECMAT_SQRT, vector2::x, and vector2::y.

◆ vec2_distance_squared()

vm_float_t vec2_distance_squared ( const vector2 a,
const vector2 b )

Returns the squared Euclidean distance between a and b.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 778 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_div()

vector2 vec2_div ( const vector2 a,
const vector2 b )

Divides two vectors component-wise.

See vec2_div_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector2.

Definition at line 527 of file vector2.c.

References vec2_div_ptr().

◆ vec2_div_ptr()

void vec2_div_ptr ( vector2 * res,
const vector2 * a,
const vector2 * b )

Divides two vectors component-wise.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 358 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_div().

◆ vec2_div_scalar()

vector2 vec2_div_scalar ( const vector2 v,
const vm_float_t s )

Divides a vector by a scalar component-wise.

See vec2_div_scalar_ptr instead.

Parameters
vThe input vector.
sThe scalar divisor (non-zero).
Returns
The divided vector2.

Definition at line 144 of file vector2.c.

References vec2_div_scalar_ptr().

◆ vec2_div_scalar_ptr()

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.

Parameters
resOutput vector.
vInput vector.
sInput scalar.

Definition at line 53 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_div_scalar().

◆ vec2_dot()

vm_float_t vec2_dot ( const vector2 a,
const vector2 b )

Computes the dot product of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The dot product scalar.

Definition at line 439 of file vector2.c.

References vector2::x, and vector2::y.

Referenced by vec2_angle(), vec2_length(), vec2_length_squared(), vec2_project_ptr(), vec2_reflect_ptr(), vec2_refract_ptr(), and vec2_slide_ptr().

◆ vec2_eq()

bool vec2_eq ( const vector2 a,
const vector2 b )

Returns true if two vectors are equal within VECMAT_EPSILON.

Parameters
aFirst vector.
bSecond vector.
Returns
True if a and b are approximately equal.

Definition at line 37 of file vecmat.c.

References VECMAT_EPSILON, VECMAT_FABS, vector2::x, and vector2::y.

◆ vec2_floor()

vector2 vec2_floor ( const vector2 v)

Applies floor to each component.

See vec2_floor_ptr instead.

Parameters
vThe input vector.
Returns
The floored vector2.

Definition at line 283 of file vector2.c.

References vec2_floor_ptr().

◆ vec2_floor_ptr()

void vec2_floor_ptr ( vector2 * res,
const vector2 * v )

Applies the floor function to each component of vector v, storing the result in res.

Parameters
resOutput vector.
vInput vector.

Definition at line 167 of file vector2_ptr.c.

References VECMAT_FLOOR, vector2::x, and vector2::y.

Referenced by vec2_floor().

◆ vec2_fract()

vector2 vec2_fract ( const vector2 v)

Returns the fractional part of each component.

See vec2_fract_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector2.

Definition at line 606 of file vector2.c.

References vec2_fract_ptr().

◆ vec2_fract_ptr()

void vec2_fract_ptr ( vector2 * res,
const vector2 * v )

Returns the fractional part of each component.

Parameters
resOutput vector.
vInput vector.

Definition at line 421 of file vector2_ptr.c.

References VECMAT_FLOOR, vector2::x, and vector2::y.

Referenced by vec2_fract().

◆ vec2_from()

vector2 vec2_from ( const vector2i * v)

Converts a vector2i to a vector2.

Parameters
vInput integer vector.
Returns
The resulting vector2.

Definition at line 268 of file vecmat.c.

References vector2i::x, and vector2i::y.

◆ vec2_from_angle()

vector2 vec2_from_angle ( const vm_float_t angle)

Returns the unit vector at the given angle in radians.

See vec2_from_angle_ptr instead.

Parameters
angleAngle in radians.
Returns
The resulting vector2.

Definition at line 667 of file vector2.c.

References VECMAT_COS, and VECMAT_SIN.

◆ vec2_heading()

vm_float_t vec2_heading ( const vector2 v)

Returns the heading angle of the vector in radians.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 803 of file vector2.c.

References VECMAT_ATAN2, vector2::x, and vector2::y.

◆ vec2_is_normalized()

bool vec2_is_normalized ( const vector2 v)

Returns true if the vector has unit length.

Parameters
vInput vector.
Returns
True if the vector has unit length.

Definition at line 858 of file vector2.c.

References vec2_length_squared(), VECMAT_EPSILON, and VECMAT_FABS.

◆ vec2_is_zero()

bool vec2_is_zero ( const vector2 v)

Returns true if every component is zero.

Parameters
vInput vector.
Returns
True if every component is zero.

Definition at line 847 of file vector2.c.

References VECMAT_EPSILON, VECMAT_FABS, vector2::x, and vector2::y.

◆ vec2_length()

vm_float_t vec2_length ( const vector2 v)

Computes the length (magnitude) of the vector.

Parameters
vThe input vector.
Returns
The length scalar.

Definition at line 450 of file vector2.c.

References vec2_dot(), and VECMAT_SQRT.

Referenced by vec2_angle(), vec2_limit_length_ptr(), and vec2_normalize_ptr().

◆ vec2_length_chebyshev()

vm_float_t vec2_length_chebyshev ( const vector2 v)

Returns the Chebyshev (L-inf) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 766 of file vector2.c.

References VECMAT_FABS, VECMAT_FMAX, vector2::x, and vector2::y.

◆ vec2_length_manhattan()

vm_float_t vec2_length_manhattan ( const vector2 v)

Returns the Manhattan (L1) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 755 of file vector2.c.

References VECMAT_FABS, vector2::x, and vector2::y.

◆ vec2_length_squared()

vm_float_t vec2_length_squared ( const vector2 v)

Returns the squared Euclidean length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 744 of file vector2.c.

References vec2_dot().

Referenced by vec2_is_normalized().

◆ vec2_lerp()

vector2 vec2_lerp ( const vector2 a,
const vector2 b,
const vm_float_t t )

Linearly interpolates from a to b by t.

See vec2_lerp_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
tInterpolation factor.
Returns
The resulting vector2.

Definition at line 511 of file vector2.c.

References vec2_lerp_ptr().

◆ vec2_lerp_ptr()

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.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.
tInterpolation factor.

Definition at line 345 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_lerp().

◆ vec2_limit_length()

vector2 vec2_limit_length ( const vector2 v,
const vm_float_t max_len )

Clamps the vector length to max_len.

See vec2_limit_length_ptr instead.

Parameters
vInput vector.
max_lenMaximum length.
Returns
The resulting vector2.

Definition at line 715 of file vector2.c.

References vec2_limit_length_ptr().

◆ vec2_limit_length_ptr()

void vec2_limit_length_ptr ( vector2 * res,
const vector2 * v,
const vm_float_t max_len )

Clamps the vector length to max_len.

Parameters
resOutput vector.
vInput vector.
max_lenMaximum length.

Definition at line 511 of file vector2_ptr.c.

References vec2_length(), vector2::x, and vector2::y.

Referenced by vec2_limit_length().

◆ vec2_max()

vector2 vec2_max ( const vector2 a,
const vector2 b )

Returns the component-wise maximum of two vectors.

See vec2_max_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The maximum vector2.

Definition at line 253 of file vector2.c.

References vec2_max_ptr().

◆ vec2_max_component()

vm_float_t vec2_max_component ( const vector2 v)

Returns the largest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 825 of file vector2.c.

References VECMAT_FMAX, vector2::x, and vector2::y.

◆ vec2_max_ptr()

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.

Parameters
resOutput vector.
aInput vector a.
bInput vector b.

Definition at line 141 of file vector2_ptr.c.

References VECMAT_FMAX, vector2::x, and vector2::y.

Referenced by vec2_max().

◆ vec2_min()

vector2 vec2_min ( const vector2 a,
const vector2 b )

Returns the component-wise minimum of two vectors.

See vec2_min_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The minimum vector2.

Definition at line 237 of file vector2.c.

References vec2_min_ptr().

◆ vec2_min_component()

vm_float_t vec2_min_component ( const vector2 v)

Returns the smallest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 814 of file vector2.c.

References VECMAT_FMIN, vector2::x, and vector2::y.

◆ vec2_min_ptr()

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.

Parameters
resOutput vector.
aInput vector a.
bInput vector b.

Definition at line 127 of file vector2_ptr.c.

References VECMAT_FMIN, vector2::x, and vector2::y.

Referenced by vec2_min().

◆ vec2_move_toward()

vector2 vec2_move_toward ( const vector2 current,
const vector2 target,
const vm_float_t max_delta )

Moves current toward target by at most max_delta.

See vec2_move_toward_ptr instead.

Parameters
currentCurrent position.
targetTarget position.
max_deltaMaximum distance to move.
Returns
The resulting vector2.

Definition at line 699 of file vector2.c.

References vec2_move_toward_ptr().

◆ vec2_move_toward_ptr()

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.

Parameters
resOutput vector.
currentCurrent position.
targetTarget position.
max_deltaMaximum distance to move.

Definition at line 490 of file vector2_ptr.c.

References VECMAT_SQRT, vector2::x, and vector2::y.

Referenced by vec2_move_toward().

◆ vec2_mul()

vector2 vec2_mul ( const vector2 a,
const vector2 b )

Multiplies two vectors component-wise (Hadamard product).

See vec2_mul_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The product vector2.

Definition at line 160 of file vector2.c.

References vec2_mul_ptr().

◆ vec2_mul_ptr()

void vec2_mul_ptr ( vector2 * res,
const vector2 * a,
const vector2 * b )

Multiplies vectors a and b component-wise, storing the result in res.

Parameters
resOutput vector.
aInput vector a.
bInput vector b.

Definition at line 70 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_mul().

◆ vec2_mul_scalar()

vector2 vec2_mul_scalar ( const vector2 v,
const vm_float_t s )

Multiplies a vector by a scalar component-wise.

See vec2_mul_scalar_ptr instead.

Parameters
vThe input vector.
sThe scalar multiplier.
Returns
The scaled vector2.

Definition at line 128 of file vector2.c.

References vec2_mul_scalar_ptr().

◆ vec2_mul_scalar_ptr()

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.

Parameters
resOutput vector.
vInput vector.
sInput scalar.

Definition at line 40 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_mul_scalar().

◆ vec2_near()

bool vec2_near ( const vector2 a,
const vector2 b,
const vm_float_t eps )

Returns true if a and b are within eps of each other.

Parameters
aFirst input vector.
bSecond input vector.
epsDistance tolerance.
Returns
True if a and b are within eps.

Definition at line 871 of file vector2.c.

References VECMAT_FABS, vector2::x, and vector2::y.

◆ vec2_neg()

vector2 vec2_neg ( const vector2 v)

Negates the vector (multiplies each component by -1.0f).

See vec2_neg_ptr instead.

Parameters
vThe input vector.
Returns
The negated vector2.

Definition at line 175 of file vector2.c.

References vec2_neg_ptr().

◆ vec2_neg_ptr()

void vec2_neg_ptr ( vector2 * res,
const vector2 * v )

Negates the components of vector v, storing the result in res.

Parameters
resOutput vector.
vInput vector.

Definition at line 82 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_neg().

◆ vec2_normalize()

vector2 vec2_normalize ( const vector2 v)

Normalizes the vector to unit length.

See vec2_normalize_ptr instead.

Parameters
vThe input vector.
Returns
The normalized vector2 (unchanged if zero length).

Definition at line 221 of file vector2.c.

References vec2_normalize_ptr().

◆ vec2_normalize_ptr()

void vec2_normalize_ptr ( vector2 * res,
const vector2 * v )

Normalizes vector v to unit length, storing the result in res.

Parameters
resOutput vector.
vInput vector.

Definition at line 107 of file vector2_ptr.c.

References vec2_length(), vector2::x, and vector2::y.

Referenced by vec2_normalize(), and vec2i_normalize_to_vec2_ptr().

◆ vec2_one()

vector2 vec2_one ( void )

Returns a vector2 with both components set to 1.0f.

Returns
The one vector2.

Definition at line 22 of file vector2.c.

◆ vec2_perpendicular()

vector2 vec2_perpendicular ( const vector2 v)

Returns the perpendicular vector (90 degrees counterclockwise).

See vec2_perpendicular_ptr instead.

Parameters
vThe input vector.
Returns
The perpendicular vector2.

Definition at line 329 of file vector2.c.

References vec2_perpendicular_ptr().

◆ vec2_perpendicular_ptr()

void vec2_perpendicular_ptr ( vector2 * res,
const vector2 * v )

Computes the perpendicular vector to v (90 degrees counterclockwise rotation), storing the result in res.

Parameters
resOutput vector.
vInput vector.

Definition at line 206 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_perpendicular().

◆ vec2_project()

vector2 vec2_project ( const vector2 a,
const vector2 b )

Projects the first vector onto the second.

See vec2_project_ptr instead.

Parameters
aThe vector to project.
bThe projection direction vector.
Returns
The projected vector2.

Definition at line 361 of file vector2.c.

References vec2_project_ptr().

◆ vec2_project_ptr()

void vec2_project_ptr ( vector2 * res,
const vector2 * a,
const vector2 * b )

Projects vector a onto vector b (scalar projection scaled by b).

Parameters
resThe output projected vector.
aThe vector to project.
bThe direction vector (non-zero length recommended).

Definition at line 261 of file vector2_ptr.c.

References vec2_dot(), vector2::x, and vector2::y.

Referenced by vec2_project(), and vec2_reject_ptr().

◆ vec2_reflect()

vector2 vec2_reflect ( const vector2 v,
const vector2 normal )

Reflects vector v across the normal, storing the result in res.

See vec2_reflect_ptr instead.

Parameters
vThe incident vector.
normalThe unit normal vector.
Returns
The reflected vector2.

Definition at line 345 of file vector2.c.

References vec2_reflect_ptr().

◆ vec2_reflect_ptr()

void vec2_reflect_ptr ( vector2 * res,
const vector2 * v,
const vector2 * normal )

Reflects vector v across the normal, storing the result in res.

Parameters
resOutput vector.
vInput incident vector.
normalInput surface normal.

Definition at line 247 of file vector2_ptr.c.

References vec2_dot(), vector2::x, and vector2::y.

Referenced by vec2_reflect().

◆ vec2_refract()

vector2 vec2_refract ( const vector2 incident,
const vector2 normal,
const vm_float_t eta )

Computes the refraction of incident across normal with ratio eta.

See vec2_refract_ptr instead.

Parameters
incidentIncident vector.
normalSurface normal.
etaRatio of indices of refraction.
Returns
The resulting vector2.

Definition at line 623 of file vector2.c.

References vec2_refract_ptr().

◆ vec2_refract_ptr()

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.

Parameters
resOutput vector.
incidentIncident vector.
normalSurface normal.
etaRatio of indices of refraction.

Definition at line 435 of file vector2_ptr.c.

References vec2_dot(), VECMAT_SQRT, vector2::x, and vector2::y.

Referenced by vec2_refract().

◆ vec2_reject()

vector2 vec2_reject ( const vector2 a,
const vector2 b )

Returns the component of a orthogonal to b.

See vec2_reject_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector2.

Definition at line 639 of file vector2.c.

References vec2_reject_ptr().

◆ vec2_reject_ptr()

void vec2_reject_ptr ( vector2 * res,
const vector2 * a,
const vector2 * b )

Returns the component of a orthogonal to b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 456 of file vector2_ptr.c.

References vec2_project_ptr(), vector2::x, and vector2::y.

Referenced by vec2_reject().

◆ vec2_rotate()

vector2 vec2_rotate ( const vector2 v,
const vm_float_t angle )

Rotates the input vector counterclockwise by the given angle (radians).

See vec2_rotate_ptr instead.

Parameters
vThe input vector.
angleThe rotation angle in radians.
Returns
The rotated vector2.

Definition at line 392 of file vector2.c.

References vec2_rotate_ptr().

◆ vec2_rotate_around()

vector2 vec2_rotate_around ( const vector2 v,
const vector2 pivot,
const vm_float_t angle )

Rotates v around pivot by angle radians.

See vec2_rotate_around_ptr instead.

Parameters
vInput vector.
pivotRotation pivot.
angleAngle in radians.
Returns
The resulting vector2.

Definition at line 682 of file vector2.c.

References vec2_rotate_around_ptr().

◆ vec2_rotate_around_ptr()

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.

Parameters
resOutput vector.
vInput vector.
pivotRotation pivot.
angleAngle in radians.

Definition at line 472 of file vector2_ptr.c.

References vec2_rotate_ptr(), vector2::x, and vector2::y.

Referenced by vec2_rotate_around().

◆ vec2_rotate_ptr()

void vec2_rotate_ptr ( vector2 * result,
const vector2 * v,
const vm_float_t angle )

Rotates the input vector counterclockwise by the given angle (radians).

Uses standard 2D rotation matrix.

Parameters
resultThe output rotated vector.
vThe input vector.
angleThe rotation angle in radians.

Definition at line 297 of file vector2_ptr.c.

References VECMAT_COS, VECMAT_SIN, vector2::x, and vector2::y.

Referenced by vec2_rotate(), and vec2_rotate_around_ptr().

◆ vec2_round()

vector2 vec2_round ( const vector2 v)

Applies round to each component.

See vec2_round_ptr instead.

Parameters
vThe input vector.
Returns
The rounded vector2.

Definition at line 313 of file vector2.c.

References vec2_round_ptr().

◆ vec2_round_ptr()

void vec2_round_ptr ( vector2 * res,
const vector2 * v )

Applies the round function to each component of vector v, storing the result in res.

Parameters
resOutput vector.
vInput vector.

Definition at line 193 of file vector2_ptr.c.

References VECMAT_ROUND, vector2::x, and vector2::y.

Referenced by vec2_round().

◆ vec2_saturate()

vector2 vec2_saturate ( const vector2 v)

Clamps each component to the range [0, 1].

See vec2_saturate_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector2.

Definition at line 591 of file vector2.c.

References vec2_saturate_ptr().

◆ vec2_saturate_ptr()

void vec2_saturate_ptr ( vector2 * res,
const vector2 * v )

Clamps each component to the range [0, 1].

Parameters
resOutput vector.
vInput vector.

Definition at line 410 of file vector2_ptr.c.

References vec2_clamp_scalar_ptr().

Referenced by vec2_saturate().

◆ vec2_scale()

vector2 vec2_scale ( const vector2 v,
const vm_float_t s )

Scales a vector by a scalar component-wise.

See vec2_scale_ptr instead.

Parameters
vThe input vector.
sThe scalar multiplier.
Returns
The scaled vector2.

Definition at line 80 of file vector2.c.

References vec2_scale_ptr().

◆ vec2_scale_ptr()

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.

Parameters
resOutput vector.
vInput vector.
sInput scalar.

Definition at line 234 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_scale().

◆ vec2_sign()

vector2 vec2_sign ( const vector2 v)

Returns the sign of each component (+1.0f, -1.0f, or 0.0f).

See vec2_sign_ptr instead.

Parameters
vThe input vector.
Returns
The sign vector2.

Definition at line 268 of file vector2.c.

References vec2_sign_ptr().

◆ vec2_sign_ptr()

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).

Parameters
resOutput vector.
vInput vector.

Definition at line 154 of file vector2_ptr.c.

References VECMAT_COPYSIGN, vector2::x, and vector2::y.

Referenced by vec2_sign().

◆ vec2_slide()

vector2 vec2_slide ( const vector2 v,
const vector2 normal )

Slides the input vector tangent to the normal (removes normal component).

See vec2_slide_ptr instead.

Parameters
vThe input vector.
normalThe unit normal vector.
Returns
The slid vector2.

Definition at line 408 of file vector2.c.

References vec2_slide_ptr().

◆ vec2_slide_ptr()

void vec2_slide_ptr ( vector2 * result,
const vector2 * v,
const vector2 * normal )

Slides the input vector tangent to the normal (removes normal component).

Formula: v - dot(v, normal) * normal (assumes unit normal).

Parameters
resultThe output slid vector.
vThe input vector.
normalThe unit normal vector.

Definition at line 316 of file vector2_ptr.c.

References vec2_dot(), vector2::x, and vector2::y.

Referenced by vec2_slide().

◆ vec2_splat()

vector2 vec2_splat ( const vm_float_t s)

Returns a vector with every component set to s.

See vec2_splat_ptr instead.

Parameters
sScalar value.
Returns
The resulting vector2.

Definition at line 654 of file vector2.c.

◆ vec2_sub()

vector2 vec2_sub ( const vector2 a,
const vector2 b )

Subtracts the second vector from the first component-wise.

See vec2_sub_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The difference vector2.

Definition at line 112 of file vector2.c.

References vec2_sub_ptr().

◆ vec2_sub_ptr()

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.

Parameters
resOutput vector.
aInput vector a.
bInput vector b.

Definition at line 27 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_sub().

◆ vec2_sub_scalar()

vector2 vec2_sub_scalar ( const vector2 v,
const vm_float_t s )

Subtracts a scalar from each component.

See vec2_sub_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector2.

Definition at line 559 of file vector2.c.

References vec2_sub_scalar_ptr().

◆ vec2_sub_scalar_ptr()

void vec2_sub_scalar_ptr ( vector2 * res,
const vector2 * v,
const vm_float_t s )

Subtracts a scalar from each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 384 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_sub_scalar().

◆ vec2_sum()

vm_float_t vec2_sum ( const vector2 v)

Returns the sum of all components.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 836 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_tangent()

vector2 vec2_tangent ( const vector2 v)

Returns the tangent vector perpendicular to the input (90 degrees clockwise).

See vec2_tangent_ptr instead.

Parameters
vThe input vector.
Returns
The tangent vector2.

Definition at line 376 of file vector2.c.

References vec2_tangent_ptr().

◆ vec2_tangent_ptr()

void vec2_tangent_ptr ( vector2 * res,
const vector2 * v )

Computes a tangent vector perpendicular to the input (90 degrees clockwise).

Equivalent to (v.y, -v.x).

Parameters
resThe output tangent vector.
vThe input vector.

Definition at line 282 of file vector2_ptr.c.

References vector2::x, and vector2::y.

Referenced by vec2_tangent().

◆ vec2_to_vec3()

vector3 vec2_to_vec3 ( const vector2 v,
const vm_float_t z )

Converts a vector2 to a vector3 using z.

See vec2_to_vec3_ptr instead.

Parameters
vInput vector.
zZ component.
Returns
The resulting vector3.

Definition at line 731 of file vector2.c.

References vec2_to_vec3_ptr().

◆ vec2_to_vec3_ptr()

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.

Parameters
resOutput vector.
vInput vector.
zZ component.

Definition at line 530 of file vector2_ptr.c.

References vector2::x, vector3::x, vector2::y, vector3::y, and vector3::z.

Referenced by vec2_to_vec3().

◆ vec2_x_axis()

vector2 vec2_x_axis ( const vm_float_t x)

Returns a vector2 along the x-axis (y = 0.0f).

Parameters
xThe x component value.
Returns
The x-axis vector2.

Definition at line 33 of file vector2.c.

◆ vec2_x_scale()

vector2 vec2_x_scale ( const vm_float_t x)

Returns a vector2 representing x-axis scaling (y = 1.0f).

Parameters
xThe x scale factor.
Returns
The x-scale vector2.

Definition at line 55 of file vector2.c.

◆ vec2_y_axis()

vector2 vec2_y_axis ( const vm_float_t y)

Returns a vector2 along the y-axis (x = 0.0f).

Parameters
yThe y component value.
Returns
The y-axis vector2.

Definition at line 44 of file vector2.c.

◆ vec2_y_scale()

vector2 vec2_y_scale ( const vm_float_t y)

Returns a vector2 representing y-axis scaling (x = 1.0f).

Parameters
yThe y scale factor.
Returns
The y-scale vector2.

Definition at line 66 of file vector2.c.

◆ vec2_zero()

vector2 vec2_zero ( void )

Returns a vector2 with both components set to 0.0f.

Returns
The zero vector2.

Definition at line 12 of file vector2.c.

◆ vec2i()

vector2i vec2i ( const vm_int_t x,
const vm_int_t y )

Constructs a vector2i from x and y.

Parameters
xX component.
yY component.
Returns
The resulting vector2i.

Definition at line 280 of file vecmat.c.

◆ vec2i_abs()

vector2i vec2i_abs ( const vector2i v)

Returns the absolute values of each component.

See vec2i_abs_ptr instead.

Parameters
vThe input vector.
Returns
The absolute value vector2i.

Definition at line 175 of file vector2i.c.

References vec2i_abs_ptr().

◆ vec2i_abs_ptr()

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.

Parameters
resPointer to result vector2i.
vPointer to vector2i.

Definition at line 101 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_abs().

◆ vec2i_add()

vector2i vec2i_add ( const vector2i a,
const vector2i b )

Adds two vectors component-wise.

See vec2i_add_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The sum vector2i.

Definition at line 80 of file vector2i.c.

References vec2i_add_ptr().

◆ vec2i_add_assign()

void vec2i_add_assign ( vector2i * dest,
const vector2i * src )

Adds src to dest in place.

Parameters
destDestination vector.
srcVector to add.

Definition at line 316 of file vecmat.c.

References vector2i::x, and vector2i::y.

◆ vec2i_add_ptr()

void vec2i_add_ptr ( vector2i * res,
const vector2i * a,
const vector2i * b )

Adds vectors a and b component-wise, storing the result in res.

Parameters
resPointer to result vector2i.
aPointer to first vector2i.
bPointer to second vector2i.

Definition at line 15 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_add().

◆ vec2i_add_scalar()

vector2i vec2i_add_scalar ( const vector2i v,
const vm_int_t s )

Adds a scalar to each component.

See vec2i_add_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector2i.

Definition at line 405 of file vector2i.c.

References vec2i_add_scalar_ptr().

◆ vec2i_add_scalar_ptr()

void vec2i_add_scalar_ptr ( vector2i * res,
const vector2i * v,
const vm_int_t s )

Adds a scalar to each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 270 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_add_scalar().

◆ vec2i_angle()

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, dot).

Returns 0.0f if either vector has zero length.

Parameters
aThe first vector.
bThe second vector.
Returns
The signed angle scalar.

Definition at line 322 of file vector2i.c.

References vec2i_dot(), vec2i_length(), VECMAT_ATAN2, vector2i::x, and vector2i::y.

◆ vec2i_aspect_ratio()

vm_float_t vec2i_aspect_ratio ( const vector2i v)

Computes the aspect ratio of the vector (x / y).

Returns 0.0f if y == 0.

Parameters
vThe input vector.
Returns
The aspect ratio scalar.

Definition at line 340 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_assign()

void vec2i_assign ( vector2i * dest,
const vector2i * src )

Copies src into dest.

Parameters
destDestination vector.
srcSource vector.

Definition at line 291 of file vecmat.c.

References vector2i::x, and vector2i::y.

◆ vec2i_assign_xy()

void vec2i_assign_xy ( vector2i * dest,
const vm_int_t x,
const vm_int_t y )

Assigns x and y to dest.

Parameters
destDestination vector.
xX component.
yY component.

Definition at line 304 of file vecmat.c.

References vector2i::x, and vector2i::y.

◆ vec2i_clamp()

vector2i vec2i_clamp ( const vector2i v,
const vector2i min,
const vector2i max )

Clamps each component between min and max.

See vec2i_clamp_ptr instead.

Parameters
vInput vector.
minLower bound.
maxUpper bound.
Returns
The resulting vector2i.

Definition at line 373 of file vector2i.c.

References vec2i_clamp_ptr().

◆ vec2i_clamp_ptr()

void vec2i_clamp_ptr ( vector2i * res,
const vector2i * v,
const vector2i * min,
const vector2i * max )

Clamps each component between min and max.

Parameters
resOutput vector.
vInput vector.
minLower bound.
maxUpper bound.

Definition at line 244 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_clamp().

◆ vec2i_cross()

vector2i vec2i_cross ( const vector2i a,
const vector2i b )

Computes the 2D cross-product as a vector.

See vec2i_cross_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The cross-product vector2i.

Definition at line 268 of file vector2i.c.

References vec2i_cross_ptr().

◆ vec2i_cross_ptr()

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.

Parameters
resPointer to result vector2i.
aPointer to first vector2i.
bPointer to second vector2i.

Definition at line 189 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_cross().

◆ vec2i_cross_scalar()

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).

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 527 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_distance()

vm_float_t vec2i_distance ( const vector2i a,
const vector2i b )

Computes the Euclidean distance between two vectors (treated as points).

Parameters
aThe first point.
bThe second point.
Returns
The distance scalar.

Definition at line 305 of file vector2i.c.

References VECMAT_SQRT, vector2i::x, and vector2i::y.

◆ vec2i_distance_squared()

vm_int_t vec2i_distance_squared ( const vector2i a,
const vector2i b )

Returns the squared Euclidean distance between a and b.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 550 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_div()

vector2i vec2i_div ( const vector2i a,
const vector2i b )

Divides two vectors component-wise.

See vec2i_div_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector2i.

Definition at line 389 of file vector2i.c.

References vec2i_div_ptr().

◆ vec2i_div_floor()

vector2i vec2i_div_floor ( const vector2i a,
const vector2i b )

Component-wise floored division of a by b.

See vec2i_div_floor_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector2i.

Definition at line 453 of file vector2i.c.

References vec2i_div_floor_ptr().

◆ vec2i_div_floor_ptr()

void vec2i_div_floor_ptr ( vector2i * res,
const vector2i * a,
const vector2i * b )

Component-wise floored division of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 309 of file vector2i_ptr.c.

References vm_div_floor(), vector2i::x, and vector2i::y.

Referenced by vec2i_div_floor().

◆ vec2i_div_ptr()

void vec2i_div_ptr ( vector2i * res,
const vector2i * a,
const vector2i * b )

Divides two vectors component-wise.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 257 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_div().

◆ vec2i_div_scalar()

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).

See vec2i_div_scalar_ptr instead.

Parameters
vThe input vector.
sThe scalar divisor (sets to zero vector if zero).
Returns
The divided vector2i.

Definition at line 129 of file vector2i.c.

References vec2i_div_scalar_ptr().

◆ vec2i_div_scalar_ptr()

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 res.

Sets vector to zero if s == 0.

Parameters
resPointer to result vector2i.
vPointer to vector2i.
sScalar.

Definition at line 57 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_div_scalar().

◆ vec2i_dot()

vm_int_t vec2i_dot ( const vector2i a,
const vector2i b )

Computes the dot product of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The dot product (vm_int_t; may overflow).

Definition at line 282 of file vector2i.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_angle(), vec2i_length(), and vec2i_length_squared().

◆ vec2i_eq()

bool vec2i_eq ( const vector2i a,
const vector2i b )

Returns true if two vectors are exactly equal.

Parameters
aFirst vector.
bSecond vector.
Returns
True if a and b are equal.

Definition at line 79 of file vecmat.c.

References vector2i::x, and vector2i::y.

◆ vec2i_from()

vector2i vec2i_from ( const vector2 * v)

Converts a vector2 to a vector2i by truncation.

Parameters
vInput vector.
Returns
The resulting vector2i.

Definition at line 328 of file vecmat.c.

References vector2::x, and vector2::y.

◆ vec2i_from_floored()

vector2i vec2i_from_floored ( const vector2 * v)

Converts a vector2 to a vector2i by flooring each component.

Parameters
vInput vector.
Returns
The resulting vector2i.

Definition at line 339 of file vecmat.c.

References VECMAT_FLOOR, vector2::x, and vector2::y.

◆ vec2i_from_rounded()

vector2i vec2i_from_rounded ( const vector2 * v)

Converts a vector2 to a vector2i by rounding each component.

Parameters
vInput vector.
Returns
The resulting vector2i.

Definition at line 350 of file vecmat.c.

References VECMAT_ROUND, vector2::x, and vector2::y.

◆ vec2i_is_zero()

bool vec2i_is_zero ( const vector2i v)

Returns true if every component is zero.

Parameters
vInput vector.
Returns
True if every component is zero.

Definition at line 622 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_length()

vm_float_t vec2i_length ( const vector2i v)

Computes the length (magnitude) of the vector.

Parameters
vThe input vector.
Returns
The length scalar.

Definition at line 293 of file vector2i.c.

References vec2i_dot(), and VECMAT_SQRT.

Referenced by vec2i_angle(), and vec2i_normalize_ptr().

◆ vec2i_length_chebyshev()

vm_int_t vec2i_length_chebyshev ( const vector2i v)

Returns the Chebyshev (L-inf) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 576 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_length_manhattan()

vm_int_t vec2i_length_manhattan ( const vector2i v)

Returns the Manhattan (L1) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 563 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_length_squared()

vm_int_t vec2i_length_squared ( const vector2i v)

Returns the squared Euclidean length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 538 of file vector2i.c.

References vec2i_dot().

◆ vec2i_lerp()

vector2i vec2i_lerp ( const vector2i a,
const vector2i b,
const vm_float_t t )

Linearly interpolates from a to b by t.

See vec2i_lerp_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
tInterpolation factor.
Returns
The resulting vector2i.

Definition at line 356 of file vector2i.c.

References vec2i_lerp_ptr().

◆ vec2i_lerp_ptr()

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.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.
tInterpolation factor.

Definition at line 230 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_lerp().

◆ vec2i_max()

vector2i vec2i_max ( const vector2i a,
const vector2i b )

Returns the component-wise maximum of two vectors.

See vec2i_max_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The maximum vector2i.

Definition at line 222 of file vector2i.c.

References vec2i_max_ptr().

◆ vec2i_max_component()

vm_int_t vec2i_max_component ( const vector2i v)

Returns the largest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 600 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_max_ptr()

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.

Parameters
resPointer to result vector2i.
aPointer to first vector2i.
bPointer to second vector2i.

Definition at line 149 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_max().

◆ vec2i_min()

vector2i vec2i_min ( const vector2i a,
const vector2i b )

Returns the component-wise minimum of two vectors.

See vec2i_min_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The minimum vector2i.

Definition at line 206 of file vector2i.c.

References vec2i_min_ptr().

◆ vec2i_min_component()

vm_int_t vec2i_min_component ( const vector2i v)

Returns the smallest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 589 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_min_ptr()

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.

Parameters
resPointer to result vector2i.
aPointer to first vector2i.
bPointer to second vector2i.

Definition at line 135 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_min().

◆ vec2i_mod()

vector2i vec2i_mod ( const vector2i a,
const vector2i b )

Component-wise floor modulo of a by b.

See vec2i_mod_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector2i.

Definition at line 437 of file vector2i.c.

References vec2i_mod_ptr().

◆ vec2i_mod_ptr()

void vec2i_mod_ptr ( vector2i * res,
const vector2i * a,
const vector2i * b )

Component-wise floor modulo of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 296 of file vector2i_ptr.c.

References vm_mod_floor(), vector2i::x, and vector2i::y.

Referenced by vec2i_mod().

◆ vec2i_mul()

vector2i vec2i_mul ( const vector2i a,
const vector2i b )

Multiplies two vectors component-wise (Hadamard product).

See vec2i_mul_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The product vector2i.

Definition at line 145 of file vector2i.c.

References vec2i_mul_ptr().

◆ vec2i_mul_ptr()

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.

Parameters
resPointer to result vector2i.
aPointer to first vector2i.
bPointer to second vector2i.

Definition at line 76 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_mul().

◆ vec2i_mul_scalar()

vector2i vec2i_mul_scalar ( const vector2i v,
const vm_int_t s )

Multiplies a vector by a scalar component-wise.

See vec2i_mul_scalar_ptr instead.

Parameters
vThe input vector.
sThe scalar multiplier.
Returns
The scaled vector2i.

Definition at line 112 of file vector2i.c.

References vec2i_mul_scalar_ptr().

◆ vec2i_mul_scalar_ptr()

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.

Parameters
resPointer to result vector2i.
vPointer to vector2i.
sScalar.

Definition at line 41 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_mul_scalar().

◆ vec2i_neg()

vector2i vec2i_neg ( const vector2i v)

Negates the vector (multiplies each component by -1).

See vec2i_neg_ptr instead.

Parameters
vThe input vector.
Returns
The negated vector2i.

Definition at line 160 of file vector2i.c.

References vec2i_neg_ptr().

◆ vec2i_neg_ptr()

void vec2i_neg_ptr ( vector2i * res,
const vector2i * v )

Negates the components of vector v, storing the result in res.

Parameters
resPointer to result vector2i.
vPointer to vector2i.

Definition at line 88 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_neg().

◆ vec2i_normalize()

vector2i vec2i_normalize ( const vector2i v)

Normalizes the vector to approximate unit length (float length, truncated to int).

See vec2i_normalize_ptr instead.

Parameters
vThe input vector.
Returns
The normalized vector2i (unchanged if zero length).

Definition at line 190 of file vector2i.c.

References vec2i_normalize_ptr().

◆ vec2i_normalize_ptr()

void vec2i_normalize_ptr ( vector2i * res,
const vector2i * v )

Normalizes vector v to approximate unit length (float length computation, truncated to int), storing the result in res.

Copies v unchanged if the length is zero.

Parameters
resPointer to result vector2i.
vPointer to vector2i.

Definition at line 116 of file vector2i_ptr.c.

References vec2i_length(), vector2i::x, and vector2i::y.

Referenced by vec2i_normalize().

◆ vec2i_normalize_to_vec2()

vector2 vec2i_normalize_to_vec2 ( const vector2i v)

Converts to a unit-length vector2.

See vec2i_normalize_to_vec2_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector2.

Definition at line 513 of file vector2i.c.

References vec2i_normalize_to_vec2_ptr().

◆ vec2i_normalize_to_vec2_ptr()

void vec2i_normalize_to_vec2_ptr ( vector2 * res,
const vector2i * v )

Converts to a unit-length vector2.

Parameters
resOutput vector.
vInput vector.

Definition at line 348 of file vector2i_ptr.c.

References vec2_normalize_ptr(), vector2i::x, and vector2i::y.

Referenced by vec2i_normalize_to_vec2().

◆ vec2i_one()

vector2i vec2i_one ( void )

Returns a vector2i with both components set to 1.

Returns
The one vector2i.

Definition at line 22 of file vector2i.c.

◆ vec2i_perpendicular()

vector2i vec2i_perpendicular ( const vector2i v)

Returns the perpendicular vector (90 degrees counterclockwise).

See vec2i_perpendicular_ptr instead.

Parameters
vThe input vector.
Returns
The perpendicular vector2i.

Definition at line 252 of file vector2i.c.

References vec2i_perpendicular_ptr().

◆ vec2i_perpendicular_ptr()

void vec2i_perpendicular_ptr ( vector2i * res,
const vector2i * v )

Computes the perpendicular vector to v (90 degrees counterclockwise rotation), storing the result in res.

Parameters
resPointer to result vector2i.
vPointer to vector2i.

Definition at line 175 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_perpendicular().

◆ vec2i_sign()

vector2i vec2i_sign ( const vector2i v)

Returns the sign of each component (+1, -1, or 0).

See vec2i_sign_ptr instead.

Parameters
vThe input vector.
Returns
The sign vector2i.

Definition at line 237 of file vector2i.c.

References vec2i_sign_ptr().

◆ vec2i_sign_ptr()

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, or 0).

Parameters
resPointer to result vector2i.
vPointer to vector2i.

Definition at line 162 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_sign().

◆ vec2i_splat()

vector2i vec2i_splat ( const vm_int_t s)

Returns a vector with every component set to s.

See vec2i_splat_ptr instead.

Parameters
sScalar value.
Returns
The resulting vector2i.

Definition at line 484 of file vector2i.c.

◆ vec2i_sub()

vector2i vec2i_sub ( const vector2i a,
const vector2i b )

Subtracts the second vector from the first component-wise.

See vec2i_sub_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The difference vector2i.

Definition at line 96 of file vector2i.c.

References vec2i_sub_ptr().

◆ vec2i_sub_ptr()

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.

Parameters
resPointer to result vector2i.
aPointer to first vector2i.
bPointer to second vector2i.

Definition at line 28 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_sub().

◆ vec2i_sub_scalar()

vector2i vec2i_sub_scalar ( const vector2i v,
const vm_int_t s )

Subtracts a scalar from each component.

See vec2i_sub_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector2i.

Definition at line 421 of file vector2i.c.

References vec2i_sub_scalar_ptr().

◆ vec2i_sub_scalar_ptr()

void vec2i_sub_scalar_ptr ( vector2i * res,
const vector2i * v,
const vm_int_t s )

Subtracts a scalar from each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 283 of file vector2i_ptr.c.

References vector2i::x, and vector2i::y.

Referenced by vec2i_sub_scalar().

◆ vec2i_sum()

vm_int_t vec2i_sum ( const vector2i v)

Returns the sum of all components.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 611 of file vector2i.c.

References vector2i::x, and vector2i::y.

◆ vec2i_to_vec3i()

vector3i vec2i_to_vec3i ( const vector2i v,
const vm_int_t z )

Converts a vector2i to a vector3i using z.

See vec2i_to_vec3i_ptr instead.

Parameters
vInput vector.
zZ component.
Returns
The resulting vector3i.

Definition at line 498 of file vector2i.c.

References vec2i_to_vec3i_ptr().

◆ vec2i_to_vec3i_ptr()

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

Converts a vector4i to a vector3i by dropping w.

Parameters
resOutput vector.
vInput vector.
zZ component.

Definition at line 335 of file vector2i_ptr.c.

References vector2i::x, vector3i::x, vector2i::y, vector3i::y, and vector3i::z.

Referenced by vec2i_to_vec3i().

◆ vec2i_wrap()

vector2i vec2i_wrap ( const vector2i v,
const vector2i period )

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

See vec2i_wrap_ptr instead.

Parameters
vInput vector.
periodWrap period per component.
Returns
The resulting vector2i.

Definition at line 469 of file vector2i.c.

References vec2i_wrap_ptr().

◆ vec2i_wrap_ptr()

void vec2i_wrap_ptr ( vector2i * res,
const vector2i * v,
const vector2i * period )

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

Parameters
resOutput vector.
vInput vector.
periodWrap period per component.

Definition at line 322 of file vector2i_ptr.c.

References vm_mod_floor(), vector2i::x, and vector2i::y.

Referenced by vec2i_wrap().

◆ vec2i_x_axis()

vector2i vec2i_x_axis ( const vm_int_t x)

Returns a vector2i along the x-axis (y = 0).

Parameters
xThe x component value.
Returns
The x-axis vector2i.

Definition at line 33 of file vector2i.c.

◆ vec2i_x_scale()

vector2i vec2i_x_scale ( const vm_int_t x)

Returns a vector2i representing x-axis scaling (y = 1).

Parameters
xThe x scale factor.
Returns
The x-scale vector2i.

Definition at line 55 of file vector2i.c.

◆ vec2i_y_axis()

vector2i vec2i_y_axis ( const vm_int_t y)

Returns a vector2i along the y-axis (x = 0).

Parameters
yThe y component value.
Returns
The y-axis vector2i.

Definition at line 44 of file vector2i.c.

◆ vec2i_y_scale()

vector2i vec2i_y_scale ( const vm_int_t y)

Returns a vector2i representing y-axis scaling (x = 1).

Parameters
yThe y scale factor.
Returns
The y-scale vector2i.

Definition at line 66 of file vector2i.c.

◆ vec2i_zero()

vector2i vec2i_zero ( void )

Returns a vector2i with both components set to 0.

Returns
The zero vector2i.

Definition at line 12 of file vector2i.c.

◆ vec3()

vector3 vec3 ( const vm_float_t x,
const vm_float_t y,
const vm_float_t z )

Constructs a vector3 from x, y, and z.

Parameters
xX component.
yY component.
zZ component.
Returns
The resulting vector3.

Definition at line 363 of file vecmat.c.

◆ vec3_abs()

vector3 vec3_abs ( const vector3 v)

Computes the absolute value per component of a vector3.

See vec3_abs_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The absolute vector3.

Definition at line 196 of file vector3.c.

References vec3_abs_ptr().

◆ vec3_abs_ptr()

void vec3_abs_ptr ( vector3 * res,
const vector3 * v )

Computes the absolute value per component of a vector3.

Parameters
resResult vector.
vVector.

Definition at line 100 of file vector3_ptr.c.

References VECMAT_FABS, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_abs().

◆ vec3_add()

vector3 vec3_add ( const vector3 a,
const vector3 b )

Component-wise addition of two vectors.

See vec3_add_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 102 of file vector3.c.

References vec3_add_ptr().

◆ vec3_add_assign()

void vec3_add_assign ( vector3 * dest,
const vector3 * src )

Adds src to dest in place.

Parameters
destDestination vector.
srcVector to add.

Definition at line 402 of file vecmat.c.

References vector3::x, vector3::y, and vector3::z.

◆ vec3_add_ptr()

void vec3_add_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Component-wise addition of two vectors.

Parameters
resResult vector.
aFirst vector.
bSecond vector.

Definition at line 14 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_add().

◆ vec3_add_scalar()

vector3 vec3_add_scalar ( const vector3 v,
const vm_float_t s )

Adds a scalar to each component.

See vec3_add_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector3.

Definition at line 485 of file vector3.c.

References vec3_add_scalar_ptr().

◆ vec3_add_scalar_ptr()

void vec3_add_scalar_ptr ( vector3 * res,
const vector3 * v,
const vm_float_t s )

Adds a scalar to each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 320 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_add_scalar().

◆ vec3_angle()

vm_float_t vec3_angle ( const vector3 a,
const vector3 b )

Computes the angle between two non-zero vector3 in radians.

Parameters
aFirst vector.
bSecond vector.
Returns
The angle between the directions of a and b.

Definition at line 413 of file vector3.c.

References vec3_dot(), vec3_length(), and VECMAT_ACOS.

◆ vec3_assign()

void vec3_assign ( vector3 * dest,
const vector3 * src )

Copies src into dest.

Parameters
destDestination vector.
srcSource vector.

Definition at line 374 of file vecmat.c.

References vector3::x, vector3::y, and vector3::z.

◆ vec3_assign_xyz()

void vec3_assign_xyz ( vector3 * dest,
const vm_float_t x,
const vm_float_t y,
const vm_float_t z )

Assigns x, y, and z to dest.

Parameters
destDestination vector.
xX component.
yY component.
zZ component.

Definition at line 389 of file vecmat.c.

References vector3::x, vector3::y, and vector3::z.

◆ vec3_ceil()

vector3 vec3_ceil ( const vector3 v)

Applies ceil per component to a vector3.

See vec3_ceil_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The ceiling vector.

Definition at line 304 of file vector3.c.

References vec3_ceil_ptr().

◆ vec3_ceil_ptr()

void vec3_ceil_ptr ( vector3 * res,
const vector3 * v )

Component-wise ceil of a vector.

Parameters
resResult vector.
vVector.

Definition at line 200 of file vector3_ptr.c.

References VECMAT_CEIL, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_ceil().

◆ vec3_clamp()

vector3 vec3_clamp ( const vector3 v,
const vector3 min,
const vector3 max )

Clamps a vector3 between min and max per component.

See vec3_clamp_ptr for the out-parameter version.

Parameters
vThe vector.
minMinimum bounds.
maxMaximum bounds.
Returns
The clamped vector.

Definition at line 387 of file vector3.c.

References vec3_clamp_ptr().

◆ vec3_clamp_ptr()

void vec3_clamp_ptr ( vector3 * res,
const vector3 * v,
const vector3 * min,
const vector3 * max )

Clamp vector components between min and max.

Parameters
resResult vector.
vVector.
minMinimum bounds.
maxMaximum bounds.

Definition at line 280 of file vector3_ptr.c.

References VECMAT_FMAX, VECMAT_FMIN, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_clamp().

◆ vec3_clamp_scalar()

vector3 vec3_clamp_scalar ( const vector3 v,
const vm_float_t min,
const vm_float_t max )

Clamps each component to the scalar range [min, max].

See vec3_clamp_scalar_ptr instead.

Parameters
vInput vector.
minLower bound.
maxUpper bound.
Returns
The resulting vector3.

Definition at line 518 of file vector3.c.

References vec3_clamp_scalar_ptr().

◆ vec3_clamp_scalar_ptr()

void vec3_clamp_scalar_ptr ( vector3 * res,
const vector3 * v,
const vm_float_t min,
const vm_float_t max )

Clamps each component to the scalar range [min, max].

Parameters
resOutput vector.
vInput vector.
minLower bound.
maxUpper bound.

Definition at line 349 of file vector3_ptr.c.

References VECMAT_FMAX, VECMAT_FMIN, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_clamp_scalar(), and vec3_saturate_ptr().

◆ vec3_cross()

vector3 vec3_cross ( const vector3 a,
const vector3 b )

Computes the cross-product of two vector3.

See vec3_cross_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
The cross-product (a × b).

Definition at line 212 of file vector3.c.

References vec3_cross_ptr().

Referenced by mat4_look_at_ptr(), and vec3_signed_angle().

◆ vec3_cross_ptr()

void vec3_cross_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Compute cross-product of two vectors.

Parameters
resResult vector.
aFirst vector.
bSecond vector.

Definition at line 133 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_cross(), and vec3_orthonormal_basis_ptr().

◆ vec3_distance()

vm_float_t vec3_distance ( const vector3 a,
const vector3 b )

Computes the Euclidean distance between two vector3.

Parameters
aFirst vector.
bSecond vector.
Returns
The distance between a and b.

Definition at line 401 of file vector3.c.

References vec3_length(), and vec3_sub().

◆ vec3_distance_squared()

vm_float_t vec3_distance_squared ( const vector3 a,
const vector3 b )

Returns the squared Euclidean distance between a and b.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 749 of file vector3.c.

References vector3::x, vector3::y, and vector3::z.

◆ vec3_div()

vector3 vec3_div ( const vector3 a,
const vector3 b )

Divides two vectors component-wise.

See vec3_div_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector3.

Definition at line 469 of file vector3.c.

References vec3_div_ptr().

◆ vec3_div_ptr()

void vec3_div_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Divides two vectors component-wise.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 306 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_div().

◆ vec3_div_scalar()

vector3 vec3_div_scalar ( const vector3 v,
const vm_float_t s )

Component-wise division of vector by scalar.

See vec3_div_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar (non-zero).
Returns
Result vector.

Definition at line 150 of file vector3.c.

References vec3_div_scalar_ptr().

◆ vec3_div_scalar_ptr()

void vec3_div_scalar_ptr ( vector3 * res,
const vector3 * v,
const vm_float_t s )

Component-wise division of vector by scalar.

Parameters
resResult vector.
vVector.
sScalar.

Definition at line 56 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_div_scalar().

◆ vec3_dot()

vm_float_t vec3_dot ( const vector3 a,
const vector3 b )

Computes the dot product of two vector3.

Parameters
aFirst vector.
bSecond vector.
Returns
The dot product (a.x * b.x + a.y * b.y + a.z * b.z).

Definition at line 428 of file vector3.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by mat4_look_at_ptr(), vec3_angle(), vec3_length(), vec3_length_squared(), vec3_project_ptr(), vec3_reflect_ptr(), vec3_refract_ptr(), vec3_rotate_axis_ptr(), vec3_signed_angle(), and vec3_slide_ptr().

◆ vec3_eq()

bool vec3_eq ( const vector3 a,
const vector3 b )

Returns true if two vectors are equal within VECMAT_EPSILON.

Parameters
aFirst vector.
bSecond vector.
Returns
True if a and b are approximately equal.

Definition at line 50 of file vecmat.c.

References VECMAT_EPSILON, VECMAT_FABS, vector3::x, vector3::y, and vector3::z.

◆ vec3_floor()

vector3 vec3_floor ( const vector3 v)

Applies the floor per component to a vector3.

See vec3_floor_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The floored vector.

Definition at line 289 of file vector3.c.

References vec3_floor_ptr().

◆ vec3_floor_ptr()

void vec3_floor_ptr ( vector3 * res,
const vector3 * v )

Component-wise floor of a vector.

Parameters
resResult vector.
vVector.

Definition at line 187 of file vector3_ptr.c.

References VECMAT_FLOOR, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_floor().

◆ vec3_fract()

vector3 vec3_fract ( const vector3 v)

Returns the fractional part of each component.

See vec3_fract_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector3.

Definition at line 548 of file vector3.c.

References vec3_fract_ptr().

◆ vec3_fract_ptr()

void vec3_fract_ptr ( vector3 * res,
const vector3 * v )

Returns the fractional part of each component.

Parameters
resOutput vector.
vInput vector.

Definition at line 373 of file vector3_ptr.c.

References VECMAT_FLOOR, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_fract().

◆ vec3_from()

vector3 vec3_from ( const vector3i * v)

Converts a vector3i to a vector3.

Parameters
vInput integer vector.
Returns
The resulting vector3.

Definition at line 415 of file vecmat.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3_from_vec2()

vector3 vec3_from_vec2 ( const vector2 v,
const vm_float_t z )

Builds a vector3 from a vector2 and z.

See vec3_from_vec2_ptr instead.

Parameters
vInput vector.
zZ component.
Returns
The resulting vector3.

Definition at line 642 of file vector3.c.

References vec3_from_vec2_ptr().

◆ vec3_from_vec2_ptr()

void vec3_from_vec2_ptr ( vector3 * res,
const vector2 * v,
const vm_float_t z )

Builds a higher-dimension vector from a vector2.

Parameters
resOutput vector.
vInput vector.
zZ component.

Definition at line 460 of file vector3_ptr.c.

References vector2::x, vector3::x, vector2::y, vector3::y, and vector3::z.

Referenced by vec3_from_vec2().

◆ vec3_is_normalized()

bool vec3_is_normalized ( const vector3 v)

Returns true if the vector has unit length.

Parameters
vInput vector.
Returns
True if the vector has unit length.

Definition at line 823 of file vector3.c.

References vec3_length_squared(), VECMAT_EPSILON, and VECMAT_FABS.

◆ vec3_is_zero()

bool vec3_is_zero ( const vector3 v)

Returns true if every component is zero.

Parameters
vInput vector.
Returns
True if every component is zero.

Definition at line 810 of file vector3.c.

References VECMAT_EPSILON, VECMAT_FABS, vector3::x, vector3::y, and vector3::z.

◆ vec3_length()

vm_float_t vec3_length ( const vector3 v)

Computes the length (magnitude) of a vector3.

Parameters
vThe vector.
Returns
The Euclidean length of v.

Definition at line 439 of file vector3.c.

References vec3_dot(), and VECMAT_SQRT.

Referenced by vec3_angle(), vec3_distance(), vec3_limit_length_ptr(), and vec3_normalize_ptr().

◆ vec3_length_chebyshev()

vm_float_t vec3_length_chebyshev ( const vector3 v)

Returns the Chebyshev (L-inf) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 737 of file vector3.c.

References VECMAT_FABS, VECMAT_FMAX, vector3::x, vector3::y, and vector3::z.

◆ vec3_length_manhattan()

vm_float_t vec3_length_manhattan ( const vector3 v)

Returns the Manhattan (L1) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 726 of file vector3.c.

References VECMAT_FABS, vector3::x, vector3::y, and vector3::z.

◆ vec3_length_squared()

vm_float_t vec3_length_squared ( const vector3 v)

Returns the squared Euclidean length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 715 of file vector3.c.

References vec3_dot().

Referenced by vec3_is_normalized().

◆ vec3_lerp()

vector3 vec3_lerp ( const vector3 a,
const vector3 b,
const vm_float_t t )

Linearly interpolates between two vector3.

See vec3_lerp_ptr for the out-parameter version.

Parameters
aStart vector.
bEnd vector.
tInterpolation factor [0, 1].
Returns
The interpolated vector (a * (1 - t) + b * t).

Definition at line 370 of file vector3.c.

References vec3_lerp_ptr().

◆ vec3_lerp_ptr()

void vec3_lerp_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b,
const vm_float_t t )

Linear interpolation between two vectors.

Parameters
resResult vector.
aStart vector.
bEnd vector.
tInterpolation factor.

Definition at line 265 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_lerp().

◆ vec3_limit_length()

vector3 vec3_limit_length ( const vector3 v,
const vm_float_t max_len )

Clamps the vector length to max_len.

See vec3_limit_length_ptr instead.

Parameters
vInput vector.
max_lenMaximum length.
Returns
The resulting vector3.

Definition at line 675 of file vector3.c.

References vec3_limit_length_ptr().

◆ vec3_limit_length_ptr()

void vec3_limit_length_ptr ( vector3 * res,
const vector3 * v,
const vm_float_t max_len )

Clamps the vector length to max_len.

Parameters
resOutput vector.
vInput vector.
max_lenMaximum length.

Definition at line 510 of file vector3_ptr.c.

References vec3_length(), vector3::x, vector3::y, and vector3::z.

Referenced by vec3_limit_length().

◆ vec3_max()

vector3 vec3_max ( const vector3 a,
const vector3 b )

Computes the component-wise maximum of two vector3.

See vec3_max_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component max(a, b).

Definition at line 259 of file vector3.c.

References vec3_max_ptr().

◆ vec3_max_component()

vm_float_t vec3_max_component ( const vector3 v)

Returns the largest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 788 of file vector3.c.

References VECMAT_FMAX, vector3::x, vector3::y, and vector3::z.

◆ vec3_max_ptr()

void vec3_max_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Component-wise maximum of two vectors.

Parameters
resResult vector.
aFirst vector.
bSecond vector.

Definition at line 161 of file vector3_ptr.c.

References VECMAT_FMAX, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_max().

◆ vec3_min()

vector3 vec3_min ( const vector3 a,
const vector3 b )

Computes the component-wise minimum of two vector3.

See vec3_min_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component min(a, b).

Definition at line 243 of file vector3.c.

References vec3_min_ptr().

◆ vec3_min_component()

vm_float_t vec3_min_component ( const vector3 v)

Returns the smallest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 777 of file vector3.c.

References VECMAT_FMIN, vector3::x, vector3::y, and vector3::z.

◆ vec3_min_ptr()

void vec3_min_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Component-wise minimum of two vectors.

Parameters
resResult vector.
aFirst vector.
bSecond vector.

Definition at line 147 of file vector3_ptr.c.

References VECMAT_FMIN, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_min().

◆ vec3_move_toward()

vector3 vec3_move_toward ( const vector3 current,
const vector3 target,
const vm_float_t max_delta )

Moves current toward target by at most max_delta.

See vec3_move_toward_ptr instead.

Parameters
currentCurrent position.
targetTarget position.
max_deltaMaximum distance to move.
Returns
The resulting vector3.

Definition at line 659 of file vector3.c.

References vec3_move_toward_ptr().

◆ vec3_move_toward_ptr()

void vec3_move_toward_ptr ( vector3 * res,
const vector3 * current,
const vector3 * target,
const vm_float_t max_delta )

Moves current toward target by at most max_delta.

Parameters
resOutput vector.
currentCurrent position.
targetTarget position.
max_deltaMaximum distance to move.

Definition at line 487 of file vector3_ptr.c.

References VECMAT_SQRT, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_move_toward().

◆ vec3_mul()

vector3 vec3_mul ( const vector3 a,
const vector3 b )

Component-wise multiplication of two vectors.

See vec3_mul_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 166 of file vector3.c.

References vec3_mul_ptr().

◆ vec3_mul_ptr()

void vec3_mul_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Component-wise multiplication of two vectors.

Parameters
resResult vector.
aFirst vector.
bSecond vector.

Definition at line 74 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_mul().

◆ vec3_mul_scalar()

vector3 vec3_mul_scalar ( const vector3 v,
const vm_float_t s )

Component-wise multiplication of vector by scalar.

See vec3_mul_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar.
Returns
Result vector.

Definition at line 134 of file vector3.c.

References vec3_mul_scalar_ptr().

◆ vec3_mul_scalar_ptr()

void vec3_mul_scalar_ptr ( vector3 * res,
const vector3 * v,
const vm_float_t s )

Component-wise multiplication of vector by scalar.

Parameters
resResult vector.
vVector.
sScalar.

Definition at line 42 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_mul_scalar(), and vec3_scale_ptr().

◆ vec3_near()

bool vec3_near ( const vector3 a,
const vector3 b,
const vm_float_t eps )

Returns true if a and b are within eps of each other.

Parameters
aFirst input vector.
bSecond input vector.
epsDistance tolerance.
Returns
True if a and b are within eps.

Definition at line 836 of file vector3.c.

References VECMAT_FABS, vector3::x, vector3::y, and vector3::z.

◆ vec3_neg()

vector3 vec3_neg ( const vector3 v)

Negation of a vector.

See vec3_neg_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The negated vector.

Definition at line 181 of file vector3.c.

References vec3_neg_ptr().

◆ vec3_neg_ptr()

void vec3_neg_ptr ( vector3 * res,
const vector3 * v )

Negation of a vector.

Parameters
resResult vector.
vVector.

Definition at line 87 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_neg().

◆ vec3_normalize()

vector3 vec3_normalize ( const vector3 v)

Normalizes a vector3 to unit length.

See vec3_normalize_ptr for the out-parameter version.

Parameters
vThe vector (non-zero).
Returns
The normalized vector.

Definition at line 227 of file vector3.c.

References vec3_normalize_ptr().

Referenced by mat4_look_at_ptr(), mat4_rotation_ptr(), and quat_from_axis_angle_ptr().

◆ vec3_normalize_ptr()

void vec3_normalize_ptr ( vector3 * res,
const vector3 * v )

Normalize a vector to unit length.

Parameters
resResult vector.
vVector.

Definition at line 113 of file vector3_ptr.c.

References vec3_length(), vector3::x, vector3::y, and vector3::z.

Referenced by vec3_normalize(), vec3_orthonormal_basis_ptr(), vec3_rotate_axis_ptr(), and vec3i_normalize_to_vec3_ptr().

◆ vec3_one()

vector3 vec3_one ( void )

Returns a vector3 with all components set to 1.0f.

Returns
A vector3 with all components set to 1.0f.

Definition at line 22 of file vector3.c.

◆ vec3_orthonormal_basis()

void vec3_orthonormal_basis ( const vector3 n,
vector3 * t,
vector3 * b )

Builds a tangent and bitangent orthonormal to n.

Parameters
nUnit normal.
tOutput tangent.
bOutput bitangent.

Definition at line 704 of file vector3.c.

References vec3_orthonormal_basis_ptr().

◆ vec3_orthonormal_basis_ptr()

void vec3_orthonormal_basis_ptr ( const vector3 * n,
vector3 * t,
vector3 * b )

Builds a tangent and bitangent orthonormal to n.

Parameters
nUnit normal.
tOutput tangent.
bOutput bitangent.

Definition at line 530 of file vector3_ptr.c.

References vec3_cross_ptr(), vec3_normalize_ptr(), VECMAT_FABS, and vector3::x.

Referenced by vec3_orthonormal_basis().

◆ vec3_project()

vector3 vec3_project ( const vector3 a,
const vector3 b )

Projects a onto b.

See vec3_project_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector3.

Definition at line 564 of file vector3.c.

References vec3_project_ptr().

◆ vec3_project_ptr()

void vec3_project_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Projects a onto b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 387 of file vector3_ptr.c.

References vec3_dot(), vector3::x, vector3::y, and vector3::z.

Referenced by vec3_project(), and vec3_reject_ptr().

◆ vec3_reflect()

vector3 vec3_reflect ( const vector3 incident,
const vector3 normal )

Reflects an incident vector over normal.

See vec3_reflect_ptr for the out-parameter version.

Parameters
incidentThe incident vector.
normalThe surface normal.
Returns
The reflected vector.

Definition at line 335 of file vector3.c.

References vec3_reflect_ptr().

◆ vec3_reflect_ptr()

void vec3_reflect_ptr ( vector3 * res,
const vector3 * incident,
const vector3 * normal )

Compute reflection of the incident vector over normal.

Parameters
resResult vector.
incidentIncident vector.
normalNormal vector.

Definition at line 227 of file vector3_ptr.c.

References vec3_dot(), vector3::x, vector3::y, and vector3::z.

Referenced by vec3_reflect().

◆ vec3_refract()

vector3 vec3_refract ( const vector3 incident,
const vector3 normal,
const vm_float_t eta )

Refracts an incident vector across an interface with a given normal and ratio of refraction eta.

See vec3_refract_ptr for the out-parameter version.

Parameters
incidentThe incident vector.
normalThe surface normal.
etaThe ratio of refraction (eta = n1 / n2).
Returns
The refracted vector, or incident if total internal reflection.

Definition at line 353 of file vector3.c.

References vec3_refract_ptr().

◆ vec3_refract_ptr()

void vec3_refract_ptr ( vector3 * res,
const vector3 * incident,
const vector3 * normal,
const vm_float_t eta )

Compute refraction of the incident vector through normal with eta.

Parameters
resResult vector.
incidentIncident vector.
normalNormal vector.
etaRefraction index ratio.

Definition at line 243 of file vector3_ptr.c.

References vec3_dot(), VECMAT_SQRT, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_refract().

◆ vec3_reject()

vector3 vec3_reject ( const vector3 a,
const vector3 b )

Returns the component of a orthogonal to b.

See vec3_reject_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector3.

Definition at line 596 of file vector3.c.

References vec3_reject_ptr().

◆ vec3_reject_ptr()

void vec3_reject_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Returns the component of a orthogonal to b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 424 of file vector3_ptr.c.

References vec3_project_ptr(), vector3::x, vector3::y, and vector3::z.

Referenced by vec3_reject().

◆ vec3_rotate_axis()

vector3 vec3_rotate_axis ( const vector3 v,
const vector3 axis,
const vm_float_t angle )

Rotates v around axis by angle radians.

See vec3_rotate_axis_ptr instead.

Parameters
vInput vector.
axisRotation axis.
angleAngle in radians.
Returns
The resulting vector3.

Definition at line 613 of file vector3.c.

References vec3_rotate_axis_ptr().

◆ vec3_rotate_axis_ptr()

void vec3_rotate_axis_ptr ( vector3 * res,
const vector3 * v,
const vector3 * axis,
const vm_float_t angle )

Rotates v around axis by angle radians.

Parameters
resOutput vector.
vInput vector.
axisRotation axis.
angleAngle in radians.

Definition at line 441 of file vector3_ptr.c.

References vec3_dot(), vec3_normalize_ptr(), VECMAT_COS, VECMAT_SIN, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_rotate_axis().

◆ vec3_round()

vector3 vec3_round ( const vector3 v)

Applies round per component to a vector3.

See vec3_round_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The rounded vector.

Definition at line 319 of file vector3.c.

References vec3_round_ptr().

◆ vec3_round_ptr()

void vec3_round_ptr ( vector3 * res,
const vector3 * v )

Component-wise round of a vector.

Parameters
resResult vector.
vVector.

Definition at line 213 of file vector3_ptr.c.

References VECMAT_ROUND, vector3::x, vector3::y, and vector3::z.

Referenced by vec3_round().

◆ vec3_saturate()

vector3 vec3_saturate ( const vector3 v)

Clamps each component to the range [0, 1].

See vec3_saturate_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector3.

Definition at line 533 of file vector3.c.

References vec3_saturate_ptr().

◆ vec3_saturate_ptr()

void vec3_saturate_ptr ( vector3 * res,
const vector3 * v )

Clamps each component to the range [0, 1].

Parameters
resOutput vector.
vInput vector.

Definition at line 362 of file vector3_ptr.c.

References vec3_clamp_scalar_ptr().

Referenced by vec3_saturate().

◆ vec3_scale()

vector3 vec3_scale ( const vector3 v,
const vm_float_t s )

Scales the vector by a scalar.

See vec3_scale_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector3.

Definition at line 453 of file vector3.c.

References vec3_scale_ptr().

◆ vec3_scale_ptr()

void vec3_scale_ptr ( vector3 * res,
const vector3 * v,
const vm_float_t s )

Scales the vector by a scalar.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 294 of file vector3_ptr.c.

References vec3_mul_scalar_ptr().

Referenced by vec3_scale().

◆ vec3_sign()

vector3 vec3_sign ( const vector3 v)

Computes the sign per component of a vector3 (-1, 0, or 1).

See vec3_sign_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The sign vector.

Definition at line 274 of file vector3.c.

References vec3_sign_ptr().

◆ vec3_sign_ptr()

void vec3_sign_ptr ( vector3 * res,
const vector3 * v )

Component-wise sign of a vector.

Parameters
resResult vector.
vVector.

Definition at line 174 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_sign().

◆ vec3_signed_angle()

vm_float_t vec3_signed_angle ( const vector3 a,
const vector3 b,
const vector3 axis )

Returns the signed angle from a to b around axis.

Parameters
aFirst input vector.
bSecond input vector.
axisRotation axis.
Returns
The resulting scalar.

Definition at line 765 of file vector3.c.

References vec3_cross(), vec3_dot(), and VECMAT_ATAN2.

◆ vec3_slide()

vector3 vec3_slide ( const vector3 v,
const vector3 normal )

Removes the component of v along normal.

See vec3_slide_ptr instead.

Parameters
vInput vector.
normalSurface normal.
Returns
The resulting vector3.

Definition at line 580 of file vector3.c.

References vec3_slide_ptr().

◆ vec3_slide_ptr()

void vec3_slide_ptr ( vector3 * res,
const vector3 * v,
const vector3 * normal )

Removes the component of v along normal.

Parameters
resOutput vector.
vInput vector.
normalSurface normal.

Definition at line 409 of file vector3_ptr.c.

References vec3_dot(), vector3::x, vector3::y, and vector3::z.

Referenced by vec3_slide().

◆ vec3_splat()

vector3 vec3_splat ( const vm_float_t s)

Returns a vector with every component set to s.

See vec3_splat_ptr instead.

Parameters
sScalar value.
Returns
The resulting vector3.

Definition at line 628 of file vector3.c.

◆ vec3_sub()

vector3 vec3_sub ( const vector3 a,
const vector3 b )

Component-wise subtraction of two vectors.

See vec3_sub_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 118 of file vector3.c.

References vec3_sub_ptr().

Referenced by mat4_look_at_ptr(), and vec3_distance().

◆ vec3_sub_ptr()

void vec3_sub_ptr ( vector3 * res,
const vector3 * a,
const vector3 * b )

Component-wise subtraction of two vectors.

Parameters
resResult vector.
aFirst vector.
bSecond vector.

Definition at line 28 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_sub().

◆ vec3_sub_scalar()

vector3 vec3_sub_scalar ( const vector3 v,
const vm_float_t s )

Subtracts a scalar from each component.

See vec3_sub_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector3.

Definition at line 501 of file vector3.c.

References vec3_sub_scalar_ptr().

◆ vec3_sub_scalar_ptr()

void vec3_sub_scalar_ptr ( vector3 * res,
const vector3 * v,
const vm_float_t s )

Subtracts a scalar from each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 334 of file vector3_ptr.c.

References vector3::x, vector3::y, and vector3::z.

Referenced by vec3_sub_scalar().

◆ vec3_sum()

vm_float_t vec3_sum ( const vector3 v)

Returns the sum of all components.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 799 of file vector3.c.

References vector3::x, vector3::y, and vector3::z.

◆ vec3_x_axis()

vector3 vec3_x_axis ( const vm_float_t x)

Returns a vector3 along the x-axis.

Parameters
xThe x component value.
Returns
A vector3 with (x, 0.0f, 0.0f).

Definition at line 33 of file vector3.c.

◆ vec3_x_scale()

vector3 vec3_x_scale ( const vm_float_t x)

Returns a vector3 for scaling along the x-axis.

Parameters
xThe x scale factor.
Returns
A vector3 with (x, 1.0f, 1.0f).

Definition at line 66 of file vector3.c.

◆ vec3_xy()

vector2 vec3_xy ( const vector3 v)

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

See vec3_xy_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector2.

Definition at line 690 of file vector3.c.

References vec3_xy_ptr().

◆ vec3_xy_ptr()

void vec3_xy_ptr ( vector2 * res,
const vector3 * v )

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

Parameters
resOutput vector.
vInput vector.

Definition at line 473 of file vector3_ptr.c.

References vector2::x, vector3::x, vector2::y, and vector3::y.

Referenced by vec3_xy().

◆ vec3_y_axis()

vector3 vec3_y_axis ( const vm_float_t y)

Returns a vector3 along the y-axis.

Parameters
yThe y component value.
Returns
A vector3 with (0.0f, y, 0.0f).

Definition at line 44 of file vector3.c.

◆ vec3_y_scale()

vector3 vec3_y_scale ( const vm_float_t y)

Returns a vector3 for scaling along the y-axis.

Parameters
yThe y scale factor.
Returns
A vector3 with (1.0f, y, 1.0f).

Definition at line 77 of file vector3.c.

◆ vec3_z_axis()

vector3 vec3_z_axis ( const vm_float_t z)

Returns a vector3 along the z-axis.

Parameters
zThe z component value.
Returns
A vector3 with (0.0f, 0.0f, z).

Definition at line 55 of file vector3.c.

◆ vec3_z_scale()

vector3 vec3_z_scale ( const vm_float_t z)

Returns a vector3 for scaling along the z-axis.

Parameters
zThe z scale factor.
Returns
A vector3 with (1.0f, 1.0f, z).

Definition at line 88 of file vector3.c.

◆ vec3_zero()

vector3 vec3_zero ( void )

Returns a zero-initialized vector3.

Returns
A vector3 with all components set to 0.0f.

Definition at line 12 of file vector3.c.

◆ vec3i()

vector3i vec3i ( const vm_int_t x,
const vm_int_t y,
const vm_int_t z )

Constructs a vector3i from x, y, and z.

Parameters
xX component.
yY component.
zZ component.
Returns
The resulting vector3i.

Definition at line 432 of file vecmat.c.

◆ vec3i_abs()

vector3i vec3i_abs ( const vector3i v)

Computes the absolute value per component of a vector3i.

See vec3i_abs_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The absolute vector3i.

Definition at line 196 of file vector3i.c.

References vec3i_abs_ptr().

◆ vec3i_abs_ptr()

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

Computes the absolute value of each component of a vector3i.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 105 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_abs().

◆ vec3i_add()

vector3i vec3i_add ( const vector3i a,
const vector3i b )

Component-wise addition of two vectors.

See vec3i_add_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 102 of file vector3i.c.

References vec3i_add_ptr().

◆ vec3i_add_assign()

void vec3i_add_assign ( vector3i * dest,
const vector3i * src )

Adds src to dest in place.

Parameters
destDestination vector.
srcVector to add.

Definition at line 471 of file vecmat.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_add_ptr()

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

Computes the component-wise sum of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 15 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_add().

◆ vec3i_add_scalar()

vector3i vec3i_add_scalar ( const vector3i v,
const vm_int_t s )

Adds a scalar to each component.

See vec3i_add_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector3i.

Definition at line 390 of file vector3i.c.

References vec3i_add_scalar_ptr().

◆ vec3i_add_scalar_ptr()

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

Adds a scalar to each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 267 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_add_scalar().

◆ vec3i_angle()

vm_float_t vec3i_angle ( const vector3i a,
const vector3i b )

Computes the angle between two non-zero vector3i in radians.

Parameters
aFirst vector.
bSecond vector.
Returns
The angle between the directions of a and b.

Definition at line 356 of file vector3i.c.

References vec3i_dot(), vec3i_length(), and VECMAT_ACOS.

◆ vec3i_assign()

void vec3i_assign ( vector3i * dest,
const vector3i * src )

Copies src into dest.

Parameters
destDestination vector.
srcSource vector.

Definition at line 443 of file vecmat.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_assign_xyz()

void vec3i_assign_xyz ( vector3i * dest,
const vm_int_t x,
const vm_int_t y,
const vm_int_t z )

Assigns x, y, and z to dest.

Parameters
destDestination vector.
xX component.
yY component.
zZ component.

Definition at line 458 of file vecmat.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_clamp()

vector3i vec3i_clamp ( const vector3i v,
const vector3i min,
const vector3i max )

Clamps a vector3i between min and max per component.

See vec3i_clamp_ptr for the out-parameter version.

Parameters
vThe vector.
minMinimum bounds.
maxMaximum bounds.
Returns
The clamped vector.

Definition at line 308 of file vector3i.c.

References vec3i_clamp_ptr().

◆ vec3i_clamp_ptr()

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
resPointer to the vector that will store the result.
vPointer to the input vector.
minPointer to the minimum bounds vector.
maxPointer to the maximum bounds vector.

Definition at line 212 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_clamp().

◆ vec3i_cross()

vector3i vec3i_cross ( const vector3i a,
const vector3i b )

Computes the cross-product of two vector3i.

See vec3i_cross_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
The cross-product (a × b).

Definition at line 212 of file vector3i.c.

References vec3i_cross_ptr().

◆ vec3i_cross_ptr()

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

Computes the cross-product of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 140 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_cross().

◆ vec3i_distance()

vm_float_t vec3i_distance ( const vector3i a,
const vector3i b )

Computes the Euclidean distance between two vector3i.

Parameters
aFirst vector.
bSecond vector.
Returns
The distance between a and b.

Definition at line 344 of file vector3i.c.

References vec3i_length(), and vec3i_sub().

◆ vec3i_distance_squared()

vm_int_t vec3i_distance_squared ( const vector3i a,
const vector3i b )

Returns the squared Euclidean distance between a and b.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 538 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_div()

vector3i vec3i_div ( const vector3i a,
const vector3i b )

Divides two vectors component-wise.

See vec3i_div_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector3i.

Definition at line 374 of file vector3i.c.

References vec3i_div_ptr().

◆ vec3i_div_floor()

vector3i vec3i_div_floor ( const vector3i a,
const vector3i b )

Component-wise floored division of a by b.

See vec3i_div_floor_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector3i.

Definition at line 438 of file vector3i.c.

References vec3i_div_floor_ptr().

◆ vec3i_div_floor_ptr()

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

Component-wise floored division of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 309 of file vector3i_ptr.c.

References vm_div_floor3(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_div_floor().

◆ vec3i_div_ptr()

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

Divides two vectors component-wise.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 253 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_div().

◆ vec3i_div_scalar()

vector3i vec3i_div_scalar ( const vector3i v,
const vm_int_t s )

Component-wise division of vector by scalar.

See vec3i_div_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar (non-zero).
Returns
Result vector.

Definition at line 150 of file vector3i.c.

References vec3i_div_scalar_ptr().

◆ vec3i_div_scalar_ptr()

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.

If the scalar is zero, stores the zero vector.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.
sThe scalar divisor.

Definition at line 59 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_div_scalar().

◆ vec3i_dot()

vm_int_t vec3i_dot ( const vector3i a,
const vector3i b )

Computes the dot product of two vector3i.

Parameters
aFirst vector.
bSecond vector.
Returns
The dot product (a.x * b.x + a.y * b.y + a.z * b.z).

Definition at line 322 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_angle(), vec3i_length(), and vec3i_length_squared().

◆ vec3i_eq()

bool vec3i_eq ( const vector3i a,
const vector3i b )

Returns true if two vectors are exactly equal.

Parameters
aFirst vector.
bSecond vector.
Returns
True if a and b are equal.

Definition at line 91 of file vecmat.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_from()

vector3i vec3i_from ( const vector3 * v)

Converts a vector3 to a vector3i by truncation.

Parameters
vInput vector.
Returns
The resulting vector3i.

Definition at line 484 of file vecmat.c.

References vector3::x, vector3::y, and vector3::z.

◆ vec3i_from_floored()

vector3i vec3i_from_floored ( const vector3 * v)

Converts a vector3 to a vector3i by flooring each component.

Parameters
vInput vector.
Returns
The resulting vector3i.

Definition at line 499 of file vecmat.c.

References VECMAT_FLOOR, vector3::x, vector3::y, and vector3::z.

◆ vec3i_from_rounded()

vector3i vec3i_from_rounded ( const vector3 * v)

Converts a vector3 to a vector3i by rounding each component.

Parameters
vInput vector.
Returns
The resulting vector3i.

Definition at line 514 of file vecmat.c.

References VECMAT_ROUND, vector3::x, vector3::y, and vector3::z.

◆ vec3i_from_vec2i()

vector3i vec3i_from_vec2i ( const vector2i v,
const vm_int_t z )

Builds a vector3i from a vector2i and z.

See vec3i_from_vec2i_ptr instead.

Parameters
vInput vector.
zZ component.
Returns
The resulting vector3i.

Definition at line 483 of file vector3i.c.

References vec3i_from_vec2i_ptr().

◆ vec3i_from_vec2i_ptr()

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

Builds a vector3i from a vector2i and z.

Parameters
resOutput vector.
vInput vector.
zZ component.

Definition at line 337 of file vector3i_ptr.c.

References vector2i::x, vector3i::x, vector2i::y, vector3i::y, and vector3i::z.

Referenced by vec3i_from_vec2i().

◆ vec3i_is_zero()

bool vec3i_is_zero ( const vector3i v)

Returns true if every component is zero.

Parameters
vInput vector.
Returns
True if every component is zero.

Definition at line 616 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_length()

vm_float_t vec3i_length ( const vector3i v)

Computes the length (magnitude) of a vector3i.

Parameters
vThe vector.
Returns
The Euclidean length of v.

Definition at line 333 of file vector3i.c.

References vec3i_dot(), and VECMAT_SQRT.

Referenced by vec3i_angle(), vec3i_distance(), and vec3i_normalize_ptr().

◆ vec3i_length_chebyshev()

vm_int_t vec3i_length_chebyshev ( const vector3i v)

Returns the Chebyshev (L-inf) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 566 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_length_manhattan()

vm_int_t vec3i_length_manhattan ( const vector3i v)

Returns the Manhattan (L1) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 552 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_length_squared()

vm_int_t vec3i_length_squared ( const vector3i v)

Returns the squared Euclidean length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 526 of file vector3i.c.

References vec3i_dot().

◆ vec3i_lerp()

vector3i vec3i_lerp ( const vector3i a,
const vector3i b,
const vm_float_t t )

Linearly interpolates between two vector3i.

See vec3i_lerp_ptr for the out-parameter version.

Parameters
aStart vector.
bEnd vector.
tInterpolation factor [0, 1].
Returns
The interpolated vector (a * (1 - t) + b * t).

Definition at line 291 of file vector3i.c.

References vec3i_lerp_ptr().

◆ vec3i_lerp_ptr()

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

Performs linear interpolation between two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the start vector.
bPointer to the end vector.
tInterpolation factor (typically between 0.0 and 1.0).

Definition at line 196 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_lerp().

◆ vec3i_max()

vector3i vec3i_max ( const vector3i a,
const vector3i b )

Computes the component-wise maximum of two vector3i.

See vec3i_max_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component max(a, b).

Definition at line 259 of file vector3i.c.

References vec3i_max_ptr().

◆ vec3i_max_component()

vm_int_t vec3i_max_component ( const vector3i v)

Returns the largest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 593 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_max_ptr()

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

Computes the component-wise maximum of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 168 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_max().

◆ vec3i_min()

vector3i vec3i_min ( const vector3i a,
const vector3i b )

Computes the component-wise minimum of two vector3i.

See vec3i_min_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component min(a, b).

Definition at line 243 of file vector3i.c.

References vec3i_min_ptr().

◆ vec3i_min_component()

vm_int_t vec3i_min_component ( const vector3i v)

Returns the smallest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 581 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_min_ptr()

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

Computes the component-wise minimum of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 154 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_min().

◆ vec3i_mod()

vector3i vec3i_mod ( const vector3i a,
const vector3i b )

Component-wise floor modulo of a by b.

See vec3i_mod_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector3i.

Definition at line 422 of file vector3i.c.

References vec3i_mod_ptr().

◆ vec3i_mod_ptr()

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

Component-wise floor modulo of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 295 of file vector3i_ptr.c.

References vm_mod_floor3(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_mod().

◆ vec3i_mul()

vector3i vec3i_mul ( const vector3i a,
const vector3i b )

Component-wise multiplication of two vectors.

See vec3i_mul_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 166 of file vector3i.c.

References vec3i_mul_ptr().

◆ vec3i_mul_ptr()

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

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

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 79 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_mul().

◆ vec3i_mul_scalar()

vector3i vec3i_mul_scalar ( const vector3i v,
const vm_int_t s )

Component-wise multiplication of vector by scalar.

See vec3i_mul_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar.
Returns
Result vector.

Definition at line 134 of file vector3i.c.

References vec3i_mul_scalar_ptr().

◆ vec3i_mul_scalar_ptr()

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

Scales a vector3i by an integer scalar.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.
sThe scalar multiplier.

Definition at line 43 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_mul_scalar().

◆ vec3i_neg()

vector3i vec3i_neg ( const vector3i v)

Negation of a vector.

See vec3i_neg_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The negated vector.

Definition at line 181 of file vector3i.c.

References vec3i_neg_ptr().

◆ vec3i_neg_ptr()

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

Negates a vector3i (multiplies by -1).

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 92 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_neg().

◆ vec3i_normalize()

vector3i vec3i_normalize ( const vector3i v)

Normalizes a vector3i to unit length.

See vec3i_normalize_ptr for the out-parameter version.

Parameters
vThe vector (non-zero).
Returns
The normalized vector.

Definition at line 227 of file vector3i.c.

References vec3i_normalize_ptr().

◆ vec3i_normalize_ptr()

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

Normalizes a vector3i to approximate unit length.

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

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 120 of file vector3i_ptr.c.

References vec3i_length(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_normalize().

◆ vec3i_normalize_to_vec3()

vector3 vec3i_normalize_to_vec3 ( const vector3i v)

Converts to a unit-length vector3.

See vec3i_normalize_to_vec3_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector3.

Definition at line 513 of file vector3i.c.

References vec3i_normalize_to_vec3_ptr().

◆ vec3i_normalize_to_vec3_ptr()

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

Converts to a unit-length vector3.

Parameters
resOutput vector.
vInput vector.

Definition at line 362 of file vector3i_ptr.c.

References vec3_normalize_ptr(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_normalize_to_vec3().

◆ vec3i_one()

vector3i vec3i_one ( void )

Returns a vector3i with all components set to 1.

Returns
A vector3i with all components set to 1.

Definition at line 22 of file vector3i.c.

◆ vec3i_sign()

vector3i vec3i_sign ( const vector3i v)

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

See vec3i_sign_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The sign vector.

Definition at line 274 of file vector3i.c.

References vec3i_sign_ptr().

◆ vec3i_sign_ptr()

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

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

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 181 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_sign().

◆ vec3i_splat()

vector3i vec3i_splat ( const vm_int_t s)

Returns a vector with every component set to s.

See vec3i_splat_ptr instead.

Parameters
sScalar value.
Returns
The resulting vector3i.

Definition at line 469 of file vector3i.c.

◆ vec3i_sub()

vector3i vec3i_sub ( const vector3i a,
const vector3i b )

Component-wise subtraction of two vectors.

See vec3i_sub_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 118 of file vector3i.c.

References vec3i_sub_ptr().

Referenced by vec3i_distance().

◆ vec3i_sub_ptr()

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

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

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 29 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_sub().

◆ vec3i_sub_scalar()

vector3i vec3i_sub_scalar ( const vector3i v,
const vm_int_t s )

Subtracts a scalar from each component.

See vec3i_sub_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector3i.

Definition at line 406 of file vector3i.c.

References vec3i_sub_scalar_ptr().

◆ vec3i_sub_scalar_ptr()

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

Subtracts a scalar from each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 281 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_sub_scalar().

◆ vec3i_sum()

vm_int_t vec3i_sum ( const vector3i v)

Returns the sum of all components.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 605 of file vector3i.c.

References vector3i::x, vector3i::y, and vector3i::z.

◆ vec3i_wrap()

vector3i vec3i_wrap ( const vector3i v,
const vector3i period )

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

See vec3i_wrap_ptr instead.

Parameters
vInput vector.
periodWrap period per component.
Returns
The resulting vector3i.

Definition at line 454 of file vector3i.c.

References vec3i_wrap_ptr().

◆ vec3i_wrap_ptr()

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

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

Parameters
resOutput vector.
vInput vector.
periodWrap period per component.

Definition at line 323 of file vector3i_ptr.c.

References vm_mod_floor3(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_wrap().

◆ vec3i_x_axis()

vector3i vec3i_x_axis ( const vm_int_t x)

Returns a vector3i along the x-axis.

Parameters
xThe x component value.
Returns
A vector3i with (x, 0, 0).

Definition at line 33 of file vector3i.c.

◆ vec3i_x_scale()

vector3i vec3i_x_scale ( const vm_int_t x)

Returns a vector3i for scaling along the x-axis.

Parameters
xThe x scale factor.
Returns
A vector3i with (x, 1, 1).

Definition at line 66 of file vector3i.c.

◆ vec3i_xy()

vector2i vec3i_xy ( const vector3i v)

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

See vec3i_xy_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector2i.

Definition at line 498 of file vector3i.c.

References vec3i_xy_ptr().

◆ vec3i_xy_ptr()

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

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

Parameters
resOutput vector.
vInput vector.

Definition at line 350 of file vector3i_ptr.c.

References vector2i::x, vector3i::x, vector2i::y, and vector3i::y.

Referenced by vec3i_xy().

◆ vec3i_y_axis()

vector3i vec3i_y_axis ( const vm_int_t y)

Returns a vector3i along the y-axis.

Parameters
yThe y component value.
Returns
A vector3i with (0, y, 0).

Definition at line 44 of file vector3i.c.

◆ vec3i_y_scale()

vector3i vec3i_y_scale ( const vm_int_t y)

Returns a vector3i for scaling along the y-axis.

Parameters
yThe y scale factor.
Returns
A vector3i with (1, y, 1).

Definition at line 77 of file vector3i.c.

◆ vec3i_z_axis()

vector3i vec3i_z_axis ( const vm_int_t z)

Returns a vector3i along the z-axis.

Parameters
zThe z component value.
Returns
A vector3i with (0, 0, z).

Definition at line 55 of file vector3i.c.

◆ vec3i_z_scale()

vector3i vec3i_z_scale ( const vm_int_t z)

Returns a vector3i for scaling along the z-axis.

Parameters
zThe z scale factor.
Returns
A vector3i with (1, 1, z).

Definition at line 88 of file vector3i.c.

◆ vec3i_zero()

vector3i vec3i_zero ( void )

Returns a zero-initialized vector3i.

Returns
A vector3i with all components set to 0.

Definition at line 12 of file vector3i.c.

◆ vec4_abs()

vector4 vec4_abs ( const vector4 v)

Computes the absolute value per component of a vector4.

See vec4_abs_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The absolute vector4.

Definition at line 218 of file vector4.c.

References vec4_abs_ptr().

◆ vec4_abs_ptr()

void vec4_abs_ptr ( vector4 * res,
const vector4 * v )

Definition at line 492 of file vector4_ptr.c.

References vec4_abs_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_abs().

◆ vec4_add()

vector4 vec4_add ( const vector4 a,
const vector4 b )

Component-wise addition of two vectors.

See vec4_add_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 124 of file vector4.c.

References vec4_add_ptr().

◆ vec4_add_ptr()

void vec4_add_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Definition at line 432 of file vector4_ptr.c.

References vec4_add_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_add().

◆ vec4_add_scalar()

vector4 vec4_add_scalar ( const vector4 v,
const vm_float_t s )

Adds a scalar to each component.

See vec4_add_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector4.

Definition at line 455 of file vector4.c.

References vec4_add_scalar_ptr().

◆ vec4_add_scalar_ptr()

void vec4_add_scalar_ptr ( vector4 * res,
const vector4 * v,
vm_float_t s )

Definition at line 562 of file vector4_ptr.c.

References vec4_add_scalar_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_add_scalar().

◆ vec4_ceil()

vector4 vec4_ceil ( const vector4 v)

Applies ceil per component to a vector4.

See vec4_ceil_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The ceiling vector.

Definition at line 310 of file vector4.c.

References vec4_ceil_ptr().

◆ vec4_ceil_ptr()

void vec4_ceil_ptr ( vector4 * res,
const vector4 * v )

Definition at line 622 of file vector4_ptr.c.

References vec4_ceil_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_ceil().

◆ vec4_clamp()

vector4 vec4_clamp ( const vector4 v,
const vector4 min,
const vector4 max )

Clamps a vector4 between min and max per component.

See vec4_clamp_ptr for the out-parameter version.

Parameters
vThe vector.
minMinimum bounds.
maxMaximum bounds.
Returns
The clamped vector.

Definition at line 359 of file vector4.c.

References vec4_clamp_ptr().

◆ vec4_clamp_ptr()

void vec4_clamp_ptr ( vector4 * res,
const vector4 * v,
const vector4 * min,
const vector4 * max )

Definition at line 542 of file vector4_ptr.c.

References vec4_clamp_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_clamp().

◆ vec4_clamp_scalar()

vector4 vec4_clamp_scalar ( const vector4 v,
const vm_float_t min,
const vm_float_t max )

Clamps each component to the scalar range [min, max].

See vec4_clamp_scalar_ptr instead.

Parameters
vInput vector.
minLower bound.
maxUpper bound.
Returns
The resulting vector4.

Definition at line 488 of file vector4.c.

References vec4_clamp_scalar_ptr().

◆ vec4_clamp_scalar_ptr()

void vec4_clamp_scalar_ptr ( vector4 * res,
const vector4 * v,
vm_float_t min,
vm_float_t max )

Definition at line 582 of file vector4_ptr.c.

References vec4_clamp_scalar_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_clamp_scalar().

◆ vec4_distance()

vm_float_t vec4_distance ( const vector4 a,
const vector4 b )

Computes the Euclidean distance between two vector4.

Parameters
aFirst vector.
bSecond vector.
Returns
The distance between a and b.

Definition at line 411 of file vector4.c.

References vec4_length(), and vec4_sub().

◆ vec4_distance_squared()

vm_float_t vec4_distance_squared ( const vector4 a,
const vector4 b )

Returns the squared Euclidean distance between a and b.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 604 of file vector4.c.

References vec4_length_squared(), and vec4_sub().

◆ vec4_div()

vector4 vec4_div ( const vector4 a,
const vector4 b )

Divides two vectors component-wise.

See vec4_div_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector4.

Definition at line 439 of file vector4.c.

References vec4_div_ptr().

◆ vec4_div_ptr()

void vec4_div_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Definition at line 552 of file vector4_ptr.c.

References vec4_div_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_div().

◆ vec4_div_scalar()

vector4 vec4_div_scalar ( const vector4 v,
const vm_float_t s )

Component-wise division of vector by scalar.

See vec4_div_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar (non-zero).
Returns
Result vector.

Definition at line 172 of file vector4.c.

References vec4_div_scalar_ptr().

◆ vec4_div_scalar_ptr()

void vec4_div_scalar_ptr ( vector4 * res,
const vector4 * v,
vm_float_t s )

Definition at line 472 of file vector4_ptr.c.

References vec4_div_scalar_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_div_scalar().

◆ vec4_dot()

vm_float_t vec4_dot ( const vector4 a,
const vector4 b )

Computes the dot product of two vector4.

Parameters
aFirst vector.
bSecond vector.
Returns
The dot product (a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w).

Definition at line 388 of file vector4.c.

References vector4::w, vector4::x, vector4::y, and vector4::z.

Referenced by vec4_length(), vec4_length_squared(), vec4_project_ptr(), and vec4_slide_ptr().

◆ vec4_eq()

bool vec4_eq ( const vector4 a,
const vector4 b )

Returns true if two vectors are equal within VECMAT_EPSILON.

Parameters
aFirst vector.
bSecond vector.
Returns
True if a and b are approximately equal.

Definition at line 64 of file vecmat.c.

References VECMAT_EPSILON, VECMAT_FABS, vector4::w, vector4::x, vector4::y, and vector4::z.

◆ vec4_floor()

vector4 vec4_floor ( const vector4 v)

Applies the floor per component to a vector4.

See vec4_floor_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The floored vector.

Definition at line 295 of file vector4.c.

References vec4_floor_ptr().

◆ vec4_floor_ptr()

void vec4_floor_ptr ( vector4 * res,
const vector4 * v )

Definition at line 612 of file vector4_ptr.c.

References vec4_floor_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_floor().

◆ vec4_fract()

vector4 vec4_fract ( const vector4 v)

Returns the fractional part of each component.

See vec4_fract_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector4.

Definition at line 518 of file vector4.c.

References vec4_fract_ptr().

◆ vec4_fract_ptr()

void vec4_fract_ptr ( vector4 * res,
const vector4 * v )

Definition at line 642 of file vector4_ptr.c.

References vec4_fract_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_fract().

◆ vec4_homogenize()

vector4 vec4_homogenize ( const vector4 v)

Homogenizes a vector4 (divides x, y, z by w).

See vec4_homogenize_ptr for the out-parameter version.

Parameters
vThe homogeneous vector (w != 0.0f).
Returns
The normalized cartesian vector4.

Definition at line 374 of file vector4.c.

References vec4_homogenize_ptr().

◆ vec4_homogenize_ptr()

void vec4_homogenize_ptr ( vector4 * res,
const vector4 * v )

Definition at line 652 of file vector4_ptr.c.

References vec4_homogenize_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_homogenize().

◆ vec4_is_normalized()

bool vec4_is_normalized ( const vector4 v)

Returns true if the vector has unit length.

Parameters
vInput vector.
Returns
True if the vector has unit length.

Definition at line 626 of file vector4.c.

References vec4_length_squared(), VECMAT_EPSILON, and VECMAT_FABS.

◆ vec4_is_zero()

bool vec4_is_zero ( const vector4 v)

Returns true if every component is zero.

Parameters
vInput vector.
Returns
True if every component is zero.

Definition at line 615 of file vector4.c.

References vec4_length_squared(), and VECMAT_EPSILON.

◆ vec4_length()

vm_float_t vec4_length ( const vector4 v)

Computes the length (magnitude) of a vector4.

Parameters
vThe vector.
Returns
The Euclidean length of v.

Definition at line 399 of file vector4.c.

References vec4_dot(), and VECMAT_SQRT.

Referenced by vec4_distance(), and vec4_normalize_ptr_scalar().

◆ vec4_length_squared()

vm_float_t vec4_length_squared ( const vector4 v)

Returns the squared Euclidean length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 592 of file vector4.c.

References vec4_dot().

Referenced by vec4_distance_squared(), vec4_is_normalized(), and vec4_is_zero().

◆ vec4_lerp()

vector4 vec4_lerp ( const vector4 a,
const vector4 b,
const vm_float_t t )

Linearly interpolates between two vector4.

See vec4_lerp_ptr for the out-parameter version.

Parameters
aStart vector.
bEnd vector.
tInterpolation factor [0, 1].
Returns
The interpolated vector (a * (1 - t) + b * t).

Definition at line 342 of file vector4.c.

References vec4_lerp_ptr().

◆ vec4_lerp_ptr()

void vec4_lerp_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b,
vm_float_t t )

Definition at line 532 of file vector4_ptr.c.

References vec4_lerp_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_lerp().

◆ vec4_max()

vector4 vec4_max ( const vector4 a,
const vector4 b )

Computes the component-wise maximum of two vector4.

See vec4_max_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component max(a, b).

Definition at line 265 of file vector4.c.

References vec4_max_ptr().

◆ vec4_max_ptr()

void vec4_max_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Definition at line 522 of file vector4_ptr.c.

References vec4_max_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_max().

◆ vec4_min()

vector4 vec4_min ( const vector4 a,
const vector4 b )

Computes the component-wise minimum of two vector4.

See vec4_min_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component min(a, b).

Definition at line 249 of file vector4.c.

References vec4_min_ptr().

◆ vec4_min_ptr()

void vec4_min_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Definition at line 512 of file vector4_ptr.c.

References vec4_min_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_min().

◆ vec4_mul()

vector4 vec4_mul ( const vector4 a,
const vector4 b )

Component-wise multiplication of two vectors.

See vec4_mul_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 188 of file vector4.c.

References vec4_mul_ptr().

◆ vec4_mul_ptr()

void vec4_mul_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Definition at line 452 of file vector4_ptr.c.

References vec4_mul_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_mul().

◆ vec4_mul_scalar()

vector4 vec4_mul_scalar ( const vector4 v,
const vm_float_t s )

Component-wise multiplication of vector by scalar.

See vec4_mul_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar.
Returns
Result vector.

Definition at line 156 of file vector4.c.

References vec4_mul_scalar_ptr().

◆ vec4_mul_scalar_ptr()

void vec4_mul_scalar_ptr ( vector4 * res,
const vector4 * v,
vm_float_t s )

Definition at line 462 of file vector4_ptr.c.

References vec4_mul_scalar_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_mul_scalar().

◆ vec4_near()

bool vec4_near ( const vector4 a,
const vector4 b,
const vm_float_t eps )

Returns true if a and b are within eps of each other.

Parameters
aFirst input vector.
bSecond input vector.
epsDistance tolerance.
Returns
True if a and b are within eps.

Definition at line 639 of file vector4.c.

References VECMAT_FABS, vector4::w, vector4::x, vector4::y, and vector4::z.

◆ vec4_neg()

vector4 vec4_neg ( const vector4 v)

Negation of a vector.

See vec4_neg_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The negated vector.

Definition at line 203 of file vector4.c.

References vec4_neg_ptr().

◆ vec4_neg_ptr()

void vec4_neg_ptr ( vector4 * res,
const vector4 * v )

Definition at line 482 of file vector4_ptr.c.

References vec4_neg_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_neg().

◆ vec4_normalize()

vector4 vec4_normalize ( const vector4 v)

Normalizes a vector4 to unit length.

See vec4_normalize_ptr for the out-parameter version.

Parameters
vThe vector (non-zero).
Returns
The normalized vector.

Definition at line 233 of file vector4.c.

References vec4_normalize_ptr().

◆ vec4_normalize_ptr()

void vec4_normalize_ptr ( vector4 * res,
const vector4 * v )

Definition at line 502 of file vector4_ptr.c.

References vec4_normalize_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_normalize().

◆ vec4_one()

vector4 vec4_one ( void )

Returns a vector4 with all components set to 1.0f.

Returns
A vector4 with all components set to 1.0f.

Definition at line 22 of file vector4.c.

◆ vec4_project()

vector4 vec4_project ( const vector4 a,
const vector4 b )

Projects a onto b.

See vec4_project_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector4.

Definition at line 534 of file vector4.c.

References vec4_project_ptr().

◆ vec4_project_ptr()

void vec4_project_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Projects a onto b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 385 of file vector4_ptr.c.

References vec4_dot(), vector4::w, vector4::x, vector4::y, and vector4::z.

Referenced by vec4_project(), and vec4_reject_ptr().

◆ vec4_reject()

vector4 vec4_reject ( const vector4 a,
const vector4 b )

Returns the component of a orthogonal to b.

See vec4_reject_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector4.

Definition at line 550 of file vector4.c.

References vec4_reject_ptr().

◆ vec4_reject_ptr()

void vec4_reject_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Returns the component of a orthogonal to b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 422 of file vector4_ptr.c.

References vec4_project_ptr(), vector4::w, vector4::x, vector4::y, and vector4::z.

Referenced by vec4_reject().

◆ vec4_round()

vector4 vec4_round ( const vector4 v)

Applies round per component to a vector4.

See vec4_round_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The rounded vector.

Definition at line 325 of file vector4.c.

References vec4_round_ptr().

◆ vec4_round_ptr()

void vec4_round_ptr ( vector4 * res,
const vector4 * v )

Definition at line 632 of file vector4_ptr.c.

References vec4_round_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_round().

◆ vec4_saturate()

vector4 vec4_saturate ( const vector4 v)

Clamps each component to the range [0, 1].

See vec4_saturate_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector4.

Definition at line 503 of file vector4.c.

References vec4_saturate_ptr().

◆ vec4_saturate_ptr()

void vec4_saturate_ptr ( vector4 * res,
const vector4 * v )

Definition at line 592 of file vector4_ptr.c.

References vec4_saturate_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_saturate().

◆ vec4_sign()

vector4 vec4_sign ( const vector4 v)

Computes the sign per component of a vector4 (-1, 0, or 1).

See vec4_sign_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The sign vector.

Definition at line 280 of file vector4.c.

References vec4_sign_ptr().

◆ vec4_sign_ptr()

void vec4_sign_ptr ( vector4 * res,
const vector4 * v )

Definition at line 602 of file vector4_ptr.c.

References vec4_sign_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_sign().

◆ vec4_slide()

vector4 vec4_slide ( const vector4 v,
const vector4 normal )

Removes the component of v along normal.

See vec4_slide_ptr instead.

Parameters
vInput vector.
normalSurface normal.
Returns
The resulting vector4.

Definition at line 566 of file vector4.c.

References vec4_slide_ptr().

◆ vec4_slide_ptr()

void vec4_slide_ptr ( vector4 * res,
const vector4 * v,
const vector4 * normal )

Removes the component of v along normal.

Parameters
resOutput vector.
vInput vector.
normalSurface normal.

Definition at line 406 of file vector4_ptr.c.

References vec4_dot(), vector4::w, vector4::x, vector4::y, and vector4::z.

Referenced by vec4_slide().

◆ vec4_splat()

vector4 vec4_splat ( const vm_float_t s)

Returns a vector with every component set to s.

See vec4_splat_ptr instead.

Parameters
sScalar value.
Returns
The resulting vector4.

Definition at line 581 of file vector4.c.

◆ vec4_sub()

vector4 vec4_sub ( const vector4 a,
const vector4 b )

Component-wise subtraction of two vectors.

See vec4_sub_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 140 of file vector4.c.

References vec4_sub_ptr().

Referenced by vec4_distance(), and vec4_distance_squared().

◆ vec4_sub_ptr()

void vec4_sub_ptr ( vector4 * res,
const vector4 * a,
const vector4 * b )

Definition at line 442 of file vector4_ptr.c.

References vec4_sub_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_sub().

◆ vec4_sub_scalar()

vector4 vec4_sub_scalar ( const vector4 v,
const vm_float_t s )

Subtracts a scalar from each component.

See vec4_sub_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector4.

Definition at line 471 of file vector4.c.

References vec4_sub_scalar_ptr().

◆ vec4_sub_scalar_ptr()

void vec4_sub_scalar_ptr ( vector4 * res,
const vector4 * v,
vm_float_t s )

Definition at line 572 of file vector4_ptr.c.

References vec4_sub_scalar_ptr_scalar(), and vm_cpu_init().

Referenced by vec4_sub_scalar().

◆ vec4_to_vec3()

vector3 vec4_to_vec3 ( const vector4 v)

Converts a vector4 to a vector3 (discards the w component).

Parameters
vThe source vector4.
Returns
A vector3 {v.x, v.y, v.z}.

Definition at line 423 of file vector4.c.

References vec4_to_vec3_ptr().

◆ vec4_to_vec3_ptr()

void vec4_to_vec3_ptr ( vector3 * res,
const vector4 * v )

Copies the x, y, z components from a vector4 to a vector3.

Parameters
resPointer to result vector3.
vPointer to input vector4.

Definition at line 285 of file vector4_ptr.c.

References vector3::x, vector4::x, vector3::y, vector4::y, vector3::z, and vector4::z.

Referenced by vec4_to_vec3().

◆ vec4_w_axis()

vector4 vec4_w_axis ( const vm_float_t w)

Returns a vector4 along the w-axis.

Parameters
wThe w component value.
Returns
A vector4 with (0.0f, 0.0f, 0.0f, w).

Definition at line 66 of file vector4.c.

◆ vec4_w_scale()

vector4 vec4_w_scale ( const vm_float_t w)

Returns a vector4 for scaling along the w-axis.

Parameters
wThe w scale factor.
Returns
A vector4 with (1.0f, 1.0f, 1.0f, w).

Definition at line 110 of file vector4.c.

◆ vec4_x_axis()

vector4 vec4_x_axis ( const vm_float_t x)

Returns a vector4 along the x-axis.

Parameters
xThe x component value.
Returns
A vector4 with (x, 0.0f, 0.0f, 0.0f).

Definition at line 33 of file vector4.c.

◆ vec4_x_scale()

vector4 vec4_x_scale ( const vm_float_t x)

Returns avector4 for scaling along the x-axis.

Parameters
xThe x scale factor.
Returns
A vector4 with (x, 1.0f, 1.0f, 1.0f).

Definition at line 77 of file vector4.c.

◆ vec4_y_axis()

vector4 vec4_y_axis ( const vm_float_t y)

Returns a vector4 along the y-axis.

Parameters
yThe y component value.
Returns
A vector4 with (0.0f, y, 0.0f, 0.0f).

Definition at line 44 of file vector4.c.

◆ vec4_y_scale()

vector4 vec4_y_scale ( const vm_float_t y)

Returns a vector4 for scaling along the y-axis.

Parameters
yThe y scale factor.
Returns
A vector4 with (1.0f, y, 1.0f, 1.0f).

Definition at line 88 of file vector4.c.

◆ vec4_z_axis()

vector4 vec4_z_axis ( const vm_float_t z)

Returns a vector4 along the z-axis.

Parameters
zThe z component value.
Returns
A vector4 with (0.0f, 0.0f, z, 0.0f).

Definition at line 55 of file vector4.c.

◆ vec4_z_scale()

vector4 vec4_z_scale ( const vm_float_t z)

Returns a vector4for scaling along the z-axis.

Parameters
zThe z scale factor.
Returns
A vector4 with (1.0f, 1.0f, z, 1.0f).

Definition at line 99 of file vector4.c.

◆ vec4_zero()

vector4 vec4_zero ( void )

Returns a zero-initialized vector4.

Returns
A vector4 with all components set to 0.0f.

Definition at line 12 of file vector4.c.

◆ vec4i_abs()

vector4i vec4i_abs ( const vector4i v)

Computes the absolute value per component of a vector4i.

See vec4i_abs_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The absolute vector4i.

Definition at line 217 of file vector4i.c.

References vec4i_abs_ptr().

◆ vec4i_abs_ptr()

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.

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 116 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_abs().

◆ vec4i_add()

vector4i vec4i_add ( const vector4i a,
const vector4i b )

Component-wise addition of two vectors.

See vec4i_add_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 123 of file vector4i.c.

References vec4i_add_ptr().

◆ vec4i_add_ptr()

void vec4i_add_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Adds the components of two vector4i and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 15 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_add().

◆ vec4i_add_scalar()

vector4i vec4i_add_scalar ( const vector4i v,
const vm_int_t s )

Adds a scalar to each component.

See vec4i_add_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector4i.

Definition at line 395 of file vector4i.c.

References vec4i_add_scalar_ptr().

◆ vec4i_add_scalar_ptr()

void vec4i_add_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Adds a scalar to each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 293 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_add_scalar().

◆ vec4i_clamp()

vector4i vec4i_clamp ( const vector4i v,
const vector4i min,
const vector4i max )

Clamps each component of the input vector to the range defined by the minimum and maximum vectors.

See vec4i_clamp_ptr for the out-parameter version.

Parameters
vThe input vector.
minThe minimum value for each component.
maxThe maximum value for each component.
Returns
A new vector4i with each component clamped to [min, max].

Definition at line 314 of file vector4i.c.

References vec4i_clamp_ptr().

◆ vec4i_clamp_ptr()

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.

Parameters
resPointer to result vector
vPointer to input vector
minPointer to minimum bounds vector
maxPointer to maximum bounds vector

Definition at line 222 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_clamp().

◆ vec4i_distance()

vm_float_t vec4i_distance ( const vector4i a,
const vector4i b )

Computes the Euclidean distance between two vector4i.

Parameters
aFirst vector.
bSecond vector.
Returns
The distance between a and b.

Definition at line 351 of file vector4i.c.

References vec4i_length(), and vec4i_sub().

◆ vec4i_distance_squared()

vm_int_t vec4i_distance_squared ( const vector4i a,
const vector4i b )

Returns the squared Euclidean distance between a and b.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 497 of file vector4i.c.

References vec4i_length_squared(), and vec4i_sub().

◆ vec4i_div()

vector4i vec4i_div ( const vector4i a,
const vector4i b )

Divides two vectors component-wise.

See vec4i_div_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector4i.

Definition at line 379 of file vector4i.c.

References vec4i_div_ptr().

◆ vec4i_div_floor()

vector4i vec4i_div_floor ( const vector4i a,
const vector4i b )

Component-wise floored division of a by b.

See vec4i_div_floor_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector4i.

Definition at line 443 of file vector4i.c.

References vec4i_div_floor_ptr().

◆ vec4i_div_floor_ptr()

void vec4i_div_floor_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Component-wise floored division of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 338 of file vector4i_ptr.c.

References vm_div_floor4(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_div_floor().

◆ vec4i_div_ptr()

void vec4i_div_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Divides two vectors component-wise.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 278 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_div().

◆ vec4i_div_scalar()

vector4i vec4i_div_scalar ( const vector4i v,
const vm_int_t s )

Component-wise division of vector by scalar.

See vec4i_div_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar (non-zero).
Returns
Result vector.

Definition at line 171 of file vector4i.c.

References vec4i_div_scalar_ptr().

◆ vec4i_div_scalar_ptr()

void vec4i_div_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Divides the components of a vector4i by a scalar and stores the result in res.

If the scalar is zero, sets all components of res to zero.

Parameters
resPointer to result vector
vPointer to input vector
sScalar divisor

Definition at line 65 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_div_scalar().

◆ vec4i_dot()

vm_int_t vec4i_dot ( const vector4i a,
const vector4i b )

Computes the dot product of two vector4i.

Parameters
aFirst vector.
bSecond vector.
Returns
The dot product.

Definition at line 328 of file vector4i.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_length(), and vec4i_length_squared().

◆ vec4i_eq()

bool vec4i_eq ( const vector4i a,
const vector4i b )

Returns true if two vectors are exactly equal.

Parameters
aFirst vector.
bSecond vector.
Returns
True if a and b are equal.

Definition at line 103 of file vecmat.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

◆ vec4i_is_zero()

bool vec4i_is_zero ( const vector4i v)

Returns true if every component is zero.

Parameters
vInput vector.
Returns
True if every component is zero.

Definition at line 582 of file vector4i.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

◆ vec4i_length()

vm_float_t vec4i_length ( const vector4i v)

Computes the length (magnitude) of a vector4i.

Parameters
vThe vector.
Returns
The Euclidean length of v.

Definition at line 339 of file vector4i.c.

References vec4i_dot(), and VECMAT_SQRT.

Referenced by vec4i_distance(), and vec4i_normalize_ptr().

◆ vec4i_length_chebyshev()

vm_int_t vec4i_length_chebyshev ( const vector4i v)

Returns the Chebyshev (L-inf) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 523 of file vector4i.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

◆ vec4i_length_manhattan()

vm_int_t vec4i_length_manhattan ( const vector4i v)

Returns the Manhattan (L1) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 508 of file vector4i.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

◆ vec4i_length_squared()

vm_int_t vec4i_length_squared ( const vector4i v)

Returns the squared Euclidean length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 485 of file vector4i.c.

References vec4i_dot().

Referenced by vec4i_distance_squared().

◆ vec4i_lerp()

vector4i vec4i_lerp ( const vector4i a,
const vector4i b,
const vm_float_t t )

Linearly interpolates between two vector4i.

See vec4i_lerp_ptr for the out-parameter version.

Parameters
aStart vector.
bEnd vector.
tInterpolation factor [0, 1].
Returns
The interpolated vector (a * (1 - t) + b * t).

Definition at line 296 of file vector4i.c.

References vec4i_lerp_ptr().

◆ vec4i_lerp_ptr()

void vec4i_lerp_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b,
const vm_float_t t )

Linearly interpolates between two vector4i using an interpolation factor t (clamped to [0,1]) and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector
tInterpolation factor

Definition at line 203 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_lerp().

◆ vec4i_max()

vector4i vec4i_max ( const vector4i a,
const vector4i b )

Computes the component-wise maximum of two vector4i.

See vec4i_max_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component max(a, b).

Definition at line 264 of file vector4i.c.

References vec4i_max_ptr().

◆ vec4i_max_component()

vm_int_t vec4i_max_component ( const vector4i v)

Returns the largest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 556 of file vector4i.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

◆ vec4i_max_ptr()

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.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 171 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_max().

◆ vec4i_min()

vector4i vec4i_min ( const vector4i a,
const vector4i b )

Computes the component-wise minimum of two vector4i.

See vec4i_min_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Per-component min(a, b).

Definition at line 248 of file vector4i.c.

References vec4i_min_ptr().

◆ vec4i_min_component()

vm_int_t vec4i_min_component ( const vector4i v)

Returns the smallest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 541 of file vector4i.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

◆ vec4i_min_ptr()

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.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 155 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_min().

◆ vec4i_mod()

vector4i vec4i_mod ( const vector4i a,
const vector4i b )

Component-wise floor modulo of a by b.

See vec4i_mod_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector4i.

Definition at line 427 of file vector4i.c.

References vec4i_mod_ptr().

◆ vec4i_mod_ptr()

void vec4i_mod_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Component-wise floor modulo of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 323 of file vector4i_ptr.c.

References vm_mod_floor4(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_mod().

◆ vec4i_mul()

vector4i vec4i_mul ( const vector4i a,
const vector4i b )

Component-wise multiplication of two vectors.

See vec4i_mul_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 187 of file vector4i.c.

References vec4i_mul_ptr().

◆ vec4i_mul_ptr()

void vec4i_mul_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Multiplies the components of two vector4i and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 87 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_mul().

◆ vec4i_mul_scalar()

vector4i vec4i_mul_scalar ( const vector4i v,
const vm_int_t s )

Component-wise multiplication of vector by scalar.

See vec4i_mul_scalar_ptr for the out-parameter version.

Parameters
vThe vector.
sThe scalar.
Returns
Result vector.

Definition at line 155 of file vector4i.c.

References vec4i_mul_scalar_ptr().

◆ vec4i_mul_scalar_ptr()

void vec4i_mul_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Multiplies the components of a vector4i by a scalar and stores the result in res.

Parameters
resPointer to result vector
vPointer to input vector
sScalar value

Definition at line 47 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_mul_scalar().

◆ vec4i_neg()

vector4i vec4i_neg ( const vector4i v)

Negation of a vector.

See vec4i_neg_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The negated vector.

Definition at line 202 of file vector4i.c.

References vec4i_neg_ptr().

◆ vec4i_neg_ptr()

void vec4i_neg_ptr ( vector4i * res,
const vector4i * v )

Negates the components of a vector4i and stores the result in res.

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 101 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_neg().

◆ vec4i_normalize()

vector4i vec4i_normalize ( const vector4i v)

Normalizes a vector4i to unit length.

See vec4i_normalize_ptr for the out-parameter version.

Parameters
vThe vector (non-zero).
Returns
The normalized vector.

Definition at line 232 of file vector4i.c.

References vec4i_normalize_ptr().

◆ vec4i_normalize_ptr()

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.

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

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 133 of file vector4i_ptr.c.

References vec4i_length(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_normalize().

◆ vec4i_one()

vector4i vec4i_one ( void )

Returns a vector4i with all components set to 1.

Returns
A vector4i with all components set to 1.

Definition at line 22 of file vector4i.c.

◆ vec4i_sign()

vector4i vec4i_sign ( const vector4i v)

Computes the sign per component of a vector4i (-1, 0, or 1).

See vec4i_sign_ptr for the out-parameter version.

Parameters
vThe vector.
Returns
The sign vector.

Definition at line 279 of file vector4i.c.

References vec4i_sign_ptr().

◆ vec4i_sign_ptr()

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.

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 186 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_sign().

◆ vec4i_splat()

vector4i vec4i_splat ( const vm_int_t s)

Returns a vector with every component set to s.

See vec4i_splat_ptr instead.

Parameters
sScalar value.
Returns
The resulting vector4i.

Definition at line 474 of file vector4i.c.

◆ vec4i_sub()

vector4i vec4i_sub ( const vector4i a,
const vector4i b )

Component-wise subtraction of two vectors.

See vec4i_sub_ptr for the out-parameter version.

Parameters
aFirst vector.
bSecond vector.
Returns
Result vector.

Definition at line 139 of file vector4i.c.

References vec4i_sub_ptr().

Referenced by vec4i_distance(), and vec4i_distance_squared().

◆ vec4i_sub_ptr()

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.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 31 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_sub().

◆ vec4i_sub_scalar()

vector4i vec4i_sub_scalar ( const vector4i v,
const vm_int_t s )

Subtracts a scalar from each component.

See vec4i_sub_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector4i.

Definition at line 411 of file vector4i.c.

References vec4i_sub_scalar_ptr().

◆ vec4i_sub_scalar_ptr()

void vec4i_sub_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Subtracts a scalar from each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 308 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_sub_scalar().

◆ vec4i_sum()

vm_int_t vec4i_sum ( const vector4i v)

Returns the sum of all components.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 571 of file vector4i.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

◆ vec4i_to_vec3i()

vector3i vec4i_to_vec3i ( const vector4i v)

Converts a vector4i to a vector3i (discards the w component).

Parameters
vThe source vector4i.
Returns
A vector3i {v.x, v.y, v.z}.

Definition at line 363 of file vector4i.c.

References vec4i_to_vec3i_ptr().

◆ vec4i_to_vec3i_ptr()

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.

Parameters
resPointer to result vector3i
vPointer to source vector4i

Definition at line 237 of file vector4i_ptr.c.

References vector3i::x, vector4i::x, vector3i::y, vector4i::y, vector3i::z, and vector4i::z.

Referenced by vec4i_to_vec3i().

◆ vec4i_w_axis()

vector4i vec4i_w_axis ( const vm_int_t w)

Returns a vector4i along the w-axis.

Parameters
wThe w component value.
Returns
A vector4i with (0, 0, 0, w).

Definition at line 65 of file vector4i.c.

◆ vec4i_w_scale()

vector4i vec4i_w_scale ( const vm_int_t w)

Returns a vector4i for scaling along the w-axis.

Parameters
wThe w scale factor.
Returns
A vector4i with (1, 1, 1, w).

Definition at line 109 of file vector4i.c.

◆ vec4i_wrap()

vector4i vec4i_wrap ( const vector4i v,
const vector4i period )

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

See vec4i_wrap_ptr instead.

Parameters
vInput vector.
periodWrap period per component.
Returns
The resulting vector4i.

Definition at line 459 of file vector4i.c.

References vec4i_wrap_ptr().

◆ vec4i_wrap_ptr()

void vec4i_wrap_ptr ( vector4i * res,
const vector4i * v,
const vector4i * period )

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

Parameters
resOutput vector.
vInput vector.
periodWrap period per component.

Definition at line 353 of file vector4i_ptr.c.

References vm_mod_floor4(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_wrap().

◆ vec4i_x_axis()

vector4i vec4i_x_axis ( const vm_int_t x)

Returns a vector4i along the x-axis.

Parameters
xThe x component value.
Returns
A vector4i with (x, 0, 0, 0).

Definition at line 33 of file vector4i.c.

◆ vec4i_x_scale()

vector4i vec4i_x_scale ( const vm_int_t x)

Returns a vector4i for scaling along the x-axis.

Parameters
xThe x scale factor.
Returns
A vector4i with (x, 1, 1, 1).

Definition at line 76 of file vector4i.c.

◆ vec4i_y_axis()

vector4i vec4i_y_axis ( const vm_int_t y)

Returns a vector4i along the y-axis.

Parameters
yThe y component value.
Returns
A vector4i with (0, y, 0, 0).

Definition at line 44 of file vector4i.c.

◆ vec4i_y_scale()

vector4i vec4i_y_scale ( const vm_int_t y)

Returns a vector4i for scaling along the y-axis.

Parameters
yThe y scale factor.
Returns
A vector4i with (1, y, 1, 1).

Definition at line 87 of file vector4i.c.

◆ vec4i_z_axis()

vector4i vec4i_z_axis ( const vm_int_t z)

Returns a vector4i along the z-axis.

Parameters
zThe z component value.
Returns
A vector4i with (0, 0, z, 0).

Definition at line 55 of file vector4i.c.

◆ vec4i_z_scale()

vector4i vec4i_z_scale ( const vm_int_t z)

Returns a vector4i for scaling along the z-axis.

Parameters
zThe z scale factor.
Returns
A vector4i with (1, 1, z, 1).

Definition at line 98 of file vector4i.c.

◆ vec4i_zero()

vector4i vec4i_zero ( void )

Returns a zero-initialized vector4i.

Returns
A vector4i with all components set to 0.

Definition at line 12 of file vector4i.c.

◆ vm_cpu_compiled_features()

vm_cpu_features_t vm_cpu_compiled_features ( void )

Definition at line 130 of file cpu.c.

References VM_CPU_AVX, VM_CPU_AVX2, VM_CPU_AVX512, VM_CPU_SCALAR, VM_CPU_SVE, and VM_CPU_SVE2.

Referenced by vm_cpu_selected_features().

◆ vm_cpu_init()

◆ vm_cpu_name()

const char * vm_cpu_name ( vm_cpu_features_t features)

Definition at line 193 of file cpu.c.

References VM_CPU_AVX, VM_CPU_AVX2, VM_CPU_AVX512, VM_CPU_SCALAR, VM_CPU_SVE, and VM_CPU_SVE2.

◆ vm_cpu_runtime_features()

◆ vm_cpu_selected_features()

vm_cpu_features_t vm_cpu_selected_features ( void )

Variable Documentation

◆ VM_DEG_TO_RAD

const vm_float_t VM_DEG_TO_RAD = VM_DEG_TO_RAD_F64
static

Definition at line 85 of file vecmat.h.

Referenced by deg_to_rad().

◆ VM_DEG_TO_RAD_F32

const float VM_DEG_TO_RAD_F32 = 0.017453292519943295769236907684886f
static

Definition at line 53 of file vecmat.h.

◆ VM_DEG_TO_RAD_F64

const double VM_DEG_TO_RAD_F64 = 0.017453292519943295769236907684886
static

Definition at line 55 of file vecmat.h.

◆ VM_RAD_TO_DEG

const vm_float_t VM_RAD_TO_DEG = VM_RAD_TO_DEG_F64
static

Definition at line 86 of file vecmat.h.

Referenced by quat_to_euler_ptr(), and rad_to_deg().

◆ VM_RAD_TO_DEG_F32

const float VM_RAD_TO_DEG_F32 = 57.295779513082320876798154814105f
static

Definition at line 54 of file vecmat.h.

◆ VM_RAD_TO_DEG_F64

const double VM_RAD_TO_DEG_F64 = 57.295779513082320876798154814105
static

Definition at line 56 of file vecmat.h.