Skip to content
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

[raymath] Angle returned by Vector2Angle() isn't correct #2172

Closed
Knose1 opened this issue Nov 25, 2021 · 3 comments
Closed

[raymath] Angle returned by Vector2Angle() isn't correct #2172

Knose1 opened this issue Nov 25, 2021 · 3 comments

Comments

@Knose1
Copy link

Knose1 commented Nov 25, 2021

Like this post say, the angle isn't correct.
I used to multiply one of the vectors by 1000 when calling the function to avoid that problem.
The problem came back with Vector2Angle({0,1}, {0,1000}) the result shall be 0 but the returned value is 90

I fixed it by replacing this line

float result = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/PI);

By this one in the raymath.h of my project

float result = atan2(v2.y, v2.x) - atan2(v1.y, v1.x) * (180.0f / PI);
@raysan5 raysan5 changed the title Angles returned by raymath.Vector2Angle isn't correct [raymath] Angle returned by Vector2Angle() isn't correct Nov 27, 2021
@schveiguy
Copy link
Contributor

This should be closed now.

@raysan5 raysan5 closed this as completed Dec 7, 2021
@raysan5
Copy link
Owner

raysan5 commented Jan 15, 2022

@leowribeiro Note that Vector2Angle() returns angle in radians so you can not operate with -180 directly.

@raysan5
Copy link
Owner

raysan5 commented Jan 15, 2022

@leowribeiro that's because you are using an old version of raylib. That was an issue that was fixed some time ago. Now Vector2Angle() return radians, not degrees.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants