GeometryBasics Rect

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> Rect(Circle(Point((0.,0.)), 1.))
Rect2D{Float64}([-1.0, -1.0], [2.0, 2.0])

Is there a better bounding box function?

? extrema()

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])

1 Like

the Rect() returns a min-point and the width (mini, maxi .- mini)

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