164164 end
165165 end
166166
167- # TODO : test/check for Rect(::GeometryPrimitive) for all primitives
168167 @testset " Boundingbox-like" begin
169168 for constructor in [Rect, Rect{2 }, Rect{2 , Float32}, Rect3f]
170169 @test constructor (Circle (Point2f (0 ), 1f0 )) == constructor (Point2f (- 1 , - 1 ), Vec2f (2 , 2 ))
@@ -183,19 +182,46 @@ end
183182 end
184183 end
185184
186- # TODO : origin, minimum, maximum, width, height, widths, area, volume with empty constructed Rects
187-
188- a = Rect (Vec (0 , 0 ), Vec (1 , 1 ))
189- pt_expa = Point{2 ,Int}[(0 , 0 ), (1 , 0 ), (1 , 1 ), (0 , 1 )]
185+ # TODO : These don't really make sense...
186+ r = Rect2f ()
187+ @test origin (r) == Vec (Inf , Inf )
188+ @test minimum (r) == Vec (Inf , Inf )
189+ @test isnan (maximum (r))
190+ @test width (r) == - Inf
191+ @test height (r) == - Inf
192+ @test widths (r) == Vec (- Inf , - Inf )
193+ @test area (r) == Inf
194+ @test volume (r) == Inf
195+
196+ a = Rect (Vec (0 , 1 ), Vec (2 , 3 ))
197+ pt_expa = Point{2 ,Int}[(0 , 1 ), (2 , 1 ), (2 , 4 ), (0 , 4 )]
190198 @test decompose (Point{2 ,Int}, a) == pt_expa
191199 mesh = normal_mesh (a)
192200 @test decompose (Point2f, mesh) == pt_expa
193201
194- b = Rect (Vec (1 , 1 , 1 ), Vec (1 , 1 , 1 ))
195- pt_expb = Point{3 ,Int64}[[1 , 1 , 1 ], [1 , 1 , 2 ], [1 , 2 , 1 ], [1 , 2 , 2 ],
196- [2 , 1 , 1 ], [2 , 1 , 2 ], [2 , 2 , 1 ], [2 , 2 , 2 ]]
202+ @test origin (a) == Vec (0 ,1 )
203+ @test minimum (a) == Vec (0 ,1 )
204+ @test maximum (a) == Vec (2 ,4 )
205+ @test width (a) == 2
206+ @test height (a) == 3
207+ @test widths (a) == Vec (2 ,3 )
208+ @test area (a) == 2 * 3
209+ @test volume (a) == 2 * 3
210+
211+ b = Rect (Vec (1 , 2 , 3 ), Vec (4 , 5 , 6 ))
212+ pt_expb = Point{3 , Int64}[[1 , 2 , 3 ], [1 , 2 , 9 ], [1 , 7 , 3 ], [1 , 7 , 9 ],
213+ [5 , 2 , 3 ], [5 , 2 , 9 ], [5 , 7 , 3 ], [5 , 7 , 9 ]]
197214 @test decompose (Point{3 ,Int}, b) == pt_expb
198215
216+ @test origin (b) == Vec (1 ,2 ,3 )
217+ @test minimum (b) == Vec (1 ,2 ,3 )
218+ @test maximum (b) == Vec (5 ,7 ,9 )
219+ @test width (b) == 4
220+ @test height (b) == 5
221+ @test widths (b) == Vec (4 ,5 ,6 )
222+ @test_throws MethodError area (b)
223+ @test volume (b) == 4 * 5 * 6
224+
199225 mesh = normal_mesh (b)
200226 @test faces (mesh) == GLTriangleFace[
201227 (1 , 2 , 4 ), (1 , 4 , 3 ), (7 , 8 , 6 ), (7 , 6 , 5 ), (5 , 6 , 2 ), (5 , 2 , 1 ),
0 commit comments