如何检测旋转&缩放手势 [英] How to detect Rotate & zoom gesture

查看:60
本文介绍了如何检测旋转&缩放手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

 

我需要编码旋转&缩放手势在C#& amp; WPF并且正在考虑我将如何做到这一点。

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

简短说明:


  • 缩放 - 让两只手靠近
  • 旋转 -  用左手和右手在同一方向上进行圆圈运动。

现在我想知道如何检测这些。我的第一个想法是使用一个计时器并检查每个刻度,但有一个替代/提示。

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

推荐答案

我想到的第一件事:

First things that come to my mind:

缩放:我认为这应该是一个州。定义某种触发缩放状态的标记事件,如姿势或深度阈值,即距离kinect的距离。然后你只需跟踪左手和右手之间的距离向量,
左上角和右下角,反之亦然,并相应地缩放所选对象。此外,实施退出事件,允许用户离开缩放状态。

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...

另一种(更简单的)方法是采取一定高度(位置矢量的Y分量,再次,有一些余量)作为中性区域。左手较高,右手较低,向左旋转,左手向下,右手向上旋转
将向左旋转。 

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. 

 


这篇关于如何检测旋转&缩放手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