summaryrefslogtreecommitdiff
path: root/matematik.c
diff options
context:
space:
mode:
Diffstat (limited to 'matematik.c')
-rw-r--r--matematik.c16
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 };
+}