diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-07-25 15:58:46 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-07-25 15:58:46 +0300 |
| commit | 884bac2a767bf5bf77413c055a6484a7ea87700c (patch) | |
| tree | 56121d3f5930d5cde2e292c99c9fb81590a2d7a7 /src/vector.c | |
| parent | dc980b5ae0ca61eae3386a9ee6cbfe835a598b95 (diff) | |
| download | a3catragmx-884bac2a767bf5bf77413c055a6484a7ea87700c.tar.gz a3catragmx-884bac2a767bf5bf77413c055a6484a7ea87700c.tar.bz2 a3catragmx-884bac2a767bf5bf77413c055a6484a7ea87700c.zip | |
Diffstat (limited to 'src/vector.c')
| -rw-r--r-- | src/vector.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vector.c b/src/vector.c index 7da6cc5..7274cbb 100644 --- a/src/vector.c +++ b/src/vector.c @@ -1 +1,27 @@ +#include <math.h> + #include "vector.h" + +static inline double vec3_magnitude(Vec3 v) { + return hypot(v.x, hypot(v.y, v.z)); +} + +static inline Vec3 vec3_diff(Vec3 a, Vec3 b) { + return (Vec3){.x = a.x - b.x, + .y = a.y - b.y, + .z = a.z - b.z}; +} + +static inline Vec3 vec3_normalize(Vec3 v) { + double len = sqrt(v.x * v.x + + v.y * v.y + + v.z * v.z); + if (len != 0.0) + return (Vec3){.x = v.x / len, + .y = v.y / len, + .z = v.z / len}; +} + +static inline Vec3 vec3_mul(Vec3 v, double n) { + +} |
