Prediction and angles

BlitzMax Forums/BlitzMax Programming/Prediction and angles

nawi(Posted 2008) [#1]
I'm using prediction in a network game, everytime a packet arrives it calculates the averate angle rate by dividing the angle difference by the duration of frames. This works fine for angles like 30 to 50, but when there happens to be a 359 -> 2 angle change, it of course calculates it to be something like 357/frames, even though the correct prediction is 3/frames. Is there better fix to this than to just limit the max angle difference?


Gabriel(Posted 2008) [#2]
Use quaternions, on which you can use spherical interpolation, and the issue will not arise.


dynaman(Posted 2008) [#3]
Quick idea, if it is greater then 180 then subtract 360 from the result. In this case it would be

357 > 180 so
360 - 357 = 3

I'm pretty sure I'm missing something important though...


xlsior(Posted 2008) [#4]
If there is more than 180 degrees difference between the angles, add 360 to the smallest value?


Warpy(Posted 2008) [#5]
function nicedifference#(an1#,an2#)
  an=(an2-an1) mod 360
  if an < -180 then an=an+360
  if an > 180 then an=an-360
  return an
end function



dynaman(Posted 2008) [#6]
Yup, Xlsior and Warpy got the part I was missing.


nawi(Posted 2008) [#7]
Thanks, that seems to work.