4-Component Vector
#include <graphics/vec4.h>
-
struct vec4
Two component vector structure.
-
void vec4_set(struct vec4 *dst, float x, float y, float z, float w)
Sets the individual components of a 4-component vector.
- Parameters:
dst – Destination
x – X component
y – Y component
z – Z component
w – W component
-
void vec4_copy(struct vec4 *dst, const struct vec4 *v)
Copies a vector
- Parameters:
dst – Destination
v – Vector to copy
-
void vec4_from_vec3(struct vec4 *dst, const struct vec3 *v)
Creates a 4-component vector from a 3-component vector
- Parameters:
dst – 4-component vector destination
v – 3-component vector
-
void vec4_add(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
Adds two vectors
- Parameters:
dst – Destination
v1 – Vector 1
v2 – Vector 2
-
void vec4_sub(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
Subtracts two vectors
- Parameters:
dst – Destination
v1 – Vector being subtracted from
v2 – Vector being subtracted
-
void vec4_mul(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
Multiplies two vectors
- Parameters:
dst – Destination
v1 – Vector 1
v2 – Vector 2
-
void vec4_div(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
Divides two vectors
- Parameters:
dst – Destination
v1 – Dividend
v2 – Divisor
-
void vec4_addf(struct vec4 *dst, const struct vec4 *v, float f)
Adds a floating point to all components
- Parameters:
dst – Destination
dst – Vector
f – Floating point
-
void vec4_subf(struct vec4 *dst, const struct vec4 *v, float f)
Subtracts a floating point from all components
- Parameters:
dst – Destination
v – Vector being subtracted from
f – Floating point being subtracted
-
void vec4_mulf(struct vec4 *dst, const struct vec4 *v, float f)
Multiplies a floating point with all components
- Parameters:
dst – Destination
dst – Vector
f – Floating point
-
void vec4_divf(struct vec4 *dst, const struct vec4 *v, float f)
Divides a floating point from all components
- Parameters:
dst – Destination
v – Vector (dividend)
f – Floating point (divisor)
-
void vec4_neg(struct vec4 *dst, const struct vec4 *v)
Negates a vector
- Parameters:
dst – Destination
v – Vector to negate
-
float vec4_dot(const struct vec4 *v1, const struct vec4 *v2)
Performs a dot product between two vectors
- Parameters:
v1 – Vector 1
v2 – Vector 2
- Returns:
Result of the dot product
-
float vec4_len(const struct vec4 *v)
Gets the length of a vector
- Parameters:
v – Vector
- Returns:
The vector’s length
-
float vec4_dist(const struct vec4 *v1, const struct vec4 *v2)
Gets the distance between two vectors
- Parameters:
v1 – Vector 1
v2 – Vector 2
- Returns:
Distance between the two vectors
-
void vec4_minf(struct vec4 *dst, const struct vec4 *v, float val)
Gets the minimum values between a vector’s components and a floating point
- Parameters:
dst – Destination
v – Vector
val – Floating point
-
void vec4_min(struct vec4 *dst, const struct vec4 *v, const struct vec4 *min_v)
Gets the minimum values between two vectors
- Parameters:
dst – Destination
v – Vector 1
min_v – Vector 2
-
void vec4_maxf(struct vec4 *dst, const struct vec4 *v, float val)
Gets the maximum values between a vector’s components and a floating point
- Parameters:
dst – Destination
v – Vector
val – Floating point
-
void vec4_max(struct vec4 *dst, const struct vec4 *v, const struct vec4 *max_v)
Gets the maximum values between two vectors
- Parameters:
dst – Destination
v – Vector 1
max_v – Vector 2
-
void vec4_abs(struct vec4 *dst, const struct vec4 *v)
Gets the absolute values of each component
- Parameters:
dst – Destination
v – Vector
-
void vec4_floor(struct vec4 *dst, const struct vec4 *v)
Gets the floor values of each component
- Parameters:
dst – Destination
v – Vector
-
void vec4_ceil(struct vec4 *dst, const struct vec4 *v)
Gets the ceiling values of each component
- Parameters:
dst – Destination
v – Vector
-
int vec4_close(const struct vec4 *v1, const struct vec4 *v2, float epsilon)
Compares two vectors
- Parameters:
v1 – Vector 1
v2 – Vector 2
epsilon – Maximum precision for comparison
-
void vec4_norm(struct vec4 *dst, const struct vec4 *v)
Normalizes a vector
- Parameters:
dst – Destination
v – Vector to normalize