Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

Any idea how to track the mouse moving speed?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sowen Zhang - 07 Jan 2008 16:11 GMT
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.

Signature

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

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

Robbe Morris - [MVP] C# - 07 Jan 2008 16:49 GMT
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/dotnetcompactframework_capture_signature_to_
file.asp


Signature

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

> Hi,
>
[quoted text clipped - 25 lines]
>
> I hope it makes sense, any help will be appreciated.
Kevin Spencer - 08 Jan 2008 12:57 GMT
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.

Signature

HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

> Hi,
>
[quoted text clipped - 25 lines]
>
> I hope it makes sense, any help will be appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.