@@ -10,11 +10,11 @@ struct HyperRectangle{N,T} <: GeometryPrimitive{N,T}
1010 origin:: Vec{N,T}
1111 widths:: Vec{N,T}
1212
13- function HyperRectangle {N, T} (o:: VecTypes{N, T1} , w:: VecTypes{N, T2} ) where {N, T, T1, T2 }
14- return new {N, T} (Vec {N, T} (o ... ), Vec {N, T} (w ... ))
13+ function HyperRectangle {N, T} (o:: VecTypes , w:: VecTypes ) where {N, T}
14+ return new {N, T} (convert ( Vec{N, T}, o ), convert ( Vec{N, T}, w ))
1515 end
16- function HyperRectangle {N, T} (o:: VecTypes{N, T1} , w:: VecTypes{N, T2} ) where {N, T <: Integer , T1, T2 }
17- return new {N, T} (Vec {N, T} ( round .(T, o)... ), Vec {N, T} ( round .(T, w)... ))
16+ function HyperRectangle {N, T} (o:: VecTypes , w:: VecTypes ) where {N, T <: Integer }
17+ return new {N, T} (convert ( Vec{N, T}, round .(T, o)), convert ( Vec{N, T}, round .(T, w)))
1818 end
1919end
2020
@@ -161,6 +161,12 @@ height(prim::Rect) = prim.widths[2]
161161volume (prim:: HyperRectangle ) = prod (prim. widths)
162162area (prim:: Rect2 ) = volume (prim)
163163
164+ function Base. round (:: Type{Rect{N, T}} , x:: Rect{N} , mode:: RoundingMode = RoundNearest) where {N, T}
165+ mini = round .(T, minimum (x))
166+ maxi = round .(T, maximum (x))
167+ return Rect {N, T} (mini, maxi .- mini)
168+ end
169+
164170"""
165171 split(rectangle, axis, value)
166172
0 commit comments