fix(mat3.c): rename mat3_Det to mat3_det

- renamed all structs with _t suffix
- remove most comments (might continue later)
This commit is contained in:
2025-06-08 23:32:56 +02:00
parent 19e57fb1ae
commit d456cbc3a7
6 changed files with 99 additions and 267 deletions

View File

@@ -4,37 +4,37 @@
#include "vec4.h"
inline Vec4 vec4(float x, float y, float z, float w)
inline Vec4_t vec4(float x, float y, float z, float w)
{
return (Vec4) {x, y, z, w};
return (Vec4_t) {x, y, z, w};
}
Vec4 vec4_add(Vec4 v1, Vec4 v2)
Vec4_t vec4_add(Vec4_t v1, Vec4_t v2)
{
return vec4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w);
}
Vec4 vec4_sub(Vec4 v1, Vec4 v2)
Vec4_t vec4_sub(Vec4_t v1, Vec4_t v2)
{
return vec4(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w);
}
Vec4 vec4_scale(Vec4 v, float scalar)
Vec4_t vec4_scale(Vec4_t v, float scalar)
{
return vec4(v.x * scalar, v.y * scalar, v.z * scalar, v.w * scalar);
}
float vec4_dot(Vec4 a, Vec4 b)
float vec4_dot(Vec4_t a, Vec4_t b)
{
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}
float vec4_len(Vec4 v)
float vec4_len(Vec4_t v)
{
return sqrtf(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w);
}
Vec4 vec4_norm(Vec4 v)
Vec4_t vec4_norm(Vec4_t v)
{
float length = vec4_len(v);
if (length == 0.f) return vec4(0, 0, 0, 0);
@@ -42,7 +42,7 @@ Vec4 vec4_norm(Vec4 v)
return vec4_scale(v, 1.f / length);
}
Vec4 vec4_lerp(Vec4 a, Vec4 b, float t)
Vec4_t vec4_lerp(Vec4_t a, Vec4_t b, float t)
{
t = fmaxf(0.f, fminf(t, 1.f));
@@ -54,7 +54,7 @@ Vec4 vec4_lerp(Vec4 a, Vec4 b, float t)
);
}
float vec4Angle(Vec4 a, Vec4 b)
float vec4Angle(Vec4_t a, Vec4_t b)
{
float lenA = vec4_len(a);
float lenB = vec4_len(b);
@@ -72,7 +72,7 @@ float vec4Angle(Vec4 a, Vec4 b)
return acosf(cosTheta);
}
Vec4 vec4_proj(Vec4 a, Vec4 b)
Vec4_t vec4_proj(Vec4_t a, Vec4_t b)
{
float dotA = vec4_dot(a, b);
float dotB = vec4_dot(b, b);
@@ -81,17 +81,17 @@ Vec4 vec4_proj(Vec4 a, Vec4 b)
return vec4_scale(b, scale);
}
Vec4 vec4_refl(Vec4 v, Vec4 normal)
Vec4_t vec4_refl(Vec4_t v, Vec4_t normal)
{
Vec4 proj = vec4_proj(v, normal);
Vec4 scal = vec4_scale(proj, 2.f);
Vec4 rlt = vec4_sub(v, scal);
Vec4_t proj = vec4_proj(v, normal);
Vec4_t scal = vec4_scale(proj, 2.f);
Vec4_t rlt = vec4_sub(v, scal);
return rlt;
}
float vec4_dist(Vec4 a, Vec4 b)
float vec4_dist(Vec4_t a, Vec4_t b)
{
Vec4 vsub = vec4_sub(a, b);
Vec4_t vsub = vec4_sub(a, b);
float rlt = vec4_len(vsub);
return rlt;
}