-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Error: "the given sine and cosine produce an invalid rotation" #415
Comments
Hi, There is another issue for the same problem : But thanks for the gif ^^ ps : I think your problem is coming from the fact that when you're little cube is colliding with your larger cube, it may create an angle between them that is forbidden. But I must say it's quite strange that it works on the left side :/ |
Thanks for link! I think the problem might be here pub fn add_angle(&self, radians: Scalar) -> Self {
Rotation::from_sin_cos(self.sin + radians * self.cos, self.cos - radians * self.sin)
.normalize()
} This input to It can explain my case: with great impact XPBD tries to apply a big update on angles and fails. It also explains 416 as clicking in this demo makes big xpbd updates. My solution would be to implement pub fn add_angle(&self, radians: Scalar) -> Self {
Rotation::from_radians(radians) * self
} More computation but more precise. I will try it and see if it fixes the problem |
# Objective Fixes [415](#415) and [416](#416) ## Solution Old implementation was only for small angles. When impact on `RevoluteJoint` is big, XPBD [tries to apply](https://github.com/Jondolf/avian/blob/main/src/dynamics/solver/xpbd/positional_constraint.rs#L70) a big update on angles and fails Implemented `add_angle` function using precise computation of sin and cos
Some mechanical systems produce this error:
It is hard to reproduce, but I can provide a gif of one such system:
It is just two
round_rectangle
's connected with aRevoluteJoint
. It consistently errors out when the system (it represents a truck) folds on itself. But only on the right side. All other collisions in my game work fine.P.S. I totally do not exclude that this might be my fault, and i just don't see it. Will gladly provide more details/logs if needed
The text was updated successfully, but these errors were encountered: