-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
fix Quaternion.slerp for small angles #14349
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
Conversation
Previous implementation relied on average quaternions (t=0.5) for small angles. Now uses the same approach as Quaternion.slerpFlat (threshold and lerp)
|
Be that as it may, perhaps you should add In fact, can you please check the consequence of failing to normalize in your app? |
| var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; | ||
|
|
||
| if ( Math.abs( sinHalfTheta ) < 0.001 ) { | ||
| if ( sqrSinHalfTheta <= Number.EPSILON ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Math.abs() is no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no : a square is always non negative !
do you prefer a update of this PR with a call to normalize() or a simply implementing slerp with a subcall to slerpFlat ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If cosHalfTheta = - 1.00001 due to roundoff then sqrSinHalfTheta could be negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but that is no longer an issue : negative sqrSinHalfTheta corresponds to cases where the cos is round off errors away from 1 or -1, which corresponds to tiny values of the sin, for which lerp makes sense. (it WAS however an issue as the sqrt was not guarded against negative values and would output NaN values...)
|
Thanks! |
Previous implementation relied on average quaternions (t=0.5) for small angles.
Now it uses the same approach as Quaternion.slerpFlat (same threshold and lerp interpolation).
This PR tries to address #14258 and iTowns/itowns#774