@@ -113,6 +113,35 @@ func TestPointCloudCentroid(t *testing.T) {
113113 test .That (t , CloudCentroid (pc ), test .ShouldResemble , r3.Vector {20 , 200 , 2000 })
114114}
115115
116+ func TestPointCloudPoints (t * testing.T ) {
117+ var data Data
118+ pc := NewBasicPointCloud (3 )
119+ test .That (t , pc .Set (r3.Vector {1 , 2 , 3 }, data ), test .ShouldBeNil )
120+ test .That (t , pc .Set (r3.Vector {4 , 5 , 6 }, data ), test .ShouldBeNil )
121+ test .That (t , pc .Set (r3.Vector {7 , 8 , 9 }, data ), test .ShouldBeNil )
122+ points := CloudToPoints (pc )
123+ test .That (t , len (points ), test .ShouldEqual , 3 )
124+ // The points can come in an unexpected order. So, just check that the 3 points we expect are
125+ // in there somewhere.
126+ has1 := false
127+ has2 := false
128+ has3 := false
129+ for _ , point := range points {
130+ if point .ApproxEqual (r3.Vector {1 , 2 , 3 }) {
131+ has1 = true
132+ }
133+ if point .ApproxEqual (r3.Vector {4 , 5 , 6 }) {
134+ has2 = true
135+ }
136+ if point .ApproxEqual (r3.Vector {7 , 8 , 9 }) {
137+ has3 = true
138+ }
139+ }
140+ test .That (t , has1 , test .ShouldBeTrue )
141+ test .That (t , has2 , test .ShouldBeTrue )
142+ test .That (t , has3 , test .ShouldBeTrue )
143+ }
144+
116145func TestPointCloudMatrix (t * testing.T ) {
117146 pc := NewBasicPointCloud (0 )
118147
0 commit comments