title: Average of two angles with wrap around
body: <blockquote>
  <p><strong>Possible Duplicate:</strong><br />
  <a href="https://stackoverflow.com/questions/491738/how-do-you-calculate-the-average-of-a-set-of-angles">How do you calculate the average of a set of circular data?</a></p>
  </blockquote>
  <p>I have two angles, a=20 degrees and b=350 degrees. The average of those two angles are 185 degrees. However, if we consider that the maximum angle is 360 degrees and allows for wrap around, one could see that 5 degrees is a closer average.</p>
  <p>I'm having troubles coming up with a good formula to handle that wrap around when calculating average. Anyone got any hints?</p>
  <p>Or am I shooting myself in the foot here? Is this considered &quot;bad practice&quot; in math?</p>