I have a unit in a game which is pointing in a particular direction; when it turns to another direction it should take the shortest turn available. The scheme starts at a particular angle, and requires a given angle to lerp (linear interpolate) towards.
For example, lerping from 10 degrees to 350 degrees should calculate a target angle of -10. Conversely lerping from 350 to 10 should calculate an end end of 370 degrees.
What algorithm can calculate these required end values?
EDIT:: There seems to be some confusion over what I need
I'm using linear interpolation to calculate angles over time. So, if I want to get from 10 to 20 then the end value needs to be 20, then I shall interpolate from 10 to 20 and turn right. However, similarly if I want to go from 20 to 10, then interpolating from 20 to 10 will go anticlockwise, this is fine too. The problem is when the turn is more than 180 in the clockwise direction, to go from 270 to 80 (210 degrees) needs to turn clockwise, direct interpolation from 270 to 80 will go anticlockwise, I need to interpolate from 270 to 420 (360+80), which will go anticlockwise.