-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.h
68 lines (61 loc) · 930 Bytes
/
help.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
#pragma once
#include "gz.h"
/* NOT part of API - just for general assistance */
short ctoi(float color);
template <class vt>
void clampVal(vt *val, vt min, vt max) {
*val = *val > max ? max : *val;
*val = *val < min ? min : *val;
}
template <class vt>
void swap(vt& v0, vt& v1) {
vt t = v0;
v0 = v1;
v1 = t;
}
template <class vt>
void minMax3(vt v0, vt v1, vt v2, vt& min, vt& max) {
if (v0 < v1) {
if (v0 < v2) {
min = v0;
if (v1 < v2) {
max = v2;
}
else {
max = v1;
}
}
else {
min = v2;
max = v1;
}
}
else {
if (v0 > v2) {
max = v0;
if (v1 > v2) {
min = v2;
}
else {
min = v1;
}
}
else {
min = v1;
max = v2;
}
}
}
/*
template <class vt>
void findMinMax4(vt v0, vt v1, vt v2, vt v3, vt& min, vt& max) {
if (v0 > v1) {
swap<vt>(v0, v1);
}
if (v2 > v3) {
swap<vt>(v2, v3);
}
min = v0 > v2 ? v2 : v0;
max = v1 > v3 ? v1 : v3;
}
*/