Implement asteroid bouncing

This commit is contained in:
Camden Dixie O'Brien
2025-10-14 17:19:02 +01:00
parent b05a4b3fe4
commit 47a0c9ffad
3 changed files with 38 additions and 1 deletions

14
maths.c
View File

@@ -27,6 +27,20 @@ vec3_t vec2_extend(vec2_t v)
return (vec3_t) { v.x, v.y, 1 };
}
vec2_t vec2_norm(vec2_t v)
{
const float l = vec2_len(v);
return (vec2_t) {
v.x / l,
v.y / l,
};
}
float vec2_dot(vec2_t v1, vec2_t v2)
{
return v1.x * v2.x + v1.y * v2.y;
}
mat2_t mat2_rotation(float theta)
{
return (mat2_t) {