blob: c5e36b2daef8cc463201df9129248f86c86d5565 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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 };
}
|