diff --git a/ext/ExtentsExt.jl b/ext/ExtentsExt.jl index a151054c..2b48a7ff 100644 --- a/ext/ExtentsExt.jl +++ b/ext/ExtentsExt.jl @@ -13,4 +13,9 @@ function Extents.extent(rect::GeometryBasics.Rect3) return Extents.Extent(X=(xmin, xmax), Y=(ymin, ymax), Z=(zmin, zmax)) end +function Extents.extent(rect::GeometryBasics.Rect4) + (xmin, ymin, zmin, mmin), (xmax, ymax, zmax, mmax) = extrema(rect) + return Extents.Extent(X=(xmin, xmax), Y=(ymin, ymax), Z=(zmin, zmax), M=(mmin, mmax)) +end + end diff --git a/src/GeometryBasics.jl b/src/GeometryBasics.jl index 5b83c6ff..739bbd4c 100644 --- a/src/GeometryBasics.jl +++ b/src/GeometryBasics.jl @@ -56,7 +56,7 @@ export uv_mesh, normal_mesh, uv_normal_mesh export height, origin, radius, width, widths export HyperSphere, Circle, Sphere, Cone export Cylinder, Pyramid, extremity -export HyperRectangle, Rect, Rect2, Rect3, Recti, Rect2i, Rect3i, Rectf, Rect2f, Rect3f, Rectd, Rect2d, Rect3d, RectT +export HyperRectangle, Rect, Rect2, Rect3, Rect4, Recti, Rect2i, Rect3i, Rect4i, Rectf, Rect2f, Rect3f, Rect4f, Rectd, Rect2d, Rect3d, Rect4d, RectT export before, during, meets, overlaps, intersects, finishes, bbox_diff export centered, direction, area, volume, update export max_dist_dim, max_euclidean, max_euclideansq, min_dist_dim, min_euclidean diff --git a/src/primitives/rectangles.jl b/src/primitives/rectangles.jl index 39826cf8..cb400720 100644 --- a/src/primitives/rectangles.jl +++ b/src/primitives/rectangles.jl @@ -31,29 +31,34 @@ A rectangle in N dimensions, formally the Cartesian product of intervals. See al |`N`(dim)|`Rect{N,T}`|`Rectd{N}`|`Rectf{N}`|`Recti{N}`| |`2` |`Rect2{T}` |`Rect2d` |`Rect2f` |`Rect2i` | |`3` |`Rect3{T}` |`Rect3d` |`Rect3f` |`Rect3i` | +|`4` |`Rect4{T}` |`Rect4d` |`Rect4f` |`Rect4i` | There is an additional unexported alias `RectT` that simply reverses the order of type parameters: `RectT{T,N} == Rect{N,T}`. """ -Rect, Rect2, Rect3, RectT, Rectd, Rect2d, Rect3d, Rectf, Rect2f, Rect3f, Recti, Rect2i, Rect3i +Rect, Rect2, Rect3, Rect4, RectT, Rectd, Rect2d, Rect3d, Rect4d, Rectf, Rect2f, Rect3f, Rect4f, Recti, Rect2i, Rect3i, Rect4i const Rect{N,T} = HyperRectangle{N,T} const Rect2{T} = Rect{2,T} const Rect3{T} = Rect{3,T} +const Rect4{T} = Rect{4,T} const RectT{T,N} = Rect{N,T} const Rectd{N} = Rect{N,Float64} const Rect2d = Rect2{Float64} const Rect3d = Rect3{Float64} +const Rect4d = Rect4{Float64} const Rectf{N} = Rect{N,Float32} const Rect2f = Rect2{Float32} const Rect3f = Rect3{Float32} +const Rect4f = Rect4{Float32} const Recti{N} = Rect{N,Int} const Rect2i = Rect2{Int} const Rect3i = Rect3{Int} +const Rect4i = Rect4{Int} # Constructors diff --git a/test/geointerface.jl b/test/geointerface.jl index 5f0b9e9e..700a56eb 100644 --- a/test/geointerface.jl +++ b/test/geointerface.jl @@ -128,6 +128,12 @@ end @test ext.X == (0.0f0, 1.0f0) @test ext.Y == (0.0f0, 1.0f0) @test ext.Z == (0.0f0, 1.0f0) + rect = Rect4f(Vec{4,Float32}(0), Vec{4,Float32}(1.0)) + ext = extent(rect) + @test ext.X == (0.0f0, 1.0f0) + @test ext.Y == (0.0f0, 1.0f0) + @test ext.Z == (0.0f0, 1.0f0) + @test ext.M == (0.0f0, 1.0f0) end @testset "coordtype" begin