How to detect Rotate & zoom gesture

• Question

• Hi

I need to code the rotate & zoom gesture in C# & WPF and was thinking how I was going to do it.

Short explanation :

• Zoom - Bringing two hands closer to each other or move them away
• Rotate - Making a circlemovement with my left and right hand in the same direction.

Now I was wondering how to detect these. My first thought was by using a Timer and checking on each tick but has someone an alternative/tips.

Tom

Friday, December 9, 2011 4:45 PM

All replies

• First things that come to my mind:

Zoom: I think this should be a state. Define some sort of a marker event that triggers the zooming state, like a pose or a depth threshold, i.e. the distance from the kinect. Then you just keep track of the distance vector between the left and right hands, top-left and right-bottom or vice-versa, and zoom the selected object accordingly. Also, implement an exit event, allowing the user to leave the zooming state.

Rotate: calculate the distance between the left and right hand, halfway is your centre of rotation. From that point on it's just a matter of some simple 3rd grade trigonometry to calculate the rotation angle. Make sure to put in some slack, since it will be virtually impossible for a user to mimic a perfect circle...

An alternative (easier) approach would be to take a certain height (Y-component of the position vector, again, with some margin) as neutral zone. Left hand higher and right hand lower would be rotation to the right, left hand lower and right hand higher would be rotation to the left.

• Edited by Friday, December 9, 2011 7:21 PM typo
• Proposed as answer by Sunday, May 6, 2012 12:31 PM
Friday, December 9, 2011 7:19 PM