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

Fix Vector2Angle() #2829

Merged
merged 1 commit into from
Dec 13, 2022
Merged

Fix Vector2Angle() #2829

merged 1 commit into from
Dec 13, 2022

Conversation

AlxHnr
Copy link
Contributor

@AlxHnr AlxHnr commented Dec 13, 2022

This fix ensures that the angle can be computed for all normalized vectors. But we still return negative values, which is not correct, but is required to maintain backwards compatibility.

Fixes #2828

With this fix the function still returns negative values, which is
wrong. But we keep this behaviour to maintain backwards compatibility.
@AlxHnr AlxHnr changed the title Fix #2828 Fix Vector2Angle() Dec 13, 2022
@raysan5 raysan5 merged commit 3419aef into raysan5:master Dec 13, 2022
@raysan5
Copy link
Owner

raysan5 commented Dec 13, 2022

@AlxHnr Thanks for the review, actually I think this function has already been reviewed several times...

@planetis-m
Copy link
Contributor

planetis-m commented Dec 13, 2022

The fact that it only works with normalized vectors is not documented anywhere. Can we get the proper fix? Even if it breaks compatibility? acos(clamp(dot(v1, v2), -1, 1))

@AlxHnr
Copy link
Contributor Author

AlxHnr commented Dec 14, 2022

You are right, it would be better if we would support everything we throw at it. Usually it just needs an extra division and thats it. I'll reopen my original ticket.
Edit: Can't reopen my ticket 🤷‍♂️

@planetis-m planetis-m mentioned this pull request Dec 15, 2022
futureapricot pushed a commit to futureapricot/raylib that referenced this pull request Oct 4, 2023
With this fix the function still returns negative values, which is
wrong. But we keep this behaviour to maintain backwards compatibility.
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

Successfully merging this pull request may close these issues.

[raymath] Vector2Angle() produces invalid results for some vectors
3 participants