-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructures.h
114 lines (98 loc) · 1.38 KB
/
structures.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#pragma once
struct Vec2 {
float x, y;
};
struct Vec4 {
float x, y, z, w;
};
struct Vec3 {
float x, y, z;
Vec3 operator +(Vec3 d) {
return {
x + d.x,
y + d.y,
z + d.z
};
}
Vec3 operator -(Vec3 d) {
return {
x - d.x,
y - d.y,
z - d.z
};
}
Vec3 operator *(float d) {
return {
x * d,
y * d,
z * d
};
}
void Normalize() {
while (y < -180) y += 360;
while (y > 180) y -= 360;
if (x > 89) x = 89;
if (x < -89) x = -89;
}
float Sum() {
return x + y + z;
}
};
struct Rect {
Vec2 top_left;
Vec2 top_right;
Vec2 bottom_left;
Vec2 bottom_right;
};
struct HyperRect {
// .b------c
// .' | .'|
// a---+--d' |
// | | | |
// | ,+--+---+
// |.' | .'
// +------+'
struct {
Vec2 a; // Position on 2d screen
float ax; // x, y and z values at that 2d position.
float ay;
float az;
Vec2 b;
float bx;
float by;
float bz;
Vec2 c;
float cx;
float cy;
float cz;
Vec2 d;
float dx;
float dy;
float dz;
} top;
// .+------+
// .' | .'|
// +---+--+' |
// | | | |
// | ,b--+---c
// |.' | .'
// a------d'
struct {
Vec2 a; // Position on 2d screen
float ax; // x, y and z values at that 2d position.
float ay;
float az;
Vec2 b;
float bx;
float by;
float bz;
Vec2 c;
float cx;
float cy;
float cz;
Vec2 d;
float dx;
float dy;
float dz;
} bottom;
};