-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtesting.go
More file actions
49 lines (44 loc) · 1.31 KB
/
testing.go
File metadata and controls
49 lines (44 loc) · 1.31 KB
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
package glmtesting
import (
"github.com/EngoEngine/math"
"github.com/engoengine/glm"
"github.com/engoengine/glm/flops/32/flops"
)
// FloatEqual returns true if v0 == v1 for every component. Will also return true
// when the components of both vectors are NaN.
func FloatEqual(v0, v1 float32) bool {
if !flops.Eq(v0, v1) && !(math.IsNaN(v0) && math.IsNaN(v1)) {
return false
}
return true
}
// Vec2Equal returns true if v0 == v1 for every component. Will also return true
// when the components of both vectors are NaN.
func Vec2Equal(v0, v1 glm.Vec2) bool {
for n := 0; n < len(v0); n++ {
if !flops.Eq(v0[n], v1[n]) && !(math.IsNaN(v0[n]) && math.IsNaN(v1[n])) {
return false
}
}
return true
}
// Vec3Equal returns true if v0 == v1 for every component. Will also return true
// when the components of both vectors are NaN.
func Vec3Equal(v0, v1 glm.Vec3) bool {
for n := 0; n < len(v0); n++ {
if !flops.Eq(v0[n], v1[n]) && !(math.IsNaN(v0[n]) && math.IsNaN(v1[n])) {
return false
}
}
return true
}
// Vec4Equal returns true if v0 == v1 for every component. Will also return true
// when the components of both vectors are NaN.
func Vec4Equal(v0, v1 glm.Vec4) bool {
for n := 0; n < len(v0); n++ {
if !flops.Eq(v0[n], v1[n]) && !(math.IsNaN(v0[n]) && math.IsNaN(v1[n])) {
return false
}
}
return true
}