Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

promote HyperRectangle numeric type instead of error #185

Open
goretkin opened this issue Oct 18, 2019 · 2 comments
Open

promote HyperRectangle numeric type instead of error #185

goretkin opened this issue Oct 18, 2019 · 2 comments

Comments

@goretkin
Copy link
Contributor

julia> bb1 = HyperRectangle{2,Int64}([0, 0], [1, 1])

HyperRectangle{2,Int64}([0, 0], [1, 1])

julia> bb2 = HyperRectangle{2,Float64}([-3.436309307146981, -3.4222642784489077], [-8.886452461851743, -14.325391136732803])
HyperRectangle{2,Float64}([-3.436309307146981, -3.4222642784489077], [-8.886452461851743, -14.325391136732803])

julia> bb1  bb2
ERROR: MethodError: no method matching iterate(::HyperRectangle{2,Int64})
@sjkelly
Copy link
Member

sjkelly commented Oct 19, 2019

I've fixed the numeric promotion error here, but I am not sure what the expected result should be with negative widths. With the current implementation I get:

    bb1 = HyperRectangle{2,Int64}([0, 0], [1, 1])
    bb2 = HyperRectangle{2,Float64}([-3.436309307146981, -3.4222642784489077], [-8.886452461851743, -14.325391136732803])
    @show bb1 ∩ bb2 == HyperRectangle{2,Float64}([0.0, 0.0], [-12.322761768998724, -17.74765541518171])

Which seems non sensical.
Since the widths are negative it should be origin = [0,0] and widths=[0,0]?

@goretkin
Copy link
Contributor Author

Thanks for fixing it! I didn't even notice the actual numbers. It was just an example that was randomly generated in my code.

The parameterization of axis-aligned bounding boxes here is origin and widths. If instead it was lower, and upper, then negative width would correspond to lower>upper. If the intersection logic were written in those terms, I think the result would be widths .== 0. But perhaps we can postpone that for later. It wasn't the intention of opening this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants