164
164
end
165
165
end
166
166
167
- # TODO : test/check for Rect(::GeometryPrimitive) for all primitives
168
167
@testset " Boundingbox-like" begin
169
168
for constructor in [Rect, Rect{2 }, Rect{2 , Float32}, Rect3f]
170
169
@test constructor (Circle (Point2f (0 ), 1f0 )) == constructor (Point2f (- 1 , - 1 ), Vec2f (2 , 2 ))
@@ -183,19 +182,46 @@ end
183
182
end
184
183
end
185
184
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 )]
190
198
@test decompose (Point{2 ,Int}, a) == pt_expa
191
199
mesh = normal_mesh (a)
192
200
@test decompose (Point2f, mesh) == pt_expa
193
201
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 ]]
197
214
@test decompose (Point{3 ,Int}, b) == pt_expb
198
215
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
+
199
225
mesh = normal_mesh (b)
200
226
@test faces (mesh) == GLTriangleFace[
201
227
(1 , 2 , 4 ), (1 , 4 , 3 ), (7 , 8 , 6 ), (7 , 6 , 5 ), (5 , 6 , 2 ), (5 , 2 , 1 ),
0 commit comments