14 return (
vector3){.x = 0.0f, .y = 0.0f, .z = 0.0f};
24 return (
vector3){.x = 1.0f, .y = 1.0f, .z = 1.0f};
35 return (
vector3){.x = x, .y = 0.0f, .z = 0.0f};
46 return (
vector3){.x = 0.0f, .y = y, .z = 0.0f};
57 return (
vector3){.x = 0.0f, .y = 0.0f, .z = z};
68 return (
vector3){.x = x, .y = 1.0f, .z = 1.0f};
79 return (
vector3){.x = 1.0f, .y = y, .z = 1.0f};
90 return (
vector3){.x = 1.0f, .y = 1.0f, .z = z};
430 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
630 return (
vector3){.x = s, .y = s, .z = s};
754 return dx * dx + dy * dy + dz * dz;
801 return v.
x + v.
y + v.
z;
void vec3_add_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Adds a scalar to each component.
#define VECMAT_FMAX(a, b)
void vec3_mul_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise multiplication of two vectors.
void vec3_abs_ptr(vector3 *res, const vector3 *v)
Computes the absolute value per component of a vector3.
void vec3_min_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise minimum of two vectors.
void vec3_sign_ptr(vector3 *res, const vector3 *v)
Component-wise sign of a vector.
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_saturate_ptr(vector3 *res, const vector3 *v)
Clamps each component to the range [0, 1].
void vec3_sub_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Subtracts a scalar from each component.
#define VECMAT_FMIN(a, b)
void vec3_from_vec2_ptr(vector3 *res, const vector2 *v, vm_float_t z)
Builds a higher-dimension vector from a vector2.
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_xy_ptr(vector2 *res, const vector3 *v)
Returns the x and y components as a 2D vector.
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_rotate_axis_ptr(vector3 *res, const vector3 *v, const vector3 *axis, vm_float_t angle)
Rotates v around axis by angle radians.
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_round_ptr(vector3 *res, const vector3 *v)
Component-wise round of a vector.
void vec3_lerp_ptr(vector3 *res, const vector3 *a, const vector3 *b, vm_float_t t)
Linear interpolation between two vectors.
void vec3_max_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise maximum of two vectors.
void vec3_fract_ptr(vector3 *res, const vector3 *v)
Returns the fractional part of each component.
void vec3_slide_ptr(vector3 *res, const vector3 *v, const vector3 *normal)
Removes the component of v along normal.
void vec3_cross_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Compute cross-product of two vectors.
void vec3_normalize_ptr(vector3 *res, const vector3 *v)
Normalize a vector to unit length.
void vec3_ceil_ptr(vector3 *res, const vector3 *v)
Component-wise ceil of a vector.
void vec3_reject_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Returns the component of a orthogonal to b.
void vec3_orthonormal_basis_ptr(const vector3 *n, vector3 *t, vector3 *b)
Builds a tangent and bitangent orthonormal to n.
void vec3_div_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Component-wise division of vector by scalar.
void vec3_mul_scalar_ptr(vector3 *res, const vector3 *v, vm_float_t s)
Component-wise multiplication of vector by scalar.
void vec3_project_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Projects a onto b.
void vec3_floor_ptr(vector3 *res, const vector3 *v)
Component-wise floor of a vector.
void vec3_limit_length_ptr(vector3 *res, const vector3 *v, vm_float_t max_len)
Clamps the vector length to max_len.
#define VECMAT_ATAN2(y, x)
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_neg_ptr(vector3 *res, const vector3 *v)
Negation of a vector.
void vec3_reflect_ptr(vector3 *res, const vector3 *incident, const vector3 *normal)
Compute reflection of the incident vector over normal.
vector3 vec3_slide(const vector3 v, const vector3 normal)
Removes the component of v along normal.
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.
void vec3_orthonormal_basis(const vector3 n, vector3 *t, vector3 *b)
Builds a tangent and bitangent orthonormal to n.
vm_float_t vec3_length(const vector3 v)
Computes the length (magnitude) of a vector3.
vector2 vec3_xy(const vector3 v)
Returns the x and y components as a 2D vector.
vector3 vec3_div(const vector3 a, const vector3 b)
Divides two vectors component-wise.
vector3 vec3_sign(const vector3 v)
Computes the sign per component of a vector3 (-1, 0, or 1).
vector3 vec3_floor(const vector3 v)
Applies the floor per component to a vector3.
vector3 vec3_reflect(const vector3 incident, const vector3 normal)
Reflects an incident vector over normal.
vector3 vec3_splat(const vm_float_t s)
Returns a vector with every component set to s.
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].
vector3 vec3_max(const vector3 a, const vector3 b)
Computes the component-wise maximum of two vector3.
vm_float_t vec3_dot(const vector3 a, const vector3 b)
Computes the dot product of two vector3.
vector3 vec3_one(void)
Returns a vector3 with all components set to 1.0f.
vector3 vec3_add(const vector3 a, const vector3 b)
Component-wise addition of two vectors.
vector3 vec3_y_scale(const vm_float_t y)
Returns a vector3 for scaling along the y-axis.
vm_float_t vec3_sum(const vector3 v)
Returns the sum of all components.
vector3 vec3_project(const vector3 a, const vector3 b)
Projects a onto b.
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.
vector3 vec3_x_scale(const vm_float_t x)
Returns a vector3 for scaling along the x-axis.
vector3 vec3_mul_scalar(const vector3 v, const vm_float_t s)
Component-wise multiplication of vector by scalar.
vector3 vec3_zero(void)
Returns a zero-initialized vector3.
vector3 vec3_min(const vector3 a, const vector3 b)
Computes the component-wise minimum of two vector3.
vector3 vec3_scale(const vector3 v, const vm_float_t s)
Scales the vector by a scalar.
vector3 vec3_add_scalar(const vector3 v, const vm_float_t s)
Adds a scalar to each component.
vector3 vec3_y_axis(const vm_float_t y)
Returns a vector3 along the y-axis.
vector3 vec3_sub_scalar(const vector3 v, const vm_float_t s)
Subtracts a scalar from each component.
vector3 vec3_z_axis(const vm_float_t z)
Returns a vector3 along the z-axis.
vm_float_t vec3_min_component(const vector3 v)
Returns the smallest component.
vector3 vec3_clamp(const vector3 v, const vector3 min, const vector3 max)
Clamps a vector3 between min and max per component.
vector3 vec3_abs(const vector3 v)
Computes the absolute value per component of a vector3.
vector3 vec3_mul(const vector3 a, const vector3 b)
Component-wise multiplication of two vectors.
bool vec3_is_zero(const vector3 v)
Returns true if every component is zero.
vector3 vec3_cross(const vector3 a, const vector3 b)
Computes the cross-product of two vector3.
vm_float_t vec3_distance_squared(const vector3 a, const vector3 b)
Returns the squared Euclidean distance between a and b.
vector3 vec3_neg(const vector3 v)
Negation of a vector.
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.
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.
vector3 vec3_from_vec2(const vector2 v, const vm_float_t z)
Builds a vector3 from a vector2 and z.
vector3 vec3_round(const vector3 v)
Applies round per component to a vector3.
vector3 vec3_sub(const vector3 a, const vector3 b)
Component-wise subtraction of two vectors.
vm_float_t vec3_length_squared(const vector3 v)
Returns the squared Euclidean length.
vector3 vec3_fract(const vector3 v)
Returns the fractional part of each component.
vector3 vec3_rotate_axis(const vector3 v, const vector3 axis, const vm_float_t angle)
Rotates v around axis by angle radians.
vector3 vec3_limit_length(const vector3 v, const vm_float_t max_len)
Clamps the vector length to max_len.
vm_float_t vec3_angle(const vector3 a, const vector3 b)
Computes the angle between two non-zero vector3 in radians.
vm_float_t vec3_length_manhattan(const vector3 v)
Returns the Manhattan (L1) length.
vm_float_t vec3_distance(const vector3 a, const vector3 b)
Computes the Euclidean distance between two vector3.
vector3 vec3_normalize(const vector3 v)
Normalizes a vector3 to unit length.
vector3 vec3_x_axis(const vm_float_t x)
Returns a vector3 along the x-axis.
vector3 vec3_div_scalar(const vector3 v, const vm_float_t s)
Component-wise division of vector by scalar.
vm_float_t vec3_length_chebyshev(const vector3 v)
Returns the Chebyshev (L-inf) length.
vector3 vec3_saturate(const vector3 v)
Clamps each component to the range [0, 1].
bool vec3_is_normalized(const vector3 v)
Returns true if the vector has unit length.
vm_float_t vec3_max_component(const vector3 v)
Returns the largest component.
vector3 vec3_z_scale(const vm_float_t z)
Returns a vector3 for scaling along the z-axis.
vector3 vec3_reject(const vector3 a, const vector3 b)
Returns the component of a orthogonal to b.
vector3 vec3_lerp(const vector3 a, const vector3 b, const vm_float_t t)
Linearly interpolates between two vector3.
vector3 vec3_ceil(const vector3 v)
Applies ceil per component to a vector3.