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

Go to the source code of this file.

Functions

void vec4i_add_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Adds the components of two vector4i and stores the result in res.
void vec4i_sub_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Subtracts the components of the second vector from the first vector4i and stores the result in res.
void vec4i_mul_scalar_ptr (vector4i *res, const vector4i *v, const vm_int_t s)
 Multiplies the components of a vector4i by a scalar and stores the result in res.
void vec4i_div_scalar_ptr (vector4i *res, const vector4i *v, const vm_int_t s)
 Divides the components of a vector4i by a scalar and stores the result in res.
void vec4i_mul_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Multiplies the components of two vector4i and stores the result in res.
void vec4i_neg_ptr (vector4i *res, const vector4i *v)
 Negates the components of a vector4i and stores the result in res.
void vec4i_abs_ptr (vector4i *res, const vector4i *v)
 Computes the absolute value of each component of a vector4i and stores the result in res.
void vec4i_normalize_ptr (vector4i *res, const vector4i *v)
 Normalizes a vector4i by dividing its components by the vector length and stores the result in res.
void vec4i_min_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Takes the component-wise minimum of two vector4i and stores the result in res.
void vec4i_max_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Computes the component-wise maximum of two vector4i and stores the result in res.
void vec4i_sign_ptr (vector4i *res, const vector4i *v)
 Computes the sign (-1, 0, or 1) of each component of a vector4i and stores the result in res.
void vec4i_lerp_ptr (vector4i *res, const vector4i *a, const vector4i *b, const vm_float_t t)
 Linearly interpolates between two vector4i using an interpolation factor t (clamped to [0,1]) and stores the result in res.
void vec4i_clamp_ptr (vector4i *res, const vector4i *v, const vector4i *min, const vector4i *max)
 Clamps the components of a vector4i to the range [min, max] and stores the result in res.
void vec4i_to_vec3i_ptr (vector3i *res, const vector4i *v)
 Copies the x, y, z components of a vector4i and stores the result in a vector3i.
static vm_int_t vm_div_floor4 (const vm_int_t a, const vm_int_t b)
static vm_int_t vm_mod_floor4 (const vm_int_t a, const vm_int_t b)
void vec4i_div_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Divides two vectors component-wise.
void vec4i_add_scalar_ptr (vector4i *res, const vector4i *v, const vm_int_t s)
 Adds a scalar to each component.
void vec4i_sub_scalar_ptr (vector4i *res, const vector4i *v, const vm_int_t s)
 Subtracts a scalar from each component.
void vec4i_mod_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Component-wise floor modulo of a by b.
void vec4i_div_floor_ptr (vector4i *res, const vector4i *a, const vector4i *b)
 Component-wise floored division of a by b.
void vec4i_wrap_ptr (vector4i *res, const vector4i *v, const vector4i *period)
 Wraps each component of v into [0, period).

Function Documentation

◆ vec4i_abs_ptr()

void vec4i_abs_ptr ( vector4i * res,
const vector4i * v )

Computes the absolute value of each component of a vector4i and stores the result in res.

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 116 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_abs().

◆ vec4i_add_ptr()

void vec4i_add_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Adds the components of two vector4i and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 15 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_add().

◆ vec4i_add_scalar_ptr()

void vec4i_add_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Adds a scalar to each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 293 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_add_scalar().

◆ vec4i_clamp_ptr()

void vec4i_clamp_ptr ( vector4i * res,
const vector4i * v,
const vector4i * min,
const vector4i * max )

Clamps the components of a vector4i to the range [min, max] and stores the result in res.

Parameters
resPointer to result vector
vPointer to input vector
minPointer to minimum bounds vector
maxPointer to maximum bounds vector

Definition at line 222 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_clamp().

◆ vec4i_div_floor_ptr()

void vec4i_div_floor_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Component-wise floored division of a by b.

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

Definition at line 338 of file vector4i_ptr.c.

