Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ext/ExtentsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/GeometryBasics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/primitives/rectangles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/geointerface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading