arctan2
- Posted by Lucius Hilley <lhilley at CDC.NET> Mar 23, 1999
- 451 views
------=_NextPart_000_0006_01BE7532.731C4640 charset="iso-8859-1" Maybe the below derived information will help clear things up for you. I tested the returned values to be sure I achieved the same results. I used rand(255)-128 for X and Y to be sure I had both (+/-) values. I also noticed his math multiplied by -1 more often than needed. function arctan2(atom X, atom Y) sequence v v = repeat(0, 14)--Define space to show work. v[1] = (Y = 0) v[8] = (Y+v[1]) v[10] = (X/v[8]) v[2] = (Y != 0) v[11] = arctan(v[10])*v[2] v[3] = (Pi*.5) v[4] = (Y < 0) v[5] = (X >= 0) v[6] = (X < 0) v[9] = (v[6]-v[5]) v[7] = (-Pi*2) v[12] = v[3]*Sgn(X)*v[1] v[13] = Pi*v[4]*v[9] v[14] = v[7]*v[6] return abs(v[11]+v[12]-v[13]-v[14]) end function Lucius L. Hilley III ------=_NextPart_000_0006_01BE7532.731C4640 name="Lucius L. Hilley III.vcf"