找到鼠标在C#中的速度 [英] Find the velocity of the mouse in C#

查看:164
本文介绍了找到鼠标在C#中的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何可以找到鼠标的瞬间垂直速度在 确切的<强/>的时刻,释放鼠标?我有用户在拖动一个自定义的控制,当他们释放我需要知道这些信息,所以我可以继续使用他们的速度...



的垂直分量被拖动对象

因此,举例来说,如果他们在一个角度拖动,使用触发来确定垂直速度,然后使用该..



我不能只是做距离随着时间的推移,因为鼠标可以以不规则的速度移动,并且这将不能代表正确的速度在所有



我想可能有的触发之间的特定时间间隔MouseMove事件,我可以用,但林不知道。


解决方案

我怎样才能找到瞬时垂直鼠标在鼠标被释放的确切时刻的速度是多少?




您不能。由于芝诺明确世纪前提出,速度只有经过一段时间的意义。如果我不得不这样做,我可能会使用加权移动平均线,所以(比如)我计算每个在过去的5鼠标移动消息的距离/时间,但它们的重要性腐烂随着时间的推移。例如,我可能会被乘以1最近一次,下一次回来2.8,下一个回来。6,等等。这样,如果(例如),他们碰巧减速(或加速),就像他们释放按钮的运动,你仍然得到的是什么,他们的一个合理的近似是的做只是在这之前。


How can i find the instantaneous vertical speed of the mouse at the exact moment that the mouse is released? i have the users dragging over a custom control and when they release i need to know this information so i can continue the object they were dragging using the vertical component of the velocity...

so for instance, if they were dragging at an angle, use trig to determine the vertical speed and then use that..

i cant just do distance over time, because the mouse can be moved at irregular speeds and this will not represent the correct velocity at all.

I was thinking that there might be a specific interval between the triggers of MouseMove that i could use, but im not sure.

解决方案

How can i find the instantaneous vertical speed of the mouse at the exact moment that the mouse is released?

You can't. As Zeno made clear centuries ago, speed is only meaningful over a period of time. If I had to do it, I'd probably use a weighted moving average, so (for example) I computed the distance/time for each of the last 5 mouse movement messages, but their importance "decayed" over time. For example, I might multiply the most recent by 1, the next one back by .8, the next one back by .6, and so on. This way if (for example) they happen to slow down (or speed up) the movement just as they release the button, you still get a reasonable approximation of what they were doing just prior to that.

这篇关于找到鼠标在C#中的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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