-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fixed add_angle #421
Fixed add_angle #421
Conversation
Although I get that the linearized implementation of Maybe then add another function |
The existing implementation was based on Solver2D's We should not compute it by computing We should just do the normalization in an optimized way before using /// Adds the given counterclockiwise angle in radians to the [`Rotation`].
#[inline]
#[must_use]
pub fn add_angle(&self, radians: Scalar) -> Self {
let (sin, cos) = (self.sin + radians * self.cos, self.cos - radians * self.sin);
let magnitude_squared = sin * sin + cos * cos;
let magnitude_recip = if magnitude_squared > 0.0 {
magnitude_squared.sqrt().recip()
} else {
0.0
};
Rotation::from_sin_cos(sin * magnitude_recip, cos * magnitude_recip)
} |
Thanks! I changed to your implementation and checked that it works |
@Khanoto I think it is identical to what I initially proposed, just more verbose |
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.
Thanks!
Objective
Fixes 415 and 416
Solution
Old implementation was only for small angles. When impact on
RevoluteJoint
is big, XPBD tries to apply a big update on angles and failsImplemented
add_angle
function using precise computation of sin and cos