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.

Coding > ArcSin & ArcCos

#27426 - DiscoStew - Tue Oct 12, 2004 9:27 pm

Does anyone know a fast way of doing these on the GBA, or even a substitute for those algorithms? Just wanted to know because I want to get the angles (2pi = 512) from one point to another. I don't need exact precision, but something really fast if possible.
_________________
DS - It's all about DiscoStew

#27428 - poslundc - Tue Oct 12, 2004 10:01 pm

Are you sure you don't want arctangent? This is the trig function most often used to determine the angle between two cartesian points. In fact, the atan2 routine was invented to avoid having to divide before obtaining the result.

The GBA BIOS has an atan2 routine in it, but while I haven't looked at it I imagine it could be improved upon. Try searching the forum for atan2; it has been discussed in a number of threads.

Dan.

#27429 - ecurtz - Tue Oct 12, 2004 10:02 pm

Do you actually have the sin/cos (which would mean you've already calculated the distance, I think) or do you actually want the atan? If you have the sin/cos you can probably do some sort of ugly and complex, but fast, stepped table. If you actually want the atan I posted my very first assembly routine for atan2 a few weeks ago - you could try it out.

atan2

#27431 - DiscoStew - Tue Oct 12, 2004 10:35 pm

Can someone just shoot me in the head? BANG! BANG!

I got so caught up in my programming that I completely forgot about using atan. Not only that, but I was involved in the discussion about atan and cordic rotators with ecurtz. I should have thought before posting. I was just so excited with the accomplishments I had done in my programming that I wasn't thinking. Thankfully you two pointed me back in the direction I needed to go. thx
_________________
DS - It's all about DiscoStew

#27438 - ecurtz - Tue Oct 12, 2004 11:38 pm

Oh yeah...

I guess I should have noticed as well. That's what I get for trying to think about anything else while I'm at work. Let me know if you have any trouble with the code - it hasn't really been tested.

- eli