pawengine/types.c
2025-02-24 20:11:51 +01:00

12 lines
355 B
C

#include "types.h"
#include "math.h"
struct Vec2 vec2_normalize(struct Vec2 v) {
float abs = sqrt(v.x * v.x + v.y * v.y);
return (struct Vec2){v.x / abs, v.y / abs};
}
struct Vec2 vec2_rotate(struct Vec2 v, float alpha) {
return (struct Vec2){v.x * cosf(alpha) - v.y * sinf(alpha),
v.x * sinf(alpha) + v.y * cosf(alpha)};
}