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.
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@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, Rebecca Schatz hat gesagt: // Rebecca Schatz wrote:
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.
A handy idiom to get the difference between a value's current and its previous position is a cross-wired trigger-substraction construct like this:
[t f f]
\ /
x
/
[- ]
If you connect for example a slider on top of that, you can see how fast the slider was moved. With Gem you can use the values coming out of gemmouse inserted into this idiom. You can also drive the whole thing with a [metro] or from the [gemhead] while storing the mouse coordinate into a [float]'s right inlet like:
[gemhead] <- or use a [metro] here | [b] [gemmouse] | | [float] | [t f f] X [- ] | [s SPEED-X]
Duplicate this for the y coordinate, if you want. For absolute speed in both directions you can add the squares of "SPEED-X" and "SPEED-Y" and [sqrt] it. That's like in Pythagoras from school: a^2 + b^2 = c^2
But when using this with [gemmouse] make you you match the [gemmouse] coordinates with the [gemwin] coordinates accordingly. There was a mailing list thread one or two weeks ago about this, search the archive for "scaling" and "interpolation" or so.
Frank Barknecht _ ______footils.org__
[MouseState] in cyclone gives you something like speed (change in
postion) in addition to pixel positions.
.hc
On Nov 29, 2007, at 4:40 AM, Rebecca Schatz wrote:
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@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
I spent 33 years and four months in active military service and
during that period I spent most of my time as a high class muscle man
for Big Business, for Wall Street and the bankers. - General
Smedley Butler