The Wayback Machine - https://web.archive.org/web/20201210170747/https://github.com/rough-stuff/rough/issues/166
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

`atan` versus `atan2` #166

Open
SheetJSDev opened this issue May 29, 2020 · 2 comments
Open

`atan` versus `atan2` #166

SheetJSDev opened this issue May 29, 2020 · 2 comments

Comments

@SheetJSDev
Copy link

@SheetJSDev SheetJSDev commented May 29, 2020

Both dashed and zigzag use Math.atan:

      const alpha = Math.atan((p2[1] - p1[1]) / (p2[0] - p1[0]));

It would seem that a generated vertical line would cause errors. Is there a reason for preferring this over the safer atan2 alternative?

      const alpha = Math.atan2((p2[1] - p1[1]), (p2[0] - p1[0]));
@pshihn
Copy link
Collaborator

@pshihn pshihn commented May 29, 2020

You're correct atan2 would be the better option here, because I don't check for the denominator to be nonzero.

@pshihn
Copy link
Collaborator

@pshihn pshihn commented May 29, 2020

I think I have been getting away with it because it is unlikely in zigzag lines, and the randomness in the dashed lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.