References vm_div_floor4(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_div_floor().

◆ vec4i_div_ptr()

void vec4i_div_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Divides two vectors component-wise.

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

Definition at line 278 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_div().

◆ vec4i_div_scalar_ptr()

void vec4i_div_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Divides the components of a vector4i by a scalar and stores the result in res.

If the scalar is zero, sets all components of res to zero.

Parameters
resPointer to result vector
vPointer to input vector
sScalar divisor

Definition at line 65 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_div_scalar().

◆ vec4i_lerp_ptr()

void vec4i_lerp_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b,
const vm_float_t t )

Linearly interpolates between two vector4i using an interpolation factor t (clamped to [0,1]) and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector
tInterpolation factor

Definition at line 203 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_lerp().

◆ vec4i_max_ptr()

void vec4i_max_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Computes the component-wise maximum of two vector4i and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 171 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_max().

◆ vec4i_min_ptr()

void vec4i_min_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Takes the component-wise minimum of two vector4i and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 155 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_min().

◆ vec4i_mod_ptr()

void vec4i_mod_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Component-wise floor modulo of a by b.

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

Definition at line 323 of file vector4i_ptr.c.

References vm_mod_floor4(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_mod().

◆ vec4i_mul_ptr()

void vec4i_mul_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Multiplies the components of two vector4i and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 87 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_mul().

◆ vec4i_mul_scalar_ptr()

void vec4i_mul_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Multiplies the components of a vector4i by a scalar and stores the result in res.

Parameters
resPointer to result vector
vPointer to input vector
sScalar value

Definition at line 47 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_mul_scalar().

◆ vec4i_neg_ptr()

void vec4i_neg_ptr ( vector4i * res,
const vector4i * v )

Negates the components of a vector4i and stores the result in res.

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 101 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_neg().

◆ vec4i_normalize_ptr()

void vec4i_normalize_ptr ( vector4i * res,
const vector4i * v )

Normalizes a vector4i by dividing its components by the vector length and stores the result in res.

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

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 133 of file vector4i_ptr.c.

References vec4i_length(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_normalize().

◆ vec4i_sign_ptr()

void vec4i_sign_ptr ( vector4i * res,
const vector4i * v )

Computes the sign (-1, 0, or 1) of each component of a vector4i and stores the result in res.

Parameters
resPointer to result vector
vPointer to input vector

Definition at line 186 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_sign().

◆ vec4i_sub_ptr()

void vec4i_sub_ptr ( vector4i * res,
const vector4i * a,
const vector4i * b )

Subtracts the components of the second vector from the first vector4i and stores the result in res.

Parameters
resPointer to result vector
aPointer to first vector
bPointer to second vector

Definition at line 31 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_sub().

◆ vec4i_sub_scalar_ptr()

void vec4i_sub_scalar_ptr ( vector4i * res,
const vector4i * v,
const vm_int_t s )

Subtracts a scalar from each component.

Parameters
resOutput vector.
vInput vector.
sScalar value.

Definition at line 308 of file vector4i_ptr.c.

References vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_sub_scalar().

◆ vec4i_to_vec3i_ptr()

void vec4i_to_vec3i_ptr ( vector3i * res,
const vector4i * v )

Copies the x, y, z components of a vector4i and stores the result in a vector3i.

Parameters
resPointer to result vector3i
vPointer to source vector4i

Definition at line 237 of file vector4i_ptr.c.

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

Referenced by vec4i_to_vec3i().

◆ vec4i_wrap_ptr()

void vec4i_wrap_ptr ( vector4i * res,
const vector4i * v,
const vector4i * period )

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

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

Definition at line 353 of file vector4i_ptr.c.

References vm_mod_floor4(), vector4i::w, vector4i::x, vector4i::y, and vector4i::z.

Referenced by vec4i_wrap().

◆ vm_div_floor4()

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

Definition at line 245 of file vector4i_ptr.c.

Referenced by vec4i_div_floor_ptr().

◆ vm_mod_floor4()

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

Definition at line 259 of file vector4i_ptr.c.

Referenced by vec4i_mod_ptr(), and vec4i_wrap_ptr().