Forums > MaxMSP

Get Speed Value of Mouse Movement

November 26, 2012 | 7:11 am

Hey Guys,

has anyone an idea how to track the speed of the mouse movement of the user?

Thanks in advance!

November 26, 2012 | 7:17 am

Speed (velocity) is distance per unit of time…so simply subtract the absolute value of the mouse position at start and end point, then divide by elapsed time. You can do it all with [mousestate] and [timer]. You could even use the delta outputs of [mousestate] to keep a running speed.

November 26, 2012 | 5:10 pm

Hey Steve, the mouse data goes from 0. to 1. x and 0. 1. y but the user can go constantly anywhere between these to values.
I have a hard understanding how to constantly scan the new speed value for the movement, if you could send a short example patch that would be amazing!

November 26, 2012 | 5:23 pm

Ok, I think I have figured out the basic function.
I get the speedvalue to a constant time interval.

The only thing left is when moving down the speed goes -.
Is there any good solution for reading all numbers out of the flonum as positiv values?

— Pasted Max Patch, click to expand. —

Edit: think this should work better

— Pasted Max Patch, click to expand. —
November 26, 2012 | 6:31 pm

I didn’t read the thread but looked at the last patch posted and it looks as if you’re trying to get positive values of delta:

— Pasted Max Patch, click to expand. —


November 26, 2012 | 7:12 pm

thanks for your reply brendan!
Just found the abs object some minutes ago, too.

I’m good to go now.

November 26, 2012 | 10:23 pm

velocity can be found by delta, basically [!- ] and [timer] is all you need.

November 27, 2012 | 8:02 am

Thank you guys, found this solution working best for me now.

— Pasted Max Patch, click to expand. —
March 4, 2013 | 1:43 pm

Hi there

I’m, currently drawing with the lcd patcher. I want to speed of the mouse movement to change the colour. Is it cool if I use your mousespeed patch? Will reference by providing a comment on the interface with a link to your posts…

Viewing 9 posts - 1 through 9 (of 9 total)

Forums > MaxMSP