blob: 4823644f8565ef90d165d93dc1570f105acb49ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//
// Created by sid on 1/2/24.
//
#include "raymath.h"
#include "utilities.h"
#include "config.h"
Vector2 toCenter(Vector2 vector) {
// Used only for drawing, any other calculation using raylib style coordinate (0, 0) top left. x = left-right, y = top-bottom
return (Vector2) {
vector.x + (float)config.ORIGIN_X,
(-1 * vector.y) + (float)config.ORIGIN_Y
};
}
Vector2 toTopLeft(Vector2 vector) {
return (Vector2) {
vector.x - (float)config.ORIGIN_X,
(-1 * vector.y) - (float)config.ORIGIN_Y
};
}
Vector2 angle2HeadingVector(float angle) {
// angle in degree
angle = angle * (float)M_PI / 180;
return (Vector2) {
cosf(angle),
sinf(angle)
};
}
|