44 "testing"
55
66 r3 "github.com/golang/geo/r3"
7- s2 "github.com/golang/geo/s2"
87 assert "github.com/stretchr/testify/assert"
98)
109
@@ -40,7 +39,7 @@ func TestInfernoActive(t *testing.T) {
4039}
4140
4241func TestInfernoConvexHull2D (t * testing.T ) {
43- // Construct a Inferno that looks roughly like this.
42+ // Construct a Inferno that looks roughly like this.
4443 // D should be inside the 2D Convex Hull but a corner of the 3D Convex Hull
4544 //
4645 // C
@@ -66,15 +65,43 @@ func TestInfernoConvexHull2D(t *testing.T) {
6665 },
6766 }
6867
69- expectedHull := s2 . LoopFromPoints ([]s2. Point {
70- {Vector : r3. Vector { X : 4 , Y : 7 , Z : 1 } },
71- {Vector : r3. Vector { X : 1 , Y : 2 , Z : 1 } },
72- {Vector : r3. Vector { X : 7 , Y : 2 , Z : 1 } },
73- })
68+ expectedHull := []r3. Vector {
69+ {X : 1 , Y : 2 , Z : 0 },
70+ {X : 4 , Y : 7 , Z : 0 },
71+ {X : 7 , Y : 2 , Z : 0 },
72+ }
7473
75- assert .ElementsMatch (t , expectedHull .Vertices (), inf .ConvexHull2D ().Vertices (), "ConvexHull2D should be as expected" )
76- assert .True (t , inf .ConvexHull2D ().BoundaryEqual (expectedHull ), "Boundary of expected and actual should be equal" )
74+ assert .ElementsMatch (t , expectedHull , inf .ConvexHull2D (), "ConvexHull2D should be as expected" )
7775
7876 // 3D-hull should be different
79- assert .NotEqual (t , expectedHull .NumVertices (), inf .ConvexHull3D ().NumVertices (), "3D hull should contain the vertex 'D'" )
77+ assert .NotEqual (t , len (expectedHull ), len (inf .ConvexHull3D ()), "3D hull should contain the vertex 'D'" )
78+ }
79+
80+ // Just check that all fires are passed to quickhull.ConvexHull()
81+ func TestInfernoConvexHull3D (t * testing.T ) {
82+ inf := Inferno {
83+ Fires : []* Fire {
84+ {
85+ Vector : r3.Vector {X : 1 , Y : 2 , Z : 3 },
86+ },
87+ {
88+ Vector : r3.Vector {X : 4 , Y : 7 , Z : 6 },
89+ },
90+ {
91+ Vector : r3.Vector {X : 7 , Y : 2 , Z : 9 },
92+ },
93+ {
94+ Vector : r3.Vector {X : 4 , Y : 4 , Z : 12 },
95+ },
96+ },
97+ }
98+
99+ expectedHull := []r3.Vector {
100+ {X : 1 , Y : 2 , Z : 3 },
101+ {X : 4 , Y : 7 , Z : 6 },
102+ {X : 7 , Y : 2 , Z : 9 },
103+ {X : 4 , Y : 4 , Z : 12 },
104+ }
105+
106+ assert .ElementsMatch (t , expectedHull , inf .ConvexHull3D (), "ConvexHull3D should contain all fire locations" )
80107}
0 commit comments