The direction isn't given by Pythgoras' theorem, rather use the definition of tan(x). The Math class has a couple of inverse tan methods that are useful.

---

I'm not sure this has anything to...