I've got an Cocos2d layer which anchorPoint, position and rotation (according to http://www.qcmat.com/understanding-anchorpoint-in-cocos2d/) vary when the pinch zoom gestures. Everything works fine.
I've also added smoothness, so the layer will stop gently when it is 'thrown away' by a one finger gesture. The layer will also stop zooming in a gentle way when the 2nd finger is released (if it is released during movement). I've also succeeded with smooth rotation, so the layer continues rotation around touch1 when touch2 is released (if touch2 described an orbit around1).
My problem is that the rotation functionality is not generic. For instance, I've problems with the case where touch1 and touch2 is on the opposite side of the center point, and follows a path on a circle circumference. The layer will then rotate around the centre point. That works fine until the fingers are released, but my algorithm is not robust enough to find out that it shall continue the rotation around said center point.
Question: How do I in a generic way find the point of rotation, and the rotation speed around that point, for a layer using sampled data containing anchorPoint, position and rotation for the last 0.1(?) seconds?
The example above is only one use case. You can also think about the case where touch1 follows the arc from (1, 0) to (0, 1) meanwhile touch2 follows the arc from (2, 0) to (0, 2). That will result in a rotation around (0, 0). I want to detect that movement, and continue the rotation around (0, 0) if the touches are released at the same time.