Skip to content

Commit

Permalink
Improve hyperrectangle.Disjoint performance
Browse files Browse the repository at this point in the history
  • Loading branch information
minkezhang committed Dec 6, 2022
1 parent bb54474 commit e7eb122
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions nd/hyperrectangle/hyperrectangle.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,20 @@ func Disjoint(r R, s R) bool {

rmin, rmax := r.Min(), r.Max()
smin, smax := s.Min(), s.Max()
for i := vector.D(0); i < rmin.Dimension(); i++ {
if rmax[i] < smin[i] || smax[i] < rmin[i] {
k := rmin.Dimension()

for i := vector.D(0); i < k; i++ {
if rmax[i] < smin[i] {
return true
}
}

for i := vector.D(0); i < k; i++ {
if smax[i] < rmin[i] {
return true
}
}

return false
}

Expand Down

0 comments on commit e7eb122

Please sign in to comment.