Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty rect behavior by reverting 84d12654104e783011f24267145fb6bfccd2a30e #181

Closed

Conversation

michaelkirk
Copy link
Member

@michaelkirk michaelkirk commented Nov 5, 2024

  • I agree to follow the project's code of conduct.
  • I added an entry to rstar/CHANGELOG.md if knowledge of this change could be valuable to users.

reverts #162

I'm not really a regular rstar contributor, and I don't know that a simple reversion is the best way to solve this problem.

Failing test is
```
assertion `left == right` failed
  left: AABB { lower: [-0.5, -0.5], upper: [-0.5, -0.5] }
 right: AABB { lower: [-0.5, -0.5], upper: [0.0, 0.0] }
```
…choosing a more tame value for AABB::new_empty (georust#162)"

This reverts commit 84d1265.
let subject = empty.merged(&other);
assert_eq!(other, subject);

let other = AABB::from_corners([-0.5, -0.5], [-0.5, -0.5]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other cases pass, but this one fails with:

```
assertion `left == right` failed
  left: AABB { lower: [-0.5, -0.5], upper: [-0.5, -0.5] }
 right: AABB { lower: [-0.5, -0.5], upper: [0.0, 0.0] }
```

@michaelkirk
Copy link
Member Author

A more rigorous solution would probably make use of an explicit empty state, e.g. Option<AABB>::None

@michaelkirk
Copy link
Member Author

I guess we can infer empty based on the "nonsense" state of min > max, so maybe can solve the root issue by adding logic without changing the type signatures.

@adamreichold
Copy link
Member

I don't know that a simple reversion is the best way to solve this problem.

I don't think we can just revert it as now the removed test case test_locate_within_distance_on_empty_tree would panic again. There also was quite a bit of boy scouting in that commit which we should not loose in any case.

I guess we can infer empty based on the "nonsense" state of min > max, so maybe can solve the root issue by adding logic without changing the type signatures.

There are certainly different options, but I am also wary of making merged more expensive to compute. I wonder if switch to a "(centre, diameter)" representation of the AABB as is done for periodic boundary conditions might be a more fundamental change to make the empty state more tame, i.e. represented by "diameter = 0".

@adamreichold
Copy link
Member

adamreichold commented Nov 5, 2024

One option I see is to revert the empty representation back to "(max_value, min_value)" but change the Point trait impls to use only saturating arithmetic.

@michaelkirk michaelkirk mentioned this pull request Nov 5, 2024
1 task
@michaelkirk
Copy link
Member Author

I'm happy to have you take this in any direction - but I think getting the wrong answer is almost always a bigger concern than getting a slightly slower answer.

@michaelkirk
Copy link
Member Author

Unfortunately, I'm out of time for today, but please feel free to solve the problem with or without my particular solution.

@adamreichold
Copy link
Member

One option I see is to revert the empty representation back to "(max_value, min_value)" but change the Point trait impls to use only saturating arithmetic.

Sadly, I see no viable option to wire this through our trait bounds ending in RTreeNum expect detaching from the Num-based hierarchy. So I do think the max/min representation is indeed superior, but I would prefer a more targeted revert and alternative fix for #161 as proposed in #184.

@michaelkirk
Copy link
Member Author

superseded by #184

@michaelkirk michaelkirk closed this Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants