vector2i.c file
Functions
- auto vec2i_zero(void) -> vector2i
- Returns a
vector2iwith both components set to 0. - auto vec2i_one(void) -> vector2i
- Returns a
vector2iwith both components set to 1. -
auto vec2i_x_axis(const vm_
int_ t x) -> vector2i - Returns a
vector2ialong the x-axis (y = 0). -
auto vec2i_y_axis(const vm_
int_ t y) -> vector2i - Returns a
vector2ialong the y-axis (x = 0). -
auto vec2i_x_scale(const vm_
int_ t x) -> vector2i - Returns a
vector2irepresenting x-axis scaling (y = 1). -
auto vec2i_y_scale(const vm_
int_ t y) -> vector2i - Returns a
vector2irepresenting y-axis scaling (x = 1). - auto vec2i_add(const vector2i a, const vector2i b) -> vector2i
- Adds two vectors component-wise.
- auto vec2i_sub(const vector2i a, const vector2i b) -> vector2i
- Subtracts the second vector from the first component-wise.
-
auto vec2i_mul_scalar(const vector2i v,
const vm_
int_ t s) -> vector2i - Multiplies a vector by a scalar component-wise.
-
auto vec2i_div_scalar(const vector2i v,
const vm_
int_ t s) -> vector2i - Divides a vector by a scalar component-wise (float division, truncated to int).
- auto vec2i_mul(const vector2i a, const vector2i b) -> vector2i
- Multiplies two vectors component-wise (Hadamard product).
- auto vec2i_neg(const vector2i v) -> vector2i
- Negates the vector (multiplies each component by -1).
- auto vec2i_abs(const vector2i v) -> vector2i
- Returns the absolute values of each component.
- auto vec2i_normalize(const vector2i v) -> vector2i
- Normalizes the vector to approximate unit length (float length, truncated to int).
- auto vec2i_min(const vector2i a, const vector2i b) -> vector2i
- Returns the component-wise minimum of two vectors.
- auto vec2i_max(const vector2i a, const vector2i b) -> vector2i
- Returns the component-wise maximum of two vectors.
- auto vec2i_sign(const vector2i v) -> vector2i
- Returns the sign of each component (+1, -1, or 0).
- auto vec2i_perpendicular(const vector2i v) -> vector2i
- Returns the perpendicular vector (90 degrees counterclockwise).
- auto vec2i_cross(const vector2i a, const vector2i b) -> vector2i
- Computes the 2D cross-product as a vector.
-
auto vec2i_dot(const vector2i a,
const vector2i b) -> vm_
int_ t - Computes the dot product of two vectors.
-
auto vec2i_length(const vector2i v) -> vm_
float_ t - Computes the length (magnitude) of the vector.
-
auto vec2i_distance(const vector2i a,
const vector2i b) -> vm_
float_ t - Computes the Euclidean distance between two vectors (treated as points).
-
auto vec2i_angle(const vector2i a,
const vector2i b) -> vm_
float_ t - Computes the signed angle between two vectors (in radians, range [-PI, PI]) using atan2(cross, dot).
-
auto vec2i_aspect_ratio(const vector2i v) -> vm_
float_ t - Computes the aspect ratio of the vector (x / y).
-
auto vec2i_lerp(const vector2i a,
const vector2i b,
const vm_
float_ t t) -> vector2i - Linearly interpolates from a to b by t.
- auto vec2i_clamp(const vector2i v, const vector2i min, const vector2i max) -> vector2i
- Clamps each component between min and max.
- auto vec2i_div(const vector2i a, const vector2i b) -> vector2i
- Divides two vectors component-wise.
-
auto vec2i_add_scalar(const vector2i v,
const vm_
int_ t s) -> vector2i - Adds a scalar to each component.
-
auto vec2i_sub_scalar(const vector2i v,
const vm_
int_ t s) -> vector2i - Subtracts a scalar from each component.
- auto vec2i_mod(const vector2i a, const vector2i b) -> vector2i
- Component-wise floor modulo of a by b.
- auto vec2i_div_floor(const vector2i a, const vector2i b) -> vector2i
- Component-wise floored division of a by b.
- auto vec2i_wrap(const vector2i v, const vector2i period) -> vector2i
- Wraps each component of v into [0, period).
-
auto vec2i_splat(const vm_
int_ t s) -> vector2i - Returns a vector with every component set to s.
-
auto vec2i_to_vec3i(const vector2i v,
const vm_
int_ t z) -> vector3i - Converts a vector2i to a vector3i using z.
- auto vec2i_normalize_to_vec2(const vector2i v) -> vector2
- Converts to a unit-length vector2.
-
auto vec2i_cross_scalar(const vector2i a,
const vector2i b) -> vm_
int_ t - Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).
-
auto vec2i_length_squared(const vector2i v) -> vm_
int_ t - Returns the squared Euclidean length.
-
auto vec2i_distance_squared(const vector2i a,
const vector2i b) -> vm_
int_ t - Returns the squared Euclidean distance between a and b.
-
auto vec2i_length_manhattan(const vector2i v) -> vm_
int_ t - Returns the Manhattan (L1) length.
-
auto vec2i_length_chebyshev(const vector2i v) -> vm_
int_ t - Returns the Chebyshev (L-inf) length.
-
auto vec2i_min_component(const vector2i v) -> vm_
int_ t - Returns the smallest component.
-
auto vec2i_max_component(const vector2i v) -> vm_
int_ t - Returns the largest component.
-
auto vec2i_sum(const vector2i v) -> vm_
int_ t - Returns the sum of all components.
- auto vec2i_is_zero(const vector2i v) -> bool
- Returns true if every component is zero.
Function documentation
vector2i vec2i_zero(void)
Returns a vector2i with both components set to 0.
| Returns | The zero vector2i. |
|---|
vector2i vec2i_x_axis(const vm_ int_ t x)
Returns a vector2i along the x-axis (y = 0).
| Parameters | |
|---|---|
| x | The x component value. |
| Returns | The x-axis vector2i. |
vector2i vec2i_y_axis(const vm_ int_ t y)
Returns a vector2i along the y-axis (x = 0).
| Parameters | |
|---|---|
| y | The y component value. |
| Returns | The y-axis vector2i. |
vector2i vec2i_x_scale(const vm_ int_ t x)
Returns a vector2i representing x-axis scaling (y = 1).
| Parameters | |
|---|---|
| x | The x scale factor. |
| Returns | The x-scale vector2i. |
vector2i vec2i_y_scale(const vm_ int_ t y)
Returns a vector2i representing y-axis scaling (x = 1).
| Parameters | |
|---|---|
| y | The y scale factor. |
| Returns | The y-scale vector2i. |
vector2i vec2i_mul_scalar(const vector2i v,
const vm_ int_ t s)
Multiplies a vector by a scalar component-wise.
| Parameters | |
|---|---|
| v | The input vector. |
| s | The scalar multiplier. |
| Returns | The scaled vector2i. |
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).
| Parameters | |
|---|---|
| v | The input vector. |
| s | The scalar divisor (sets to zero vector if zero). |
| Returns | The divided vector2i. |
vector2i vec2i_normalize(const vector2i v)
Normalizes the vector to approximate unit length (float length, truncated to int).
| Parameters | |
|---|---|
| v | The input vector. |
| Returns | The normalized vector2i (unchanged if zero length). |
vector2i vec2i_sign(const vector2i v)
Returns the sign of each component (+1, -1, or 0).
| Parameters | |
|---|---|
| v | The input vector. |
| Returns | The sign vector2i. |
vector2i vec2i_perpendicular(const vector2i v)
Returns the perpendicular vector (90 degrees counterclockwise).
| Parameters | |
|---|---|
| v | The input vector. |
| Returns | The perpendicular vector2i. |
vector2i vec2i_cross(const vector2i a, const vector2i b)
Computes the 2D cross-product as a vector.
| Parameters | |
|---|---|
| a | The first vector. |
| b | The second vector. |
| Returns | The cross-product vector2i. |
vm_ float_ t vec2i_length(const vector2i v)
Computes the length (magnitude) of the vector.
| Parameters | |
|---|---|
| v | The input vector. |
| Returns | The length scalar. |
vm_ float_ t vec2i_distance(const vector2i a,
const vector2i b)
Computes the Euclidean distance between two vectors (treated as points).
| Parameters | |
|---|---|
| a | The first point. |
| b | The second point. |
| Returns | The distance scalar. |
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).
| Parameters | |
|---|---|
| a | The first vector. |
| b | The second vector. |
| Returns | The signed angle scalar. |
Returns 0.0f if either vector has zero length.
vm_ float_ t vec2i_aspect_ratio(const vector2i v)
Computes the aspect ratio of the vector (x / y).
| Parameters | |
|---|---|
| v | The input vector. |
| Returns | The aspect ratio scalar. |
Returns 0.0f if y == 0.
vector2i vec2i_lerp(const vector2i a,
const vector2i b,
const vm_ float_ t t)
Linearly interpolates from a to b by t.
| Parameters | |
|---|---|
| a | First input vector. |
| b | Second input vector. |
| t | Interpolation factor. |
| Returns | The resulting vector2i. |
vector2i vec2i_add_scalar(const vector2i v,
const vm_ int_ t s)
Adds a scalar to each component.
| Parameters | |
|---|---|
| v | Input vector. |
| s | Scalar value. |
| Returns | The resulting vector2i. |
vector2i vec2i_sub_scalar(const vector2i v,
const vm_ int_ t s)
Subtracts a scalar from each component.
| Parameters | |
|---|---|
| v | Input vector. |
| s | Scalar value. |
| Returns | The resulting vector2i. |
vector2i vec2i_div_floor(const vector2i a, const vector2i b)
Component-wise floored division of a by b.
| Parameters | |
|---|---|
| a | First input vector. |
| b | Second input vector. |
| Returns | The resulting vector2i. |
vector2i vec2i_wrap(const vector2i v, const vector2i period)
Wraps each component of v into [0, period).
| Parameters | |
|---|---|
| v | Input vector. |
| period | Wrap period per component. |
| Returns | The resulting vector2i. |
vector2i vec2i_splat(const vm_ int_ t s)
Returns a vector with every component set to s.
| Parameters | |
|---|---|
| s | Scalar value. |
| Returns | The resulting vector2i. |
vector2 vec2i_normalize_to_vec2(const vector2i v)
Converts to a unit-length vector2.
| Parameters | |
|---|---|
| v | Input vector. |
| Returns | The resulting 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).
| Parameters | |
|---|---|
| a | First input vector. |
| b | Second input vector. |
| Returns | The resulting scalar. |
vm_ int_ t vec2i_length_squared(const vector2i v)
Returns the squared Euclidean length.
| Parameters | |
|---|---|
| v | Input vector. |
| Returns | The resulting scalar. |
vm_ int_ t vec2i_distance_squared(const vector2i a,
const vector2i b)
Returns the squared Euclidean distance between a and b.
| Parameters | |
|---|---|
| a | First input vector. |
| b | Second input vector. |
| Returns | The resulting scalar. |
vm_ int_ t vec2i_length_manhattan(const vector2i v)
Returns the Manhattan (L1) length.
| Parameters | |
|---|---|
| v | Input vector. |
| Returns | The resulting scalar. |
vm_ int_ t vec2i_length_chebyshev(const vector2i v)
Returns the Chebyshev (L-inf) length.
| Parameters | |
|---|---|
| v | Input vector. |
| Returns | The resulting scalar. |
vm_ int_ t vec2i_min_component(const vector2i v)
Returns the smallest component.
| Parameters | |
|---|---|
| v | Input vector. |
| Returns | The resulting scalar. |
vm_ int_ t vec2i_max_component(const vector2i v)
Returns the largest component.
| Parameters | |
|---|---|
| v | Input vector. |
| Returns | The resulting scalar. |
bool vec2i_is_zero(const vector2i v)
Returns true if every component is zero.
| Parameters | |
|---|---|
| v | Input vector. |
| Returns | True if every component is zero. |