0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ This should probably have a cocos2d or cocos2d-iphone tag on it as the details of the question (as currently written) are very concretely specific to that API. If you can abstractly define anchorPoint/position/rotation as cocos uses them then it might help those of us who have the math side but not the API side. \$\endgroup\$ – Steven Stadnicki Aug 6 '13 at 16:57
  • \$\begingroup\$ I'd disagree (and already rejected one edit attempt that added them); I don't see how the crux of the question is cocos2d-specific, even though 'cocos2d' is mentioned several times. \$\endgroup\$ – Josh Aug 6 '13 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.