Re: atan2
- Posted by Robert Craig <rds at ATTCANADA.NET> Mar 22, 1999
- 547 views
Mark Honnor writes: > i think atan2(x, y) > is sposed to return a, where sin(a) = x and cos(a) = y > anyone know how to do this? Probably it's the other way around: sin(a) = y and cos(a) = x and therefore tan(a) = sin(a)/cos(a) = y/x So a = arctan(y/x) *except* that Euphoria's arctan() function always returns an angle between -PI/2 and +PI/2, so to find out the true angle you must *also* take the sign +/- of x and y into account to see what quadrant you are in. e.g. if x is negative and y is positive the angle must be greater than PI/2 and less than PI. (There are 2PI radians in a circle, i.e. 360 degrees) If x is positive, arctan() should give you the correct result, but if x is negative you'll have to compute PI plus or minus the angle given by arctan(). I'd draw a diagram but it would be messed up by proportional fonts. Regards, Rob Craig Rapid Deployment Software http://members.aol.com/FilesEu/