121 res->
x = v->
x * inv_len;
122 res->
y = v->
y * inv_len;
123 res->
z = v->
z * inv_len;
135 res->
x = a->
y * b->
z - a->
z * b->
y;
136 res->
y = a->
z * b->
x - a->
x * b->
z;
137 res->
z = a->
x * b->
y - a->
y * b->
x;
176 res->
x = (v->
x > 0.0f) - (v->
x < 0.0f);
177 res->
y = (v->
y > 0.0f) - (v->
y < 0.0f);
178 res->
z = (v->
z > 0.0f) - (v->
z < 0.0f);
230 res->
x = incident->
x - 2.0f * dot * normal->
x;
231 res->
y = incident->
y - 2.0f * dot * normal->
y;
232 res->
z = incident->
z - 2.0f * dot * normal->
z;
246 const vm_float_t k = 1.0f - eta * eta * (1.0f - dot * dot);
248 res->
x = res->
y = res->
z = 0.0f;
252 res->
x = eta * incident->
x - factor * normal->
x;
253 res->
y = eta * incident->
y - factor * normal->
y;
254 res->
z = eta * incident->
z - factor * normal->
z;
267 res->
x = a->
x + t * (b->
x - a->
x);
268 res->
y = a->
y + t * (b->
y - a->
y);
269 res->
z = a->
z + t * (b->
z - a->
z);
308 res->
x = (b->
x == 0.0f) ? 0.0f : a->
x / b->
x;
309 res->
y = (b->
y == 0.0f) ? 0.0f : a->
y / b->
y;
310 res->
z = (b->
z == 0.0f) ? 0.0f : a->
z / b->
z;
397 res->
x = b->
x * scale;
398 res->
y = b->
y * scale;
399 res->
z = b->
z * scale;
412 res->
x = v->
x - normal->
x * d;
413 res->
y = v->
y - normal->
y * d;
414 res->
z = v->
z - normal->
z * d;
428 res->
x = a->
x - projected.
x;
429 res->
y = a->
y - projected.
y;
430 res->
z = a->
z - projected.
z;
448 res->
x = v->
x * cs + (k.
y * v->
z - k.
z * v->
y) * sn + k.
x * d * (1.0f - cs);
449 res->
y = v->
y * cs + (k.
z * v->
x - k.
x * v->
z) * sn + k.
y * d * (1.0f - cs);
450 res->
z = v->
z * cs + (k.
x * v->
y - k.
y * v->
x) * sn + k.
z * d * (1.0f - cs);
493 if (dist <= max_delta || dist == 0.0f) {
498 res->
x = current->
x + dx * scale;
499 res->
y = current->
y + dy * scale;
500 res->
z = current->
z + dz * scale;
513 if (len <= max_len || len == 0.0f) {
518 res->
x = v->
x * scale;
519 res->
y = v->
y * scale;
520 res->
z = v->
z * scale;
535 ? (
vector3){.x = 0.0f, .y = 1.0f, .z = 0.0f}
536 : (
vector3){.x = 1.0f, .y = 0.0f, .z = 0.0f};
#define VECMAT_FMAX(a, b)
#define VECMAT_FMIN(a, b)
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.
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.
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_sub_scalar_ptr(vector3 *res, const vector3 *v, const vm_float_t s)
Subtracts a scalar from each component.
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_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_xy_ptr(vector2 *res, const vector3 *v)
Returns the x and y components as a 2D vector.
void vec3_from_vec2_ptr(vector3 *res, const vector2 *v, const vm_float_t z)
Builds a higher-dimension vector from a vector2.
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_lerp_ptr(vector3 *res, const vector3 *a, const vector3 *b, const vm_float_t t)
Linear interpolation between two vectors.
void vec3_round_ptr(vector3 *res, const vector3 *v)
Component-wise round of a vector.
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.
void vec3_max_ptr(vector3 *res, const vector3 *a, const vector3 *b)
Component-wise maximum of two vectors.
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.
void vec3_fract_ptr(vector3 *res, const vector3 *v)
Returns the fractional part of each component.
void vec3_limit_length_ptr(vector3 *res, const vector3 *v, const vm_float_t max_len)
Clamps the vector length to max_len.
void vec3_slide_ptr(vector3 *res, const vector3 *v, const vector3 *normal)
Removes the component of v along normal.
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].
void vec3_add_scalar_ptr(vector3 *res, const vector3 *v, const vm_float_t s)
Adds a scalar to each component.
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_scale_ptr(vector3 *res, const vector3 *v, const vm_float_t s)
Scales the vector by a 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_neg_ptr(vector3 *res, const vector3 *v)
Negation of a vector.
void vec3_reflect_ptr(vector3 *res, const vector3 *incident, const vector3 *normal)
Compute reflection of the incident vector over normal.
void vec3_div_scalar_ptr(vector3 *res, const vector3 *v, const vm_float_t s)
Component-wise division of vector by scalar.
void vec3_mul_scalar_ptr(vector3 *res, const vector3 *v, const vm_float_t s)
Component-wise multiplication of vector by scalar.