|
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 | |
| 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 (const vm_int_t x) |
| Returns a vector2i along the x-axis (y = 0). | |
| vector2i | vec2i_y_axis (const vm_int_t y) |
| Returns a vector2i along the y-axis (x = 0). | |
| vector2i | vec2i_x_scale (const vm_int_t x) |
| Returns a vector2i representing x-axis scaling (y = 1). | |
| vector2i | vec2i_y_scale (const vm_int_t y) |
| Returns a vector2i representing y-axis scaling (x = 1). | |
| vector2i | vec2i_add (const vector2i a, const vector2i b) |
| Adds two vectors component-wise. | |
| vector2i | vec2i_sub (const vector2i a, const vector2i b) |
| Subtracts the second vector from the first component-wise. | |
| vector2i | vec2i_mul_scalar (const vector2i v, const vm_int_t s) |
| Multiplies a vector by a scalar component-wise. | |
| 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). | |
| vector2i | vec2i_mul (const vector2i a, const vector2i b) |
| Multiplies two vectors component-wise (Hadamard product). | |
| vector2i | vec2i_neg (const vector2i v) |
| Negates the vector (multiplies each component by -1). | |
| vector2i | vec2i_abs (const vector2i v) |
| Returns the absolute values of each component. | |
| vector2i | vec2i_normalize (const vector2i v) |
| Normalizes the vector to approximate unit length (float length, truncated to int). | |
| vector2i | vec2i_min (const vector2i a, const vector2i b) |
| Returns the component-wise minimum of two vectors. | |
| vector2i | vec2i_max (const vector2i a, const vector2i b) |
| Returns the component-wise maximum of two vectors. | |
| vector2i | vec2i_sign (const vector2i v) |
| Returns the sign of each component (+1, -1, or 0). | |
| vector2i | vec2i_perpendicular (const vector2i v) |
| Returns the perpendicular vector (90 degrees counterclockwise). | |
| vector2i | vec2i_cross (const vector2i a, const vector2i b) |
| Computes the 2D cross-product as a vector. | |
| vm_int_t | vec2i_dot (const vector2i a, const vector2i b) |
| Computes the dot product of two vectors. | |
| vm_float_t | vec2i_length (const vector2i v) |
| Computes the length (magnitude) of the vector. | |
| vm_float_t | vec2i_distance (const vector2i a, const vector2i b) |
| Computes the Euclidean distance between two vectors (treated as points). | |
| 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). | |
| vm_float_t | vec2i_aspect_ratio (const vector2i v) |
| Computes the aspect ratio of the vector (x / y). | |
| vector2i | vec2i_lerp (const vector2i a, const vector2i b, const vm_float_t t) |
| Linearly interpolates from a to b by t. | |
| vector2i | vec2i_clamp (const vector2i v, const vector2i min, const vector2i max) |
| Clamps each component between min and max. | |
| vector2i | vec2i_div (const vector2i a, const vector2i b) |
| Divides two vectors component-wise. | |
| vector2i | vec2i_add_scalar (const vector2i v, const vm_int_t s) |
| Adds a scalar to each component. | |
| vector2i | vec2i_sub_scalar (const vector2i v, const vm_int_t s) |
| Subtracts a scalar from each component. | |
| vector2i | vec2i_mod (const vector2i a, const vector2i b) |
| Component-wise floor modulo of a by b. | |
| vector2i | vec2i_div_floor (const vector2i a, const vector2i b) |
| Component-wise floored division of a by b. | |
| vector2i | vec2i_wrap (const vector2i v, const vector2i period) |
| Wraps each component of v into [0, period). | |
| vector2i | vec2i_splat (const vm_int_t s) |
| Returns a vector with every component set to s. | |
| vector3i | vec2i_to_vec3i (const vector2i v, const vm_int_t z) |
| Converts a vector2i to a vector3i using z. | |
| vector2 | vec2i_normalize_to_vec2 (const vector2i v) |
| Converts to a unit-length vector2. | |
| 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). | |
| vm_int_t | vec2i_length_squared (const vector2i v) |
| Returns the squared Euclidean length. | |
| vm_int_t | vec2i_distance_squared (const vector2i a, const vector2i b) |
| Returns the squared Euclidean distance between a and b. | |
| vm_int_t | vec2i_length_manhattan (const vector2i v) |
| Returns the Manhattan (L1) length. | |
| vm_int_t | vec2i_length_chebyshev (const vector2i v) |
| Returns the Chebyshev (L-inf) length. | |
| vm_int_t | vec2i_min_component (const vector2i v) |
| Returns the smallest component. | |
| vm_int_t | vec2i_max_component (const vector2i v) |
| Returns the largest component. | |
| vm_int_t | vec2i_sum (const vector2i v) |
| Returns the sum of all components. | |
| bool | vec2i_is_zero (const vector2i v) |
| Returns true if every component is zero. | |
Returns the absolute values of each component.
See vec2i_abs_ptr instead.
| v | The input vector. |
Definition at line 175 of file vector2i.c.
References vec2i_abs_ptr().
Adds two vectors component-wise.
See vec2i_add_ptr instead.
| a | The first vector. |
| b | The second vector. |
Definition at line 80 of file vector2i.c.
References vec2i_add_ptr().
Adds a scalar to each component.
See vec2i_add_scalar_ptr instead.
| v | Input vector. |
| s | Scalar value. |
Definition at line 405 of file vector2i.c.
References vec2i_add_scalar_ptr().
| 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.
| a | The first vector. |
| b | The second vector. |
Definition at line 322 of file vector2i.c.
References vec2i_dot(), vec2i_length(), VECMAT_ATAN2, vector2i::x, and vector2i::y.
| vm_float_t vec2i_aspect_ratio | ( | const vector2i | v | ) |
Computes the aspect ratio of the vector (x / y).
Returns 0.0f if y == 0.
| v | The input vector. |
Definition at line 340 of file vector2i.c.
References vector2i::x, and vector2i::y.
Clamps each component between min and max.
See vec2i_clamp_ptr instead.
| v | Input vector. |
| min | Lower bound. |
| max | Upper bound. |
Definition at line 373 of file vector2i.c.
References vec2i_clamp_ptr().
Computes the 2D cross-product as a vector.
See vec2i_cross_ptr instead.
| a | The first vector. |
| b | The second vector. |
Definition at line 268 of file vector2i.c.
References vec2i_cross_ptr().
Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).
| a | First input vector. |
| b | Second input vector. |
Definition at line 527 of file vector2i.c.
References vector2i::x, and vector2i::y.
| vm_float_t vec2i_distance | ( | const vector2i | a, |
| const vector2i | b ) |
Computes the Euclidean distance between two vectors (treated as points).
| a | The first point. |
| b | The second point. |
Definition at line 305 of file vector2i.c.
References VECMAT_SQRT, vector2i::x, and vector2i::y.
Returns the squared Euclidean distance between a and b.
| a | First input vector. |
| b | Second input vector. |
Definition at line 550 of file vector2i.c.
References vector2i::x, and vector2i::y.
Divides two vectors component-wise.
See vec2i_div_ptr instead.
| a | First input vector. |
| b | Second input vector. |
Definition at line 389 of file vector2i.c.
References vec2i_div_ptr().
Component-wise floored division of a by b.
See vec2i_div_floor_ptr instead.
| a | First input vector. |
| b | Second input vector. |
Definition at line 453 of file vector2i.c.
References vec2i_div_floor_ptr().
Divides a vector by a scalar component-wise (float division, truncated to int).
See vec2i_div_scalar_ptr instead.
| v | The input vector. |
| s | The scalar divisor (sets to zero vector if zero). |
Definition at line 129 of file vector2i.c.
References vec2i_div_scalar_ptr().
Computes the dot product of two vectors.
| a | The first vector. |
| b | The second vector. |
Definition at line 282 of file vector2i.c.
References vector2i::x, and vector2i::y.
Referenced by vec2i_angle(), vec2i_length(), and vec2i_length_squared().
| bool vec2i_is_zero | ( | const vector2i | v | ) |
Returns true if every component is zero.
| v | Input vector. |
Definition at line 622 of file vector2i.c.
References vector2i::x, and vector2i::y.
| vm_float_t vec2i_length | ( | const vector2i | v | ) |
Computes the length (magnitude) of the vector.
| v | The input vector. |
Definition at line 293 of file vector2i.c.
References vec2i_dot(), and VECMAT_SQRT.
Referenced by vec2i_angle(), and vec2i_normalize_ptr().
Returns the Chebyshev (L-inf) length.
| v | Input vector. |
Definition at line 576 of file vector2i.c.
References vector2i::x, and vector2i::y.
Returns the Manhattan (L1) length.
| v | Input vector. |
Definition at line 563 of file vector2i.c.
References vector2i::x, and vector2i::y.
Returns the squared Euclidean length.
| v | Input vector. |
Definition at line 538 of file vector2i.c.
References vec2i_dot().
| 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.
| a | First input vector. |
| b | Second input vector. |
| t | Interpolation factor. |
Definition at line 356 of file vector2i.c.
References vec2i_lerp_ptr().
Returns the component-wise maximum of two vectors.
See vec2i_max_ptr instead.
| a | The first vector. |
| b | The second vector. |
Definition at line 222 of file vector2i.c.
References vec2i_max_ptr().
Returns the largest component.
| v | Input vector. |
Definition at line 600 of file vector2i.c.
References vector2i::x, and vector2i::y.
Returns the component-wise minimum of two vectors.
See vec2i_min_ptr instead.
| a | The first vector. |
| b | The second vector. |
Definition at line 206 of file vector2i.c.
References vec2i_min_ptr().
Returns the smallest component.
| v | Input vector. |
Definition at line 589 of file vector2i.c.
References vector2i::x, and vector2i::y.
Component-wise floor modulo of a by b.
See vec2i_mod_ptr instead.
| a | First input vector. |
| b | Second input vector. |
Definition at line 437 of file vector2i.c.
References vec2i_mod_ptr().
Multiplies two vectors component-wise (Hadamard product).
See vec2i_mul_ptr instead.
| a | The first vector. |
| b | The second vector. |
Definition at line 145 of file vector2i.c.
References vec2i_mul_ptr().
Multiplies a vector by a scalar component-wise.
See vec2i_mul_scalar_ptr instead.
| v | The input vector. |
| s | The scalar multiplier. |
Definition at line 112 of file vector2i.c.
References vec2i_mul_scalar_ptr().
Negates the vector (multiplies each component by -1).
See vec2i_neg_ptr instead.
| v | The input vector. |
Definition at line 160 of file vector2i.c.
References vec2i_neg_ptr().
Normalizes the vector to approximate unit length (float length, truncated to int).
See vec2i_normalize_ptr instead.
| v | The input vector. |
Definition at line 190 of file vector2i.c.
References vec2i_normalize_ptr().
Converts to a unit-length vector2.
See vec2i_normalize_to_vec2_ptr instead.
| v | Input vector. |
Definition at line 513 of file vector2i.c.
References vec2i_normalize_to_vec2_ptr().
| vector2i vec2i_one | ( | void | ) |
Returns a vector2i with both components set to 1.
Definition at line 22 of file vector2i.c.
Returns the perpendicular vector (90 degrees counterclockwise).
See vec2i_perpendicular_ptr instead.
| v | The input vector. |
Definition at line 252 of file vector2i.c.
References vec2i_perpendicular_ptr().
Returns the sign of each component (+1, -1, or 0).
See vec2i_sign_ptr instead.
| v | The input vector. |
Definition at line 237 of file vector2i.c.
References vec2i_sign_ptr().
Returns a vector with every component set to s.
See vec2i_splat_ptr instead.
| s | Scalar value. |
Definition at line 484 of file vector2i.c.
Subtracts the second vector from the first component-wise.
See vec2i_sub_ptr instead.
| a | The first vector. |
| b | The second vector. |
Definition at line 96 of file vector2i.c.
References vec2i_sub_ptr().
Subtracts a scalar from each component.
See vec2i_sub_scalar_ptr instead.
| v | Input vector. |
| s | Scalar value. |
Definition at line 421 of file vector2i.c.
References vec2i_sub_scalar_ptr().
Returns the sum of all components.
| v | Input vector. |
Definition at line 611 of file vector2i.c.
References vector2i::x, and vector2i::y.
Converts a vector2i to a vector3i using z.
See vec2i_to_vec3i_ptr instead.
| v | Input vector. |
| z | Z component. |
Definition at line 498 of file vector2i.c.
References vec2i_to_vec3i_ptr().
Wraps each component of v into [0, period).
See vec2i_wrap_ptr instead.
| v | Input vector. |
| period | Wrap period per component. |
Definition at line 469 of file vector2i.c.
References vec2i_wrap_ptr().
Returns a vector2i along the x-axis (y = 0).
| x | The x component value. |
Definition at line 33 of file vector2i.c.
Returns a vector2i representing x-axis scaling (y = 1).
| x | The x scale factor. |
Definition at line 55 of file vector2i.c.
Returns a vector2i along the y-axis (x = 0).
| y | The y component value. |
Definition at line 44 of file vector2i.c.
Returns a vector2i representing y-axis scaling (x = 1).
| y | The y scale factor. |
Definition at line 66 of file vector2i.c.
| vector2i vec2i_zero | ( | void | ) |
Returns a vector2i with both components set to 0.
Definition at line 12 of file vector2i.c.