-
Notifications
You must be signed in to change notification settings - Fork 438
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
Weird results with angleBetween (FlxAngle VS FlxPoint) #2037
Comments
Regarding the "0 is pointing to the up direction" / the |
Regarding the actual issue, Would also be interesting to check if AS3 Flixel's version of this method has the same issue, IIRC we made some fixes to it at some point. |
Would you rather have a fast atan2 or just the function itself? I can look into the former. |
I guess it depends on how much faster than atan2 the function currently really is. If there is no big performance benefit, we might as well use the more accurate version. However, I have a feeling it will make a difference. |
Same kind of thing as fast sine? |
Not sure what you mean. |
Maybe we can let the user to choose between both with a fast:Bool. But I would always choose the precise result, because 2.47° of error is HUGE... |
That would be a huge hack / not an option. We need to fix it properly. :) |
Like how the |
I tried both of these. They're either slower or 4 percent faster, and that's without checking for edge cases such as Everything was tested inlined and not, cpp debug. |
Code snippet reproducing the issue:
Observed behavior:
FlxAngle.angleBetween(SpriteA:FlxSprite, SpriteB:FlxSprite, AsDegrees:Bool = false):Float returns 32.78428086586915, which is correct.
FlxPoint.angleBetween(point:FlxPoint):Float returns 35.25773195876289, which is wrong.
Expected behavior:
I'm calculating the angle between two FlxPoint instead of two (created for the occasion) FlxSprite in order to gain some speed. I expect the results to be the same...
And by the way, I'm wondering why
FlxAngle.angleBetweenPoint()
gives the angle between an FlxSprite and an FlxPoint, and not between two FlxPoint... >:(If you need more details, here's the discussion at haxeflixel forum that led me here.
The text was updated successfully, but these errors were encountered: