So,
We had this problem in multiple run times, (C and Unity). The problem is the bones would rotate around multiple times, and get worse and worse. we are talking legs that would roate 360' 5 times. Worth noting we turn off iks and move and rotate bones >360' .
We where stuck on this for a while, until we outputted the bone's rotation. The bones do not wrap between 0 and 360 (or -180 and 180 as you have it)
In the rotate timeline:
amount = frames[frameIndex + FRAME_VALUE] - prevFrameValue;
while (amount > 180)
amount -= 360;
while (amount < -180)
amount += 360;
amount = bone.data.rotation + (prevFrameValue + amount * percent) - bone.rotation;
while (amount > 180)
amount -= 360;
while (amount < -180)
amount += 360;
bone.rotation += amount * alpha;
This is attempting to wrap it, but it does not do it after the bone.rotation += amount * alpha;
meanng it can escape the wrap.
after wrapping bone.rotation at the end of the function the ik spinning does not occur