gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > SWI library help

#9287 - slip - Fri Aug 01, 2003 12:36 am

I posted in another thread asking this but the thread was about linking and I havn't got a reply.
I'm not sure about the ArcTan and ArcTan2 functions, would someone be able to explain them to me? I understand what ArcTan is but I don't get the results I expect when calling them. I'm asuming (for ArcTan2) the x is the run and the y is the rise, hence angle = arctan(y/x); is this wrong?
thanks
_________________
[url="http://www.ice-d.com"]www.ice-d.com[/url]

#9312 - tom - Fri Aug 01, 2003 11:00 am

http://www.work.de/nocash/gbatek.htm

#9315 - slip - Fri Aug 01, 2003 12:01 pm

SWI 9 - ArcTan
Calculates the arc tangent.

r0 Tan, 16bit (1bit sign, 1bit integral part, 14bit decimal part)

Return:

r0 "-PI/2<THETA/<PI/2" in a range of C000h-4000h.

Note: there is a problem in accuracy with "THETA<-PI/4, PI/4<THETA".

SWI 10 (0Ah) - ArcTan2
Calculates the arc tangent after correction processing.
Use this in normal situations.

r0 X, 16bit (1bit sign, 1bit integral part, 14bit decimal part)
r1 Y, 16bit (1bit sign, 1bit integral part, 14bit decimal part)

Return:

r0 0000h-FFFFh for 0<=THETA<2PI.


Thats what the gbatek says. after looking at ia bit this is what I worked out, for Arctan r0 will return the result of theta between -PI/2 and PI/2, and in a value between C000h and 4000h, C000h representing -PI/2? and 4000h representing PI/2?
Similarly Theta is between 0 and 2PI in a value range of 0000h to FFFFh for ArcTan2?

ok sweet... I just checked it =) thanks a lot
_________________
[url="http://www.ice-d.com"]www.ice-d.com[/url]