-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriangle_test.go
More file actions
33 lines (29 loc) · 1.4 KB
/
triangle_test.go
File metadata and controls
33 lines (29 loc) · 1.4 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
package MeshTypes_Test
import (
"reflect"
"testing"
"github.com/Patch2PDF/GDTF-Mesh-Reader/v2/pkg/MeshTypes"
)
func TestTriangleNormal(t *testing.T) {
a := MeshTypes.Triangle{
V0: MeshTypes.Vertex{Position: MeshTypes.Vector{X: 1, Y: 4, Z: 3}, Normal: &MeshTypes.Vector{X: 4, Y: 5, Z: 6}},
V1: MeshTypes.Vertex{Position: MeshTypes.Vector{X: 4, Y: 8, Z: 10}, Normal: &MeshTypes.Vector{X: 10, Y: 11, Z: 12}},
V2: MeshTypes.Vertex{Position: MeshTypes.Vector{X: 13, Y: 14, Z: 15}, Normal: &MeshTypes.Vector{X: 16, Y: 17, Z: 18}},
}
want := MeshTypes.Vector{X: -0.39436910666014113, Y: 0.8604416872584897, Z: -0.3226656327219336}
result := a.Normal()
if !reflect.DeepEqual(result, want) {
t.Error("Triangle Normal() returned value does not match expected value")
}
}
func TestTriangleCopy(t *testing.T) {
a := MeshTypes.Triangle{
V0: MeshTypes.Vertex{Position: MeshTypes.Vector{X: 1, Y: 2, Z: 3}, Normal: &MeshTypes.Vector{X: 4, Y: 5, Z: 6}},
V1: MeshTypes.Vertex{Position: MeshTypes.Vector{X: 7, Y: 8, Z: 9}, Normal: &MeshTypes.Vector{X: 10, Y: 11, Z: 12}},
V2: MeshTypes.Vertex{Position: MeshTypes.Vector{X: 13, Y: 14, Z: 15}, Normal: &MeshTypes.Vector{X: 16, Y: 17, Z: 18}},
}
copy := a.Copy()
if !(reflect.DeepEqual(copy, a) && a.V0.Normal != copy.V0.Normal && a.V1.Normal != copy.V1.Normal && a.V2.Normal != copy.V2.Normal) {
t.Error("Triangle Copy() returned value does not match expected value")
}
}