Hi SESI,
After scratching my head for quite some time trying to figure out what was going on, I realized that the parameters to the atan() function should be the reverse of what is given in the documentation.
What is given is atan(x,y), and what it actually expects is atan(y,x), as in the C implementation of atan2().
Thanks.
Doc BUG: atan() and atan2()
3341 2 0- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
- ben simons
- Member
- 387 posts
- Joined: July 2005
- Offline
- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
ben simons
Huh,
It seems to be working ok here?
-> echo `atan2(1,1)`
45
Hi Ben,
Thanks for checking, but I was referring to the VEX functions (but I didn't make that clear, sorry), which are documented as follows:
float atan(float x, y), atan2( float x, y)
and should really be
float atan(float y, x), atan2( float y ,x)
On the other hand, the hscript function, which is the one you tried, is documented properly:
/ -> exhelp atan2
float atan2 (float y, float x)
Compute the arctangent of y/x. <…snip…>
and can be checked easily:
/ -> echo “`atan(4/3)` should be the same as `atan2(4,3)` assuming params are atan2(y,x)”
53.1301 should be the same as 53.1301 assuming params are atan2(y,x)
Cheers!
-
- Quick Links