diff options
Diffstat (limited to 'mons_math/include/mons_math/vec4.h')
-rw-r--r-- | mons_math/include/mons_math/vec4.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mons_math/include/mons_math/vec4.h b/mons_math/include/mons_math/vec4.h new file mode 100644 index 0000000..24a2d8f --- /dev/null +++ b/mons_math/include/mons_math/vec4.h @@ -0,0 +1,53 @@ +#ifndef MONS_MATH_VEC4_H +#define MONS_MATH_VEC4_H + +typedef struct mons_vec4 { + float x; + float y; + float z; + float w; +} mons_vec4; + +mons_vec4 mons_vec4_add(mons_vec4 a, mons_vec4 b); +void mons_vec4_add_inplace(mons_vec4 *a, mons_vec4 b); + +mons_vec4 mons_vec4_sub(mons_vec4 a, mons_vec4 b); +void mons_vec4_sub_inplace(mons_vec4 *a, mons_vec4 b); + +mons_vec4 mons_vec4_mul_f(mons_vec4 a, float b); +mons_vec4 mons_vec4_mul_i(mons_vec4 a, int b); +float mons_vec4_dot(mons_vec4 a, mons_vec4 b); + +void mons_vec4_mul_f_inplace(mons_vec4 *a, float b); +void mons_vec4_mul_i_inplace(mons_vec4 *a, int b); + +mons_vec4 mons_vec4_div_f(mons_vec4 a, float b); +mons_vec4 mons_vec4_div_i(mons_vec4 a, int b); +void mons_vec4_div_f_inplace(mons_vec4 *a, float b); +void mons_vec4_div_i_inplace(mons_vec4 *a, int b); + +float mons_vec4_len(mons_vec4 a); +float mons_vec4_len_squared(mons_vec4 a); + +struct mons_vec3 mons_vec4_truncate(mons_vec4 a); + +int mons_vec4_equal(mons_vec4 a, mons_vec4 b); +mons_vec4 mons_vec4_negate(mons_vec4 a); +void mons_vec4_negate_inplace(mons_vec4 *a); +mons_vec4 mons_vec4_normalize(mons_vec4 a); +void mons_vec4_normalize_inplace(mons_vec4 *a); + +void mons_vec4_print(mons_vec4 vec); + +#define MONS_VEC4_ZERO (mons_vec4) { 0, 0, 0, 0 } +#define MONS_VEC4_ONE (mons_vec4) { 1, 1, 1, 1 } +#define MONS_VEC4_X (mons_vec4) { 1, 0, 0, 0 } +#define MONS_VEC4_Y (mons_vec4) { 0, 1, 0, 0 } +#define MONS_VEC4_Z (mons_vec4) { 0, 0, 1, 0 } +#define MONS_VEC4_W (mons_vec4) { 0, 0, 0, 1 } +#define MONS_VEC4_NEG_X (mons_vec4) {-1,0,0,0} +#define MONS_VEC4_NEG_Y (mons_vec4) {0,-1,0,0} +#define MONS_VEC4_NEG_Z (mons_vec4) {0,0,-1,0} +#define MONS_VEC4_NEG_W (mons_vec4) {0,0,0,-1} + +#endif |