[PD] Beginners query: Calculating mouse speed

PSPunch shima at pspunch.com
Thu Nov 29 11:19:59 CET 2007


Hi,


One easy way would be to measure the number of pixels the
mouse had moved since the previous frame.

I attached an example that spits out 20 values per second,
each number is the number of pixels the cursor has travelled
since the previous frame.

This patch only measures in the horizontal direction for
simplicity. To also put the vertical axis in consideration,
you will have to get the square root of (X^2 + Y^2)

Also if the numbers change too rapidly for your needs,
you will have to add some function to smooth the value changes.


I hope this is of some help.

--
David Shimamoto



> Hi,
>  
> I have a really simple question: Does anyone know how to make a patch 
> that will give me the speed the mouse is moving?  I'm on windows and am 
> using gemmouse to get the position.
>  
> Thanks in advance!
> Rebecca.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mouse_speed.pd
Type: application/puredata
Size: 527 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20071129/c18956e5/attachment.bin>


More information about the Pd-list mailing list