Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix atan2 implementation to behave like Javascript Math.atan2#683

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ted-piotrowski wants to merge1 commit intogpujs:develop
base:develop
Choose a base branch
Loading
fromted-piotrowski:develop

Conversation

ted-piotrowski
Copy link

  • Previous implementation returned values in -PI/2 to PI/2 range even though Javascript returns in -PI to PI range
  • Add unit tests covering edge cases

Fixes#647

Previously the following cases failed:

Math.atan2(1, 0);Math.atan2(-1,0);Math.atan(0,-1);

According toMDNMath.atan2(y, x) returns a value between -PI and PI. According toOpenGLatan(y / x) returns a value between -PI/2 and PI/2 whileatan(y, x) returns a value between -PI and PI.

The main fix was to change theatan signature to take(y, x) instead of(y / x) and then to handle the casesMath.atan2(-1, 0),Math.atan2(1, 0),Math.atan(0, 0) because in OpenGLatan is undefined whenx = 0 but defined in Javascript.

Note:atan arguments are passedy first and thenx. This caused me some confusion at first.

TarVK, wyattis, Macil, m0ose, cascading-jox, unageek, dvhh, tlaundal, and mthh reacted with thumbs up emoji
- Previous implementation returned values in -PI/2 to PI/2 range even though Javascript returns in -PI to PI range- Add unit tests covering edge cases
@ted-piotrowski
Copy link
Author

@robertleeplummerjr I noticed you've been active on this project again. What are your thoughts on merging this fix?

stephent reacted with thumbs up emoji

@sojs-coder
Copy link

@robertleeplummerjr@ted-piotrowski any update on merging this fix?this issue I believe relies on it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

atan2 is implemented as atan(y/x) in gpu backend
2 participants
@ted-piotrowski@sojs-coder

[8]ページ先頭

©2009-2025 Movatter.jp