some utils jazz

This commit is contained in:
Gregory Wells
2025-06-15 18:51:30 -04:00
parent 5b05fb287d
commit 954037b4ea
4 changed files with 65 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "stdint.h"
#include "math.h"
typedef struct gnVec3 {
union {
@@ -26,6 +27,16 @@ typedef struct gnVec3 {
#endif
} gnVec3;
static const inline gnVec3 gnVec3Subtract(gnVec3 a, gnVec3 b) { return (gnVec3){ a.x - b.x, a.y - b.y, a.z - b.z }; }
static const inline gnVec3 gnVec3Add(gnVec3 a, gnVec3 b) { return (gnVec3){ a.x + b.x, a.y + b.y, a.z + b.z }; }
static const inline gnVec3 gnVec3Normalize(gnVec3 in) {
float lengthOfVector = sqrt((in.x * in.x) + (in.y * in.y) + (in.z * in.z));
return (gnVec3){in.x / lengthOfVector, in.y / lengthOfVector, in.z / lengthOfVector};
}
static const inline gnVec3 gnVec3Cross(gnVec3 a, gnVec3 b) { return (gnVec3){a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; }
static const inline float gnVec3Dot(gnVec3 a, gnVec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
typedef gnVec3 gnFVec3;
typedef gnVec3 gnFloat3;