# GeometryBasics Rect

**URL:** <https://discourse.julialang.org/t/geometrybasics-rect/64779>\
**Category:** General Usage\
**Tags:** geometrybasics\
**Created:** [July 16, 2021, 11:21pm UTC](https://discourse.julialang.org/t/geometrybasics-rect/64779 "2021-07-16T23:21:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [July 16, 2021, 11:21pm UTC](https://discourse.julialang.org/t/geometrybasics-rect/64779/1 "2021-07-16T23:21:15Z")

</div>

`Rect` says

> Construct a HyperRectangle enclosing all points.

which it does, but I think there is a better rectangle for this job than the one returned.

```julia
julia> Rect(Circle(Point((0.,0.)), 1.))
Rect2D{Float64}([-1.0, -1.0], [2.0, 2.0])

```

Is there a better bounding box function?

---

<div class="post-metadata">

**Author:** ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)\
**Post date:** [July 17, 2021, 2:36am UTC](https://discourse.julialang.org/t/geometrybasics-rect/64779/2 "2021-07-17T02:36:49Z")

</div>

> [@jzr](#):
>
> Is there a better bounding box function?

? [extrema()](https://github.com/JuliaGeometry/GeometryBasics.jl/blob/e39b2518ed1288e4fbcf701e448e22fafcd61a1c/src/geometry_primitives.jl#L2...L3)

```julia
julia> extrema(Circle(Point((0.,0.)), 10.))
([-10.0, -10.0], [10.0, 10.0])

julia> extrema(Rect(Circle(Point((0.,0.)), 1.)))
([-1.0, -1.0], [1.0, 1.0])

```

---

<div class="post-metadata">

**Author:** ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)\
**Post date:** [July 17, 2021, 2:42am UTC](https://discourse.julialang.org/t/geometrybasics-rect/64779/3 "2021-07-17T02:42:40Z")

</div>

> [@jzr](#):
>
> which it does, but I think there is a better rectangle for this job than the one returned.

[the Rect() returns a min-point and the width `(mini, maxi .- mini)`](https://github.com/JuliaGeometry/GeometryBasics.jl/blob/e39b2518ed1288e4fbcf701e448e22fafcd61a1c/src/boundingboxes.jl#L40..L43)

```julia
function Rect{T}(a::Sphere) where {T}
    mini, maxi = extrema(a)
    return Rect{T}(mini, maxi .- mini)
end

```
