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
|
#ifndef maths_h
#define maths_h
#define mini(a_, b_) ((a_) < (b_) ? (a_) : (b_))
#define maxi(a_, b_) ((a_) > (b_) ? (a_) : (b_))
#define clamp(v_, min_, max_) (maxi(min_, mini(max_, v_)))
#define absolute(v_) ((v_) < 0? -(v_): (v_))
#define fbits 9
#define f1 (1 << fbits)
#define sin_table_count 0x100
#define sin_table_mask 0x0ff
#define sqrt_table_count 0x800
#define sqrt_table_mask 0x07f
extern int sin_table[sin_table_count];
extern int cos_table[sin_table_count];
extern int sqrt_table[sqrt_table_count];
void init_maths(void);
int fpow(int a, int p);
int fsqrt(int a);
int* mtx_iden(int* m);
int* mtx_cpy(int* d, const int* s);
int* mtx_mul(int* d, const int* a, const int* b);
void mtx_push(const int* m);
void mtx_push_trans(int* v);
void mtx_push_rot_x(int a);
void mtx_push_rot_y(int a);
void mtx_push_rot_z(int a);
void mtx_push_scale(int a);
int* mtx_pop(void);
int* mtx_popn(int n);
int* mtx_peek(void);
int* mtx_trans(int* d, int* v);
int* mtx_rot_x(int* d, int a);
int* mtx_rot_y(int* d, int a);
int* mtx_rot_z(int* d, int a);
int* mtx_scale(int* d, int s);
int* mtx_apply(const int* m, int* v);
int* vec_cpy(int* d, const int* s, int c);
int* vec_ref(int* d, const int* i, const int* n, int c);
int vec_dot(const int* a, const int* b, int d);
int* vec_nrm(int* d, const int* a, int c);
int* vec_minise(int* d, const int* a, int c);
int* vec_sub(int* d, const int* a, const int* b, int c);
int* vec_add(int* d, const int* a, const int* b, int c);
int vec_dist(int* w, const int* a, const int* b, int c);
int* persp(int* v, int asp);
int* ndc2clip(const int* c, int* p);
#endif
|