-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.h
More file actions
75 lines (60 loc) · 970 Bytes
/
types.h
File metadata and controls
75 lines (60 loc) · 970 Bytes
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
71
72
73
74
75
#ifndef _INCL_TYPES
#define _INCL_TYPES
struct vec2 {
float x;
float y;
};
struct vec3 {
operator vec2() const { return {x, y}; }
float x;
float y;
float z;
};
struct color {
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
};
struct vec4 {
float x;
float y;
float z;
float w;
};
struct mat4 {
// column vectors
vec4 i;
vec4 j;
vec4 k;
vec4 l;
/*
i j k l
----------
x x x x
y y y y
z z z z
w w w w
*/
};
struct tri {
vec3 a;
vec3 b;
vec3 c;
};
vec4 mul(mat4 m, vec4 v);
vec3 mulP(mat4 m, vec3 v);
vec3 mulV(mat4 m, vec3 v);
mat4 mul(mat4 a, mat4 b);
mat4 rotY(float theta);
mat4 rotX(float theta);
mat4 trans(vec3 pos);
float length(vec3 a);
vec3 unit(vec3 a);
vec3 cross(vec3 u, vec3 v);
vec3 operator-(vec3, vec3);
bool operator==(color a, color b);
bool operator!=(color a, color b);
color operator*(color a, float b);
float triEdge(vec3, vec3, vec3);
#endif