Vecmat 0.2.3
C math and linear algebra library for 2D/3D graphics, physics, and science.
Loading...
Searching...
No Matches
vector3i_ptr.c File Reference
#include <vecmat.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

void vec3i_add_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Computes the component-wise sum of two vector3i.
void vec3i_sub_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Computes the component-wise difference of two vector3i (a minus b).
void vec3i_mul_scalar_ptr (vector3i *res, const vector3i *v, const vm_int_t s)
 Scales a vector3i by an integer scalar.
void vec3i_div_scalar_ptr (vector3i *res, const vector3i *v, const vm_int_t s)
 Scales a vector3i by the inverse of an integer scalar.
void vec3i_mul_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Computes the component-wise product (Hadamard) of two vector3i.
void vec3i_neg_ptr (vector3i *res, const vector3i *v)
 Negates a vector3i (multiplies by -1).
void vec3i_abs_ptr (vector3i *res, const vector3i *v)
 Computes the absolute value of each component of a vector3i.
void vec3i_normalize_ptr (vector3i *res, const vector3i *v)
 Normalizes a vector3i to approximate unit length.
void vec3i_cross_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Computes the cross-product of two vector3i.
void vec3i_min_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Computes the component-wise minimum of two vector3i.
void vec3i_max_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Computes the component-wise maximum of two vector3i.
void vec3i_sign_ptr (vector3i *res, const vector3i *v)
 Computes the sign of each component of a vector3i (-1, 0, or 1).
void vec3i_lerp_ptr (vector3i *res, const vector3i *a, const vector3i *b, const vm_float_t t)
 Performs linear interpolation between two vector3i.
void vec3i_clamp_ptr (vector3i *res, const vector3i *v, const vector3i *min, const vector3i *max)
 Clamps each component of a vector3i between corresponding min and max values.
static vm_int_t vm_div_floor3 (const vm_int_t a, const vm_int_t b)
static vm_int_t vm_mod_floor3 (const vm_int_t a, const vm_int_t b)
void vec3i_div_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Divides two vectors component-wise.
void vec3i_add_scalar_ptr (vector3i *res, const vector3i *v, const vm_int_t s)
 Adds a scalar to each component.
void vec3i_sub_scalar_ptr (vector3i *res, const vector3i *v, const vm_int_t s)
 Subtracts a scalar from each component.
void vec3i_mod_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Component-wise floor modulo of a by b.
void vec3i_div_floor_ptr (vector3i *res, const vector3i *a, const vector3i *b)
 Component-wise floored division of a by b.
void vec3i_wrap_ptr (vector3i *res, const vector3i *v, const vector3i *period)
 Wraps each component of v into [0, period).
void vec3i_from_vec2i_ptr (vector3i *res, const vector2i *v, const vm_int_t z)
 Builds a vector3i from a vector2i and z.
void vec3i_xy_ptr (vector2i *res, const vector3i *v)
 Returns the x and y components as a 2D vector.
void vec3i_normalize_to_vec3_ptr (vector3 *res, const vector3i *v)
 Converts to a unit-length vector3.

Function Documentation

◆ vec3i_abs_ptr()

void vec3i_abs_ptr ( vector3i * res,
const vector3i * v )

Computes the absolute value of each component of a vector3i.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 105 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_abs().

◆ vec3i_add_ptr()

void vec3i_add_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Computes the component-wise sum of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 15 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_add().

◆ vec3i_add_scalar_ptr()

void vec3i_add_scalar_ptr ( vector3i * res,
const vector3i * v,
const vm_int_t s )

Adds a scalar to each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 267 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_add_scalar().

◆ vec3i_clamp_ptr()

void vec3i_clamp_ptr ( vector3i * res,
const vector3i * v,
const vector3i * min,
const vector3i * max )

Clamps each component of a vector3i between corresponding min and max values.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.
minPointer to the minimum bounds vector.
maxPointer to the maximum bounds vector.

Definition at line 212 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_clamp().

◆ vec3i_cross_ptr()

void vec3i_cross_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Computes the cross-product of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 140 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_cross().

◆ vec3i_div_floor_ptr()

void vec3i_div_floor_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Component-wise floored division of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 309 of file vector3i_ptr.c.

References vm_div_floor3(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_div_floor().

◆ vec3i_div_ptr()

void vec3i_div_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Divides two vectors component-wise.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 253 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_div().

◆ vec3i_div_scalar_ptr()

void vec3i_div_scalar_ptr ( vector3i * res,
const vector3i * v,
const vm_int_t s )

Scales a vector3i by the inverse of an integer scalar.

If the scalar is zero, stores the zero vector.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.
sThe scalar divisor.

Definition at line 59 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_div_scalar().

◆ vec3i_from_vec2i_ptr()

void vec3i_from_vec2i_ptr ( vector3i * res,
const vector2i * v,
const vm_int_t z )

Builds a vector3i from a vector2i and z.

Parameters
resOutput vector.
vInput vector.
zZ component.

Definition at line 337 of file vector3i_ptr.c.

References vector2i::x, vector3i::x, vector2i::y, vector3i::y, and vector3i::z.

Referenced by vec3i_from_vec2i().

◆ vec3i_lerp_ptr()

void vec3i_lerp_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b,
const vm_float_t t )

Performs linear interpolation between two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the start vector.
bPointer to the end vector.
tInterpolation factor (typically between 0.0 and 1.0).

Definition at line 196 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_lerp().

◆ vec3i_max_ptr()

void vec3i_max_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Computes the component-wise maximum of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 168 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_max().

◆ vec3i_min_ptr()

void vec3i_min_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Computes the component-wise minimum of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 154 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_min().

◆ vec3i_mod_ptr()

void vec3i_mod_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Component-wise floor modulo of a by b.

Parameters
resOutput vector.
aFirst input vector.
bSecond input vector.

Definition at line 295 of file vector3i_ptr.c.

References vm_mod_floor3(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_mod().

◆ vec3i_mul_ptr()

void vec3i_mul_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Computes the component-wise product (Hadamard) of two vector3i.

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 79 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_mul().

◆ vec3i_mul_scalar_ptr()

void vec3i_mul_scalar_ptr ( vector3i * res,
const vector3i * v,
const vm_int_t s )

Scales a vector3i by an integer scalar.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.
sThe scalar multiplier.

Definition at line 43 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_mul_scalar().

◆ vec3i_neg_ptr()

void vec3i_neg_ptr ( vector3i * res,
const vector3i * v )

Negates a vector3i (multiplies by -1).

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 92 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_neg().

◆ vec3i_normalize_ptr()

void vec3i_normalize_ptr ( vector3i * res,
const vector3i * v )

Normalizes a vector3i to approximate unit length.

If the vector length is zero, copies the input vector.

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 120 of file vector3i_ptr.c.

References vec3i_length(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_normalize().

◆ vec3i_normalize_to_vec3_ptr()

void vec3i_normalize_to_vec3_ptr ( vector3 * res,
const vector3i * v )

Converts to a unit-length vector3.

Parameters
resOutput vector.
vInput vector.

Definition at line 362 of file vector3i_ptr.c.

References vec3_normalize_ptr(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_normalize_to_vec3().

◆ vec3i_sign_ptr()

void vec3i_sign_ptr ( vector3i * res,
const vector3i * v )

Computes the sign of each component of a vector3i (-1, 0, or 1).

Parameters
resPointer to the vector that will store the result.
vPointer to the input vector.

Definition at line 181 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_sign().

◆ vec3i_sub_ptr()

void vec3i_sub_ptr ( vector3i * res,
const vector3i * a,
const vector3i * b )

Computes the component-wise difference of two vector3i (a minus b).

Parameters
resPointer to the vector that will store the result.
aPointer to the first vector.
bPointer to the second vector.

Definition at line 29 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_sub().

◆ vec3i_sub_scalar_ptr()

void vec3i_sub_scalar_ptr ( vector3i * res,
const vector3i * v,
const vm_int_t s )

Subtracts a scalar from each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 281 of file vector3i_ptr.c.

References vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_sub_scalar().

◆ vec3i_wrap_ptr()

void vec3i_wrap_ptr ( vector3i * res,
const vector3i * v,
const vector3i * period )

Wraps each component of v into [0, period).

Parameters
resOutput vector.
vInput vector.
periodWrap period per component.

Definition at line 323 of file vector3i_ptr.c.

References vm_mod_floor3(), vector3i::x, vector3i::y, and vector3i::z.

Referenced by vec3i_wrap().

◆ vec3i_xy_ptr()

void vec3i_xy_ptr ( vector2i * res,
const vector3i * v )

Returns the x and y components as a 2D vector.

Parameters
resOutput vector.
vInput vector.

Definition at line 350 of file vector3i_ptr.c.

References vector2i::x, vector3i::x, vector2i::y, and vector3i::y.

Referenced by vec3i_xy().

◆ vm_div_floor3()

vm_int_t vm_div_floor3 ( const vm_int_t a,
const vm_int_t b )
static

Definition at line 220 of file vector3i_ptr.c.

Referenced by vec3i_div_floor_ptr().

◆ vm_mod_floor3()

vm_int_t vm_mod_floor3 ( const vm_int_t a,
const vm_int_t b )
static

Definition at line 234 of file vector3i_ptr.c.

Referenced by vec3i_mod_ptr(), and vec3i_wrap_ptr().