Implement asteroid bouncing

This commit is contained in:
2025-10-18 17:43:22 +01:00
parent 1b3bc21026
commit e9cb65534c
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) {