From 1b6ecc22e77b7aa1fee16420b041c1dea1925052 Mon Sep 17 00:00:00 2001 From: riton Date: Sat, 29 Mar 2025 21:37:46 +0300 Subject: init repo --- matematik.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 matematik.c (limited to 'matematik.c') 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 }; +} -- cgit v1.2.3