-
Notifications
You must be signed in to change notification settings - Fork 0
/
m_math.h
41 lines (33 loc) · 828 Bytes
/
m_math.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
#ifndef M_MATH_H
#define M_MATH_H
#include <math.h>
#define PI 3.141592653589793
typedef struct {
float x;
float y;
} Vec2;
typedef struct {
float x00, x01, x10, x11;
} Mat2;
typedef struct {
Vec2 orig;
Vec2 dir;
} Ray;
typedef struct {
Vec2 A;
Vec2 B;
} Segment;
void m_Rotate(const float angle /* radians */, Vec2*);
void m_Translate(const Vec2 t, Vec2*);
void m_Scale(const float scale, Vec2*);
void m_Add(const Vec2, Vec2*);
Vec2 m_Subtract(const Vec2, const Vec2);
//returns a random float between 0 and 1
float m_Rand(void);
//returns a random float between -1 and 1
float m_RandNeg(void);
float m_Length(const Vec2);
float m_Length2(const Vec2);
float m_Determinant(const Mat2);
Vec2 m_PolarToCart(const float angle, const float radius);
#endif /* end of include guard: M_MATH_H */