Doc BUG: atan() and atan2()

   3341   2   0
User Avatar
Member
941 posts
Joined: July 2005
Offline
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.
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
387 posts
Joined: July 2005
Offline
Huh,

It seems to be working ok here?

-> echo `atan2(1,1)`
45


Maybe that's a special case™? :^) b.
''You're always doing this: reducing it to science. Why can't it be real?'' – Jackie Tyler
User Avatar
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!
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
  • Quick Links