-
Notifications
You must be signed in to change notification settings - Fork 1
/
vec4.h
48 lines (43 loc) · 1005 Bytes
/
vec4.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
#pragma once
#include <unordered_map>
class vec4
{
public:
vec4();
vec4(double _x, double _y, double _z, double _p);
~vec4();
unsigned int hash();
double x;
double y;
double z;
double p;
double& operator[](int indx);
vec4& operator=(vec4 l);
};
bool operator==(vec4 l, vec4 r);
vec4 operator+(vec4 lhs, vec4 rhs);
vec4 operator-(vec4 lhs, vec4 rhs);
vec4 operator/(vec4 lhs, double x);
vec4 operator*(vec4 lhs, double x);
vec4 operator*(double x, vec4 lhs);
struct vec4Hasher
{
std::size_t operator()(const vec4& lhs) const
{
using std::size_t;
using std::hash;
return (hash<double>()(lhs.x) + hash<double>()(lhs.y) + hash<double>()(lhs.z));
}
};
namespace std
{
template < >
struct hash<vec4>
{
size_t operator()(const vec4& p) const
{
// Compute individual hash values for two data members and combine them using XOR and bit shifting
return (hash<double>()(p.x) + hash<double>()(p.y) + hash<double>()(p.z));
}
};
}