-
Get a monthly update on best practices for delivering successful software.
Math is fun!
I never understand why people hate math so much. I guess I hated history & literature as much as fans of those subjects hate math. I remember always hearing that you would never use math in real life, which is just not true. I use it all the time, and this post is about one of those times.
A coworker of mine is creating an iPhone app, and whenever he encounters tricky math, pulls me in, as he realizes I have fun with it. His problem was:
given two points on a circle, find the shortest number of degrees between them
So given points at 4° and 20°, the result should be 16°. Seems easy enough, except a few fun scenarios. 356° and 4° results in 8°, and 360° and 0° are the same.
I thought through it, and my original approach was going to figure out what quadrant each angle was in, and then do some calculations to adjust the distance to keep the answer <= 180°. But then I realized that was going to be nasty, and then I remembered our good friend the radian.
Continue reading »