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

Double check atan2 usage #22

Open
bmorris3 opened this issue Nov 14, 2016 · 5 comments
Open

Double check atan2 usage #22

bmorris3 opened this issue Nov 14, 2016 · 5 comments
Labels

Comments

@bmorris3
Copy link
Owner

Let's double check that we're using atan2 efficiently everywhere.

@LaurentRDC
Copy link

Is arctan significantly faster than arctan2?

@bmorris3
Copy link
Owner Author

I don't know, @jkentwallace had opinions though.

@jkentwallace
Copy link

LaurentRDC and bmorris3, I was concerned not so much about efficiency. Reading through Emilio's original writeup, (in which he used Matlab) he had a comment about using atan(z) vs atan2(y,x). Problem is that atan only goes from -p/2 to +pi/2, whereas atan2 goes from -pi to pi. (That's because in the ratio of x/y = z, not knowing the sign of x and/or y precludes getting the angle in the correct quadrant.)

Quick question: does python support a function called Arg[a + i b]? Arg[] will return the phase angle of a complex number.

@bmorris3
Copy link
Owner Author

bmorris3 commented Nov 23, 2016

@jkentwallace I believe what you're looking for is implemented in numpy.angle, which returns

the counterclockwise angle from the positive real axis on the complex plane

@jkentwallace
Copy link

Yes! That's it. Basically, this is the same as atan2. However, for those who might be lazy - ahem - you don't need to do atan2[imaginary,real], but just np.angle([]) instead.

Just a thought...

@bmorris3 bmorris3 changed the title Efficiency: double check atan2 usage Double check atan2 usage Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants