|
Vecmat 0.2.3
C math and linear algebra library for 2D/3D graphics, physics, and science.
|
#include <vecmat.h>Go to the source code of this file.
Functions | |
| 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, const vm_float_t s) |
| Component-wise multiplication of vector by scalar. | |
| 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_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, const 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, const 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, const 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, const vm_float_t s) |
| Adds a scalar to each component. | |
| void | vec3_sub_scalar_ptr (vector3 *res, const vector3 *v, const vm_float_t s) |
| Subtracts a scalar from each component. | |
| 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_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, const vm_float_t angle) |
| Rotates v around axis by angle radians. | |
| 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_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, const vm_float_t max_delta) |
| Moves current toward target by at most max_delta. | |
| 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_orthonormal_basis_ptr (const vector3 *n, vector3 *t, vector3 *b) |
| Builds a tangent and bitangent orthonormal to n. | |
Computes the absolute value per component of a vector3.
| res | Result vector. |
| v | Vector. |
Definition at line 100 of file vector3_ptr.c.
References VECMAT_FABS, vector3::x, vector3::y, and vector3::z.
Referenced by vec3_abs().
Component-wise addition of two vectors.
| res | Result vector. |
| a | First vector. |
| b | Second vector. |
Definition at line 14 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_add().
| void vec3_add_scalar_ptr | ( | vector3 * | res, |
| const vector3 * | v, | ||
| const vm_float_t | s ) |
Adds a scalar to each component.
| res | Output vector. |
| v | Input vector. |
| s | Scalar value. |
Definition at line 320 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_add_scalar().
Component-wise ceil of a vector.
| res | Result vector. |
| v | Vector. |
Definition at line 200 of file vector3_ptr.c.
References VECMAT_CEIL, vector3::x, vector3::y, and vector3::z.
Referenced by vec3_ceil().
Clamp vector components between min and max.
| res | Result vector. |
| v | Vector. |
| min | Minimum bounds. |
| max | Maximum 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().
| 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].
| res | Output vector. |
| v | Input vector. |
| min | Lower bound. |
| max | Upper 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().
Compute cross-product of two vectors.
| res | Result vector. |
| a | First vector. |
| b | Second 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().
Divides two vectors component-wise.
| res | Output vector. |
| a | First input vector. |
| b | Second input vector. |
Definition at line 306 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_div().
| void vec3_div_scalar_ptr | ( | vector3 * | res, |
| const vector3 * | v, | ||
| const vm_float_t | s ) |
Component-wise division of vector by scalar.
| res | Result vector. |
| v | Vector. |
| s | Scalar. |
Definition at line 56 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_div_scalar().
Component-wise floor of a vector.
| res | Result vector. |
| v | Vector. |
Definition at line 187 of file vector3_ptr.c.
References VECMAT_FLOOR, vector3::x, vector3::y, and vector3::z.
Referenced by vec3_floor().
Returns the fractional part of each component.
| res | Output vector. |
| v | Input vector. |
Definition at line 373 of file vector3_ptr.c.
References VECMAT_FLOOR, vector3::x, vector3::y, and vector3::z.
Referenced by vec3_fract().
| void vec3_from_vec2_ptr | ( | vector3 * | res, |
| const vector2 * | v, | ||
| const vm_float_t | z ) |
Builds a higher-dimension vector from a vector2.
| res | Output vector. |
| v | Input vector. |
| z | Z 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().
| void vec3_lerp_ptr | ( | vector3 * | res, |
| const vector3 * | a, | ||
| const vector3 * | b, | ||
| const vm_float_t | t ) |
Linear interpolation between two vectors.
| res | Result vector. |
| a | Start vector. |
| b | End vector. |
| t | Interpolation factor. |
Definition at line 265 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_lerp().
| void vec3_limit_length_ptr | ( | vector3 * | res, |
| const vector3 * | v, | ||
| const vm_float_t | max_len ) |
Clamps the vector length to max_len.
| res | Output vector. |
| v | Input vector. |
| max_len | Maximum 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().
Component-wise maximum of two vectors.
| res | Result vector. |
| a | First vector. |
| b | Second vector. |
Definition at line 161 of file vector3_ptr.c.
References VECMAT_FMAX, vector3::x, vector3::y, and vector3::z.
Referenced by vec3_max().
Component-wise minimum of two vectors.
| res | Result vector. |
| a | First vector. |
| b | Second vector. |
Definition at line 147 of file vector3_ptr.c.
References VECMAT_FMIN, vector3::x, vector3::y, and vector3::z.
Referenced by vec3_min().
| 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.
| res | Output vector. |
| current | Current position. |
| target | Target position. |
| max_delta | Maximum 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().
Component-wise multiplication of two vectors.
| res | Result vector. |
| a | First vector. |
| b | Second vector. |
Definition at line 74 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_mul().
| void vec3_mul_scalar_ptr | ( | vector3 * | res, |
| const vector3 * | v, | ||
| const vm_float_t | s ) |
Component-wise multiplication of vector by scalar.
| res | Result vector. |
| v | Vector. |
| s | Scalar. |
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().
Negation of a vector.
| res | Result vector. |
| v | Vector. |
Definition at line 87 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_neg().
Normalize a vector to unit length.
| res | Result vector. |
| v | Vector. |
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().
Builds a tangent and bitangent orthonormal to n.
| n | Unit normal. |
| t | Output tangent. |
| b | Output 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().
Projects a onto b.
| res | Output vector. |
| a | First input vector. |
| b | Second 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().
Compute reflection of the incident vector over normal.
| res | Result vector. |
| incident | Incident vector. |
| normal | Normal vector. |
Definition at line 227 of file vector3_ptr.c.
References vec3_dot(), vector3::x, vector3::y, and vector3::z.
Referenced by vec3_reflect().
| 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.
| res | Result vector. |
| incident | Incident vector. |
| normal | Normal vector. |
| eta | Refraction 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().
Returns the component of a orthogonal to b.
| res | Output vector. |
| a | First input vector. |
| b | Second 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().
| 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.
| res | Output vector. |
| v | Input vector. |
| axis | Rotation axis. |
| angle | Angle 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().
Component-wise round of a vector.
| res | Result vector. |
| v | Vector. |
Definition at line 213 of file vector3_ptr.c.
References VECMAT_ROUND, vector3::x, vector3::y, and vector3::z.
Referenced by vec3_round().
Clamps each component to the range [0, 1].
| res | Output vector. |
| v | Input vector. |
Definition at line 362 of file vector3_ptr.c.
References vec3_clamp_scalar_ptr().
Referenced by vec3_saturate().
| void vec3_scale_ptr | ( | vector3 * | res, |
| const vector3 * | v, | ||
| const vm_float_t | s ) |
Scales the vector by a scalar.
| res | Output vector. |
| v | Input vector. |
| s | Scalar value. |
Definition at line 294 of file vector3_ptr.c.
References vec3_mul_scalar_ptr().
Referenced by vec3_scale().
Component-wise sign of a vector.
| res | Result vector. |
| v | Vector. |
Definition at line 174 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_sign().
Removes the component of v along normal.
| res | Output vector. |
| v | Input vector. |
| normal | Surface normal. |
Definition at line 409 of file vector3_ptr.c.
References vec3_dot(), vector3::x, vector3::y, and vector3::z.
Referenced by vec3_slide().
Component-wise subtraction of two vectors.
| res | Result vector. |
| a | First vector. |
| b | Second vector. |
Definition at line 28 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_sub().
| void vec3_sub_scalar_ptr | ( | vector3 * | res, |
| const vector3 * | v, | ||
| const vm_float_t | s ) |
Subtracts a scalar from each component.
| res | Output vector. |
| v | Input vector. |
| s | Scalar value. |
Definition at line 334 of file vector3_ptr.c.
References vector3::x, vector3::y, and vector3::z.
Referenced by vec3_sub_scalar().
Returns the x and y components as a 2D vector.
| res | Output vector. |
| v | Input vector. |
Definition at line 473 of file vector3_ptr.c.
References vector2::x, vector3::x, vector2::y, and vector3::y.
Referenced by vec3_xy().