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

Relax the threshold when testing whether a quaternion is normalized #342

Merged
merged 1 commit into from Jun 6, 2019

Conversation

@nical
Copy link
Collaborator

nical commented Jun 6, 2019

Supposedly fixes #341 Unfortunately since this depends on how much numerical precision was lost from previous operations I don't have a good recipe for choosing a constant that fits all workloads. This changes it from 1e-6 to 1e-5 which I think is still small enough to easily detect cases where the quaternion is obviously not normalized while being less sensitive to precision errors than the previous threshold.


This change is Reviewable

@nical
Copy link
Collaborator Author

nical commented Jun 6, 2019

r? @kvark or anyone

@kvark
Copy link
Member

kvark commented Jun 6, 2019

Since this is clearly not an ultimate solution, did you consider just not asserting on the quaternion nomralization? Instead, we could do something like this:

if cfg!(debug_assertions) && !quat.is_normalized() {
  warn!("{:?} in function {} is not normalized", quat, "my_func");
}
@nical
Copy link
Collaborator Author

nical commented Jun 6, 2019

I am not opposed to replacing the assertion with a warning, although I would still not want to warn in cases we know to be correct (but the precision issue cause us to mislabel as not normalized). So I would still relax the normalized check.

@kvark
Copy link
Member

kvark commented Jun 6, 2019

How do you know that it's still correct if there is an arbitrary threshold involved?
Anyhow, I'm not opposed to land this.

@nical
Copy link
Collaborator Author

nical commented Jun 6, 2019

It's the same story with most assertions involving floats (unfortunately). The motivation is to catch bad cases where the quaternion isn't normalized but because of numerical precision issues there isn't an exact definition of normalized (or rather the exact requirement would never be met in practice) so we have to play with the threshold. the previous threshold was also arbitray, it just didn't appear to give us enough headroom in practice according to #341
Granted, playing with these threholds isn't very reassuring nor very scientific but 1e-5 is still quite small so I'm not worried about it.

@nical
Copy link
Collaborator Author

nical commented Jun 6, 2019

@bors-servo r=kvark

@bors-servo
Copy link
Contributor

bors-servo commented Jun 6, 2019

📌 Commit a39d21d has been approved by kvark

bors-servo added a commit that referenced this pull request Jun 6, 2019
Relax the threshold when testing whether a quaternion is normalized

Supposedly fixes #341 Unfortunately since this depends on how much numerical precision was lost from previous operations I don't have a good recipe for choosing a constant that fits all workloads. This changes it from `1e-6` to `1e-5` which I think is still small enough to easily detect cases where the quaternion is obviously not normalized while being less sensitive to precision errors than the previous threshold.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/342)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 6, 2019

Testing commit a39d21d with merge 4a24eb8...

@bors-servo
Copy link
Contributor

bors-servo commented Jun 6, 2019

☀️ Test successful - checks-travis
Approved by: kvark
Pushing 4a24eb8 to master...

@bors-servo bors-servo merged commit a39d21d into servo:master Jun 6, 2019
2 checks passed
2 checks passed
Travis CI - Pull Request Build Passed
Details
homu Test successful
Details
@nical nical deleted the nical:rotation-epsilon branch Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.