S
Sowen Zhang
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
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