|
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 | |
| 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 (const vm_float_t x) |
| Returns a vector4 along the x-axis. | |
| vector4 | vec4_y_axis (const vm_float_t y) |
| Returns a vector4 along the y-axis. | |
| vector4 | vec4_z_axis (const vm_float_t z) |
| Returns a vector4 along the z-axis. | |
| vector4 | vec4_w_axis (const vm_float_t w) |
| Returns a vector4 along the w-axis. | |
| vector4 | vec4_x_scale (const vm_float_t x) |
| Returns avector4 for scaling along the x-axis. | |
| vector4 | vec4_y_scale (const vm_float_t y) |
| Returns a vector4 for scaling along the y-axis. | |
| vector4 | vec4_z_scale (const vm_float_t z) |
| Returns a vector4for scaling along the z-axis. | |
| vector4 | vec4_w_scale (const vm_float_t w) |
| Returns a vector4 for scaling along the w-axis. | |
| vector4 | vec4_add (const vector4 a, const vector4 b) |
| Component-wise addition of two vectors. | |
| vector4 | vec4_sub (const vector4 a, const vector4 b) |
| Component-wise subtraction of two vectors. | |
| vector4 | vec4_mul_scalar (const vector4 v, const vm_float_t s) |
| Component-wise multiplication of vector by scalar. | |
| vector4 | vec4_div_scalar (const vector4 v, const vm_float_t s) |
| Component-wise division of vector by scalar. | |
| vector4 | vec4_mul (const vector4 a, const vector4 b) |
| Component-wise multiplication of two vectors. | |
| vector4 | vec4_neg (const vector4 v) |
| Negation of a vector. | |
| vector4 | vec4_abs (const vector4 v) |
| Computes the absolute value per component of a vector4. | |
| vector4 | vec4_normalize (const vector4 v) |
| Normalizes a vector4 to unit length. | |
| vector4 | vec4_min (const vector4 a, const vector4 b) |
| Computes the component-wise minimum of two vector4. | |
| vector4 | vec4_max (const vector4 a, const vector4 b) |
| Computes the component-wise maximum of two vector4. | |
| vector4 | vec4_sign (const vector4 v) |
| Computes the sign per component of a vector4 (-1, 0, or 1). | |
| vector4 | vec4_floor (const vector4 v) |
| Applies the floor per component to a vector4. | |
| vector4 | vec4_ceil (const vector4 v) |
| Applies ceil per component to a vector4. | |
| vector4 | vec4_round (const vector4 v) |
| Applies round per component to a vector4. | |
| vector4 | vec4_lerp (const vector4 a, const vector4 b, const vm_float_t t) |
| Linearly interpolates between two vector4. | |
| vector4 | vec4_clamp (const vector4 v, const vector4 min, const vector4 max) |
| Clamps a vector4 between min and max per component. | |
| vector4 | vec4_homogenize (const vector4 v) |
| Homogenizes a vector4 (divides x, y, z by w). | |
| vm_float_t | vec4_dot (const vector4 a, const vector4 b) |
| Computes the dot product of two vector4. | |
| vm_float_t | vec4_length (const vector4 v) |
| Computes the length (magnitude) of a vector4. | |
| vm_float_t | vec4_distance (const vector4 a, const vector4 b) |
| Computes the Euclidean distance between two vector4. | |
| vector3 | vec4_to_vec3 (const vector4 v) |
| Converts a vector4 to a vector3 (discards the w component). | |
| vector4 | vec4_div (const vector4 a, const vector4 b) |
| Divides two vectors component-wise. | |
| vector4 | vec4_add_scalar (const vector4 v, const vm_float_t s) |
| Adds a scalar to each component. | |
| vector4 | vec4_sub_scalar (const vector4 v, const vm_float_t s) |
| Subtracts a scalar from each component. | |
| 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]. | |
| vector4 | vec4_saturate (const vector4 v) |
| Clamps each component to the range [0, 1]. | |
| vector4 | vec4_fract (const vector4 v) |
| Returns the fractional part of each component. | |
| vector4 | vec4_project (const vector4 a, const vector4 b) |
| Projects a onto b. | |
| vector4 | vec4_reject (const vector4 a, const vector4 b) |
| Returns the component of a orthogonal to b. | |
| vector4 | vec4_slide (const vector4 v, const vector4 normal) |
| Removes the component of v along normal. | |
| vector4 | vec4_splat (const vm_float_t s) |
| Returns a vector with every component set to s. | |
| vm_float_t | vec4_length_squared (const vector4 v) |
| Returns the squared Euclidean length. | |
| vm_float_t | vec4_distance_squared (const vector4 a, const vector4 b) |
| Returns the squared Euclidean distance between a and b. | |
| bool | vec4_is_zero (const vector4 v) |
| Returns true if every component is zero. | |
| bool | vec4_is_normalized (const vector4 v) |
| Returns true if the vector has unit length. | |
| 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. | |
Computes the absolute value per component of a vector4.
See vec4_abs_ptr for the out-parameter version.
| v | The vector. |
Definition at line 218 of file vector4.c.
References vec4_abs_ptr().
Component-wise addition of two vectors.
See vec4_add_ptr for the out-parameter version.
| a | First vector. |
| b | Second vector. |
Definition at line 124 of file vector4.c.
References vec4_add_ptr().
| vector4 vec4_add_scalar | ( | const vector4 | v, |
| const vm_float_t | s ) |
Adds a scalar to each component.
See vec4_add_scalar_ptr instead.
| v | Input vector. |
| s | Scalar value. |
Definition at line 455 of file vector4.c.
References vec4_add_scalar_ptr().
Applies ceil per component to a vector4.
See vec4_ceil_ptr for the out-parameter version.
| v | The vector. |
Definition at line 310 of file vector4.c.
References vec4_ceil_ptr().
Clamps a vector4 between min and max per component.
See vec4_clamp_ptr for the out-parameter version.
| v | The vector. |
| min | Minimum bounds. |
| max | Maximum bounds. |
Definition at line 359 of file vector4.c.
References vec4_clamp_ptr().
| 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.
| v | Input vector. |
| min | Lower bound. |
| max | Upper bound. |
Definition at line 488 of file vector4.c.
References vec4_clamp_scalar_ptr().
| vm_float_t vec4_distance | ( | const vector4 | a, |
| const vector4 | b ) |
Computes the Euclidean distance between two vector4.
| a | First vector. |
| b | Second vector. |
Definition at line 411 of file vector4.c.
References vec4_length(), and vec4_sub().
| vm_float_t vec4_distance_squared | ( | const vector4 | a, |
| const vector4 | b ) |
Returns the squared Euclidean distance between a and b.
| a | First input vector. |
| b | Second input vector. |
Definition at line 604 of file vector4.c.
References vec4_length_squared(), and vec4_sub().
Divides two vectors component-wise.
See vec4_div_ptr instead.
| a | First input vector. |
| b | Second input vector. |
Definition at line 439 of file vector4.c.
References vec4_div_ptr().
| 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.
| v | The vector. |
| s | The scalar (non-zero). |
Definition at line 172 of file vector4.c.
References vec4_div_scalar_ptr().
| vm_float_t vec4_dot | ( | const vector4 | a, |
| const vector4 | b ) |
Computes the dot product of two vector4.
| a | First vector. |
| b | Second vector. |
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().
Applies the floor per component to a vector4.
See vec4_floor_ptr for the out-parameter version.
| v | The vector. |
Definition at line 295 of file vector4.c.
References vec4_floor_ptr().
Returns the fractional part of each component.
See vec4_fract_ptr instead.
| v | Input vector. |
Definition at line 518 of file vector4.c.
References vec4_fract_ptr().
Homogenizes a vector4 (divides x, y, z by w).
See vec4_homogenize_ptr for the out-parameter version.
| v | The homogeneous vector (w != 0.0f). |
Definition at line 374 of file vector4.c.
References vec4_homogenize_ptr().
| bool vec4_is_normalized | ( | const vector4 | v | ) |
Returns true if the vector has unit length.
| v | Input vector. |
Definition at line 626 of file vector4.c.
References vec4_length_squared(), VECMAT_EPSILON, and VECMAT_FABS.
| bool vec4_is_zero | ( | const vector4 | v | ) |
Returns true if every component is zero.
| v | Input vector. |
Definition at line 615 of file vector4.c.
References vec4_length_squared(), and VECMAT_EPSILON.
| vm_float_t vec4_length | ( | const vector4 | v | ) |
Computes the length (magnitude) of a vector4.
| v | The vector. |
Definition at line 399 of file vector4.c.
References vec4_dot(), and VECMAT_SQRT.
Referenced by vec4_distance(), and vec4_normalize_ptr_scalar().
| vm_float_t vec4_length_squared | ( | const vector4 | v | ) |
Returns the squared Euclidean length.
| v | Input vector. |
Definition at line 592 of file vector4.c.
References vec4_dot().
Referenced by vec4_distance_squared(), vec4_is_normalized(), and vec4_is_zero().
| 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.
| a | Start vector. |
| b | End vector. |
| t | Interpolation factor [0, 1]. |
Definition at line 342 of file vector4.c.
References vec4_lerp_ptr().
Computes the component-wise maximum of two vector4.
See vec4_max_ptr for the out-parameter version.
| a | First vector. |
| b | Second vector. |
Definition at line 265 of file vector4.c.
References vec4_max_ptr().
Computes the component-wise minimum of two vector4.
See vec4_min_ptr for the out-parameter version.
| a | First vector. |
| b | Second vector. |
Definition at line 249 of file vector4.c.
References vec4_min_ptr().
Component-wise multiplication of two vectors.
See vec4_mul_ptr for the out-parameter version.
| a | First vector. |
| b | Second vector. |
Definition at line 188 of file vector4.c.
References vec4_mul_ptr().
| 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.
| v | The vector. |
| s | The scalar. |
Definition at line 156 of file vector4.c.
References vec4_mul_scalar_ptr().
| 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.
| a | First input vector. |
| b | Second input vector. |
| eps | Distance tolerance. |
Definition at line 639 of file vector4.c.
References VECMAT_FABS, vector4::w, vector4::x, vector4::y, and vector4::z.
Negation of a vector.
See vec4_neg_ptr for the out-parameter version.
| v | The vector. |
Definition at line 203 of file vector4.c.
References vec4_neg_ptr().
Normalizes a vector4 to unit length.
See vec4_normalize_ptr for the out-parameter version.
| v | The vector (non-zero). |
Definition at line 233 of file vector4.c.
References vec4_normalize_ptr().
| vector4 vec4_one | ( | void | ) |
Projects a onto b.
See vec4_project_ptr instead.
| a | First input vector. |
| b | Second input vector. |
Definition at line 534 of file vector4.c.
References vec4_project_ptr().
Returns the component of a orthogonal to b.
See vec4_reject_ptr instead.
| a | First input vector. |
| b | Second input vector. |
Definition at line 550 of file vector4.c.
References vec4_reject_ptr().
Applies round per component to a vector4.
See vec4_round_ptr for the out-parameter version.
| v | The vector. |
Definition at line 325 of file vector4.c.
References vec4_round_ptr().
Clamps each component to the range [0, 1].
See vec4_saturate_ptr instead.
| v | Input vector. |
Definition at line 503 of file vector4.c.
References vec4_saturate_ptr().
Computes the sign per component of a vector4 (-1, 0, or 1).
See vec4_sign_ptr for the out-parameter version.
| v | The vector. |
Definition at line 280 of file vector4.c.
References vec4_sign_ptr().
Removes the component of v along normal.
See vec4_slide_ptr instead.
| v | Input vector. |
| normal | Surface normal. |
Definition at line 566 of file vector4.c.
References vec4_slide_ptr().
| vector4 vec4_splat | ( | const vm_float_t | s | ) |
Component-wise subtraction of two vectors.
See vec4_sub_ptr for the out-parameter version.
| a | First vector. |
| b | Second vector. |
Definition at line 140 of file vector4.c.
References vec4_sub_ptr().
Referenced by vec4_distance(), and vec4_distance_squared().
| vector4 vec4_sub_scalar | ( | const vector4 | v, |
| const vm_float_t | s ) |
Subtracts a scalar from each component.
See vec4_sub_scalar_ptr instead.
| v | Input vector. |
| s | Scalar value. |
Definition at line 471 of file vector4.c.
References vec4_sub_scalar_ptr().
| vector4 vec4_w_axis | ( | const vm_float_t | w | ) |
| vector4 vec4_w_scale | ( | const vm_float_t | w | ) |
| vector4 vec4_x_axis | ( | const vm_float_t | x | ) |
| vector4 vec4_x_scale | ( | const vm_float_t | x | ) |
| vector4 vec4_y_axis | ( | const vm_float_t | y | ) |
| vector4 vec4_y_scale | ( | const vm_float_t | y | ) |
| vector4 vec4_z_axis | ( | const vm_float_t | z | ) |
| vector4 vec4_z_scale | ( | const vm_float_t | z | ) |