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?
Prediction and angles
BlitzMax Forums/BlitzMax Programming/Prediction and angles Use quaternions, on which you can use spherical interpolation, and the issue will not arise.
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...
357 > 180 so
360 - 357 = 3
I'm pretty sure I'm missing something important though...
If there is more than 180 degrees difference between the angles, add 360 to the smallest value?
Yup, Xlsior and Warpy got the part I was missing.
Thanks, that seems to work.