PC Review


Reply
Thread Tools Rate Thread

Any idea how to track the mouse moving speed?

 
 
Sowen Zhang
Guest
Posts: n/a
 
      7th Jan 2008
Hi,

Suppose a user presses the mouse on an object, then drags the object around.
When the user releases the mouse, I want to tell what's the average speed of
the whole movement. Any idea how to calculate that?

Because the user can drag the object to any direction, it could go right,
then go left, then go up, go right, go left, ect. And the speed of each
section varies, I can't use the starting point and ending point as the
distance then divide by the time comsuned.

What I am doing is, in each MouseMove event, I store the point (section). I
calculate the average speed for every two sections as follows:

d1 = p2-p1;
v1 = d1 / 2; // 2 means 2 frames
d2 = p3-p2;
v2 = d2 / 2;

v = 2 / (1/v1 + 1/v2); // mean

Assume every MouseMove happens evenly. In fact, I am not going to track
mouse but finger. In that case, there is no FingerMove event, but only a
camera frame update event, every frame is updated constantly.

Now I am using a harmonic mean to compute the average speed for every two
sections, but the result doesn't look right.

I hope it makes sense, any help will be appreciated.


--
Best Regards!
Hong.
---------------------------
Image Processing and Watermark components for .NET
http://www.ImageComponent.NET

Personal Entertainment Shareware and Freeware
http://www.angGoGo.com


 
Reply With Quote
 
 
 
 
Robbe Morris - [MVP] C#
Guest
Posts: n/a
 
      7th Jan 2008
Well, this can help. It is a signature app but it keeps track
of position coordinates. You'd expand your tracking
to track the time for each movement.

http://www.eggheadcafe.com/articles/...re_to_file.asp

--
Robbe Morris [Microsoft MVP - Visual C#]
AdvancedXL Server, Designer, and Data Analyzer
Convert cell ranges in Excel to rule driven web surveys
Free download: http://www.equalssolved.com/default.aspx




"Sowen Zhang" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Suppose a user presses the mouse on an object, then drags the object
> around. When the user releases the mouse, I want to tell what's the
> average speed of the whole movement. Any idea how to calculate that?
>
> Because the user can drag the object to any direction, it could go right,
> then go left, then go up, go right, go left, ect. And the speed of each
> section varies, I can't use the starting point and ending point as the
> distance then divide by the time comsuned.
>
> What I am doing is, in each MouseMove event, I store the point (section).
> I calculate the average speed for every two sections as follows:
>
> d1 = p2-p1;
> v1 = d1 / 2; // 2 means 2 frames
> d2 = p3-p2;
> v2 = d2 / 2;
>
> v = 2 / (1/v1 + 1/v2); // mean
>
> Assume every MouseMove happens evenly. In fact, I am not going to track
> mouse but finger. In that case, there is no FingerMove event, but only a
> camera frame update event, every frame is updated constantly.
>
> Now I am using a harmonic mean to compute the average speed for every two
> sections, but the result doesn't look right.
>
> I hope it makes sense, any help will be appreciated.
>
>
> --
> Best Regards!
> Hong.
> ---------------------------
> Image Processing and Watermark components for .NET
> http://www.ImageComponent.NET
>
> Personal Entertainment Shareware and Freeware
> http://www.angGoGo.com
>


 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      8th Jan 2008
Speed = distance / time.

Therefore, you need to know the time difference to calculate the speed. This
means that every time you sample a distance, you must know the time interval
of the sample. I hope your assumption is correct!

As for your math, you can average 2 values by dividing by 2, only if the 2
values represent the same thing. So, if 2 values represent the same time
interval, the average is accurate. But if one value represents a cumulative
time interval, and the other represents a single time interval, the average
is inaccurate. Each time you average 2 values, the result represents a
cumulative time interval. The average of 10 distances over 10 ms has more
weight than the value of 1 distance for 1 ms, by a factor of 10.


--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"Sowen Zhang" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Suppose a user presses the mouse on an object, then drags the object
> around. When the user releases the mouse, I want to tell what's the
> average speed of the whole movement. Any idea how to calculate that?
>
> Because the user can drag the object to any direction, it could go right,
> then go left, then go up, go right, go left, ect. And the speed of each
> section varies, I can't use the starting point and ending point as the
> distance then divide by the time comsuned.
>
> What I am doing is, in each MouseMove event, I store the point (section).
> I calculate the average speed for every two sections as follows:
>
> d1 = p2-p1;
> v1 = d1 / 2; // 2 means 2 frames
> d2 = p3-p2;
> v2 = d2 / 2;
>
> v = 2 / (1/v1 + 1/v2); // mean
>
> Assume every MouseMove happens evenly. In fact, I am not going to track
> mouse but finger. In that case, there is no FingerMove event, but only a
> camera frame update event, every frame is updated constantly.
>
> Now I am using a harmonic mean to compute the average speed for every two
> sections, but the result doesn't look right.
>
> I hope it makes sense, any help will be appreciated.
>
>
> --
> Best Regards!
> Hong.
> ---------------------------
> Image Processing and Watermark components for .NET
> http://www.ImageComponent.NET
>
> Personal Entertainment Shareware and Freeware
> http://www.angGoGo.com
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse DPI and pointer speed at the Mouse Properties. RealCat Windows Vista General Discussion 0 16th Oct 2008 06:09 AM
As soon I down load SP2 my mouse stop working. Any idea...thanks =?Utf-8?B?QW5pcyBLaGFu?= Microsoft Windows 2000 Enable 0 5th Jun 2007 04:20 AM
Moving my projects to asp.net beta 2. Good idea? jensen bredal Microsoft ASP .NET 4 27th Apr 2005 02:32 PM
Idea: Proxy class to limit download speed. Utilize bandwidth efficiently Martin Raychev Microsoft Dot NET 0 26th Apr 2005 05:45 PM
mouse scroll speed goes warp speed in older game =?Utf-8?B?VE5pc3NlblQ=?= Windows XP Help 0 26th Oct 2004 08:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:52 PM.