Ok, since I have spent endless hours on this, i know this by my heart.

atan2(deltay/dealtax)

(my example)so you have the static position lets say the position of your character and then you take the mouseX cordinate - positionY and then divide it by mouseY-positionY and now you gots the polar angle information.

It works the same way with anything. Just remember atan2(change in x/ change in y)

I suggest using atan2 since atan1 is not good for this situation. It will "flip" on the negative axis.

Its quite fast. I don't think you can optimize the math itself, the things that matter are *where* you use it and *how*. I haven't really optimized it, but I think speed wise you should be quite okay even with that.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org