interpolate two angles

Blitz3D Forums/Blitz3D Programming/interpolate two angles

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How can I interpolate two angles, is there an easy function?

eg:
angle 1 may be 320 degrees
angle 2 may be 20 degrees

of course the formula middle=(320+20)/2 is wrong, because the result would be 170, but it should be 350

...
while I write this, I already got an idea, something like

function findApproxAngle(a1#,a2#)
 ; find min and max
 min= a1
 if a2<min then min=a2
 max=a2
 if a1>max then max=a1 

 res#=0
 dist#=max-min
 if dist<=180 then
  res=(max+min)/2
 else
  res=(max+(((360-max)+min)/2.0)) mod 360.0
 endif
 return res#
end function

got to test this right now... :)

EDIT:
ehrm, Now I got a new problem: my "angles" use values from 0.0 to 1.0 and I have 4 of them that I want to use to create a middle value (well basicly its a hue value, not an angle, but it uses like an angle a closed circle)

So how could I do this? I thnik interpolating them one by one would not return a correct value ? And it would also be pretty slow.

Any ideas?