Changing the subject a little bit, Shondoit's code works really well for me. However, two things:
1. How can I change some of the functions to degrees, not radians?
2. How can I make the functions and properties case-insensitive?
I've sort of figured out 2, but I don't want to edit anything because the script is so complex.