-
-
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
Vector2 normalize (division with zero) #44
Comments
SolutionMy partner and I have changed to use See Also |
System.Numerics doesn't check for zero too, SharpDx does. I solved it within the Vector2 class in farseer. just wanted to let @Genbox know, in case he wants to fix it for Velcro :) |
@bQvle I don't mean this as a statement but as a sincere question: instead of comparing I ask because if |
Actually I have no idea. But since zero is the only Vector that will result in zero "length/distanceSquare" I just wanted to "return" before even calculating the length. But I think that no matter how you do it, it shouldn't change much in the big scope, performance wise. Edit:
|
I'm currently using Farseer and had some issues with contact solving. I figured the issue might still be with Velcro.
Normalize return a Vector2(X=NaN, Y=NaN) if you try to normalize a zero vector.
because factor will be zero so
1f / (float)Math.Sqrt(factor)
will result in Infinitythe solver does something like Normalize(Position1 - Position2) so if the two positions is identical we get the NaN vector which crashes the physics.
Hopes this helps :)
I solved it this way
The text was updated successfully, but these errors were encountered: