forked from smistad/SIPL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Types.cpp
86 lines (79 loc) · 2.32 KB
/
Types.cpp
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
#include "Types.hpp"
namespace SIPL {
// float2
float float2::distance(float2 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
}
float float2::dot(float2 other) const {
return x*other.x+y*other.y;
}
float float2::distance(int2 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
}
float float2::dot(int2 other) const {
return x*other.x+y*other.y;
}
bool float2::operator==(int2 other) const {
return x==other.x && y==other.y;
}
bool float2::operator==(float2 other) const {
return x==other.x && y==other.y;
}
// float3
float float3::distance(float3 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y)+(z-other.z)*(z-other.z));
}
float float3::dot(float3 other) const {
return x*other.x+y*other.y+z*other.z;
}
float float3::distance(int3 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y)+(z-other.z)*(z-other.z));
}
float float3::dot(int3 other) const {
return x*other.x+y*other.y+z*other.z;
}
bool float3::operator==(int3 other) const {
return x==other.x && y==other.y && z==other.z;
}
bool float3::operator==(float3 other) const {
return x==other.x && y==other.y && z==other.z;
}
// int2
float int2::distance(float2 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
}
float int2::dot(float2 other) const {
return x*other.x+y*other.y;
}
float int2::distance(int2 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
}
float int2::dot(int2 other) const {
return x*other.x+y*other.y;
}
bool int2::operator==(int2 other) const {
return x==other.x && y==other.y;
}
bool int2::operator==(float2 other) const {
return x==other.x && y==other.y;
}
// int3
float int3::distance(float3 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y)+(z-other.z)*(z-other.z));
}
float int3::dot(float3 other) const {
return x*other.x+y*other.y+z*other.z;
}
float int3::distance(int3 other) const {
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y)+(z-other.z)*(z-other.z));
}
float int3::dot(int3 other) const {
return x*other.x+y*other.y+z*other.z;
}
bool int3::operator==(int3 other) const {
return x==other.x && y==other.y && z==other.z;
}
bool int3::operator==(float3 other) const {
return x==other.x && y==other.y && z==other.z;
}
};