Trying to create a way for smooth rotation, but still no success

Hi all,

I am trying to make a smooth rotation of touchscreen recognized object - it has some rotation jitter, so I am using the same function as for the movement smoothing :
rotationease += (rotation - rotationease) * 0.05;

but I have an issue - then I am rotating the object putted on touchscreen(special foil, witch is capable to track position of special objects placed on screen and rotation of those objects), I am getting values from 0 to 359 - angle of object center rotation, so then I am rotating that object and I am passing the 359 to 0, or 0 to 359 degrees my function starts to move the object in opposite way, is there are any correct way of doing this?

Thanks in advanced!

The main idea is to use intrinsic rotations. Where the axis of the object to rotate is changed after applying each rotation. That way you will not have the 360 to 0 jumps.

I suggest you use ofNode.
This sort of rotation issues are solved by using this class.
Post like this one may help explain the concept behind ofNode:

And also search on the forum for “camera rotation” “quaternion rotation”.

I hope that helps!

Thanks for your replies!

acctually I was using simple ofLerp(); - and that function was interpolating my values in the wrong way, so found ofLerpDegrees() - and now it works! I was using a wrong function for the interpolation :(.

You should also take into account the framerate when moving/rotating objects.

If you do not take the framerate into account, when running in a slow pc (less framerate) the object will move slower.

You should multiply by ofGetLastFrameTime() so the movement is in units/second

1 Like