-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathutils.h
70 lines (51 loc) · 1.23 KB
/
mathutils.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef MATHUTILS_H
#define MATHUTILS_H
#include <inttypes.h>
#ifndef PI
#define PI 3.1415926
#endif
typedef struct v2{
float x;
float y;
}v2;
typedef struct v3{
float x;
float y;
float z;
}v3;
typedef struct v4{
float x;
float y;
float w;
float h;
}v4;
typedef struct m2{
float x1;
float y1;
float x2;
float y2;
}m2;
uint8_t hash_v2(v2 key, uint32_t capacity);
uint8_t v2_equals(v2 a, v2 b);
uint8_t v3_equals(v3 a, v3 b);
uint8_t v4_equals(v4 a, v4 b);
uint8_t m2_equals(m2 a, m2 b);
uint8_t edge_collision_v4(v4, m2);
v2 edge_intersect(float ax, float ay, float bx, float by, m2 edge);
v2 edge_intersect_v2(v2 a, v2 b, v2 c, v2 d);
float lenDirX(float len, float dir);
float lenDirY(float len, float dir);
int8_t sign(float val);
float distancePoint(float x, float y, float xx, float yy);
float distancePointV2(v2, v2);
float directionPoint(float x, float y, float xx, float yy);
float directionPointV2(v2, v2);
uint8_t pointInRect(float x, float y, v4);
uint8_t pointInRectV2(v2, v4);
uint8_t pointInRectB(float x, float y, v4);
uint8_t pointInRectV2B(v2, v4);
uint8_t rectCollides(v4, v4);
uint8_t rectCollidesB(v4, v4);
void approachZero(int32_t* val, int32_t amount);
void approachZeroF(float* val, float amount);
#endif