diff options
author | riton <riton@riton.home> | 2025-03-29 21:37:46 +0300 |
---|---|---|
committer | riton <riton@riton.home> | 2025-03-29 21:37:46 +0300 |
commit | 1b6ecc22e77b7aa1fee16420b041c1dea1925052 (patch) | |
tree | 6816b0d3ebcfa30492371233fcce253ef5275f31 /matematik.c |
Diffstat (limited to 'matematik.c')
-rw-r--r-- | matematik.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/matematik.c b/matematik.c new file mode 100644 index 0000000..c5e36b2 --- /dev/null +++ b/matematik.c @@ -0,0 +1,16 @@ +#include "matematik.h" + +float distance(Vector2 a, Vector2 b){ + return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2)); +} + +Vector2 normalize_vector(Vector2 vec){ + float len = sqrt(vec.x * vec.x + vec.y * vec.y); + vec.x /= len; + vec.y /= len; + return vec; +} + +Vector2 vector_diff(Vector2 a, Vector2 b){ + return (Vector2) { a.x - b.x, a.y - b.y }; +} |