-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutility.h
124 lines (105 loc) · 3.39 KB
/
utility.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
115
116
117
118
119
120
121
122
/*
* utility.h
*
* Copyright (c) 2015-2016 Dany Vohl, David G. Barnes, Christopher J. Fluke,
* Yuri Benovitski, Tsz Ho Wong, Owen L Kaluza, Toan D. Nguyen.
*
* This file is part of encube.
*
* encube is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* encube is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with encube. If not, see <http://www.gnu.org/licenses/>.
*
* We would appreciate it if research outcomes using encube would
* provide the following acknowledgement:
*
* "Visual analytics of multidimensional data was conducted with encube."
*
* and a reference to
*
* Dany Vohl, David G. Barnes, Christopher J. Fluke, Govinda Poudel, Nellie Georgiou-Karistianis,
* Amr H. Hassan, Yuri Benovitski, Tsz Ho Wong, Owen L Kaluza, Toan D. Nguyen, C. Paul Bonnington. (2016).
* Large-scale comparative visualisation of sets of multidimensional data. PeerJ Computer Science, In Press.
*
*/
#if !defined(_UTILITY_H)
#define _UTILITY_H
#define inline
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fcntl.h>
#include <unistd.h>
#include <GL/glew.h>
//Defines a 32bit colour accessible as rgba byte array, integer and r,g,b,a component struct
typedef union {
GLubyte rgba[4];
int value;
struct {
GLubyte r;
GLubyte g;
GLubyte b;
GLubyte a;
};
} Colour;
typedef union
{
float a[3];
struct
{
float x, y, z;
};
} float3;
// coloum-row fashion
typedef union
{
float a[16];
float d[4][4];
} mat4x4;
typedef struct
{
float3 min;
float3 max;
} AABB;
inline float3 make_float3(float x, float y, float z);
inline float3 make_float3(float s);
inline float3 operator+(float3 a, float3 b);
inline float3 operator+(float3 a, float b);
inline float3 operator+(float b, float3 a);
inline void operator+=(float3 &a, float3 b);
inline void operator+=(float3 &a, float b);
inline float3 operator-(float3 a, float3 b);
inline float3 operator-(float3 a, float b);
inline float3 operator-(float b, float3 a);
inline void operator-=(float3 &a, float3 b);
inline void operator-=(float3 &a, float b);
inline float3 operator*(float3 a, float3 b);
inline float3 operator*(float3 a, float b);
inline float3 operator*(float b, float3 a);
inline void operator*=(float3 &a, float3 b);
inline void operator*=(float3 &a, float b);
inline float3 operator/(float3 a, float3 b);
inline float3 operator/(float3 a, float b);
inline float3 operator/(float b, float3 a);
inline void operator/=(float3 &a, float3 b);
inline void operator/=(float3 &a, float b);
inline bool operator==(float3 &a, float3 &b);
inline bool operator!=(float3 &a, float3 &b);
inline float dotprod(float3 &a, float3 &b);
inline float length(float3 v);
inline float3 normalize(float3 &v);
inline float3 reflect(float3 &i, float3 &n);
inline float3 cross(float3 &a, float3 &b);
inline mat4x4 inverseTranspose(mat4x4 m);
inline AABB make_aabb(float3 _min, float3 _max);
bool intersect(AABB *out, AABB *a, AABB *b);
#endif