Get Speed Value of Mouse Movement

Sym's icon

Hey Guys,

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

Thanks in advance!
Imbie

Steven Miller's icon

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.

Sym's icon

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!

Sym's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

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?

Max Patch
Copy patch and select New From Clipboard in Max.

Edit: think this should work better

brendan mccloskey's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi
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:

Brendan

Sym's icon

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

I'm good to go now.
Cheers,
Imbie

Roman Thilenius's icon

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

Sym's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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

Enjay's icon

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...