How to calculate movement vector and acceleration?
Hiya Jitterists!
I'm try to create standart TUIO messages from coordinates taken from cv.jit.blobs.centroids...and can't understand how to calculate movement vector and acceleration from list that I have (
I've experimented with single coordinates of one blob with success, but never with all list...
Has anybody success with the same problemm?
Please help with any tip !
Thanks and sorry for bad english )))
This is text taken from http://tuio.org :
The movement velocity unit is defined as a movement over the full length of an axis within one second. As an example, moving a finger horizontally from left to right across the full surface within one second represents a movement velocity vector of (1.0 0.0). The motion speed values are computed from the normalized distance between two positions divided by the time between the two samples in seconds. The acceleration value is the speed change divided by the time between the two samples in seconds.
X = (sensor_dx / sensor_width) / dt
Y = (sensor_dy / sensor_height) / dt
m = (speed - last_speed) / dt
If you can do it with lists of one blob, you should be able to do it with multiple blobs using two [vexpr] objects: one for the list of X values and one for the Y values. be sure to set @scalarmode 1 for both. (if I've made any mistakes here, someone please advise...)
(float list of raw X values:) -->
[vexpr $f1 / $f2] // $f2 is your change in time, or "dt"
(float list of raw Y values:) -->
[vexpr $f1 / $f2] // the same
// this assumes a sensor width and height of 1, so you don't need the extra division in the formula.
Take each pair of points (for the whole list) and compute the distance between successive samples of each blob, labeled (x1, y1) and (x2, y2):
distance = sqrt(((x2-x1) ^ 2) + ((y2-y1) ^ 2)) // Pythagorean theorem: c = square root of ((a ^ 2) + (b ^ 2))
the x1, x2, y1, and y2 would correspond to $f1, $f2, $f3, $f4 in [vexpr].
it would be cool if you could have the third dimension of pressure, don't some surfaces have that? ... you'd just extend this to (x1, y1, z1) and (x2, y2, z2).
Thanks for the answer!
When I try calculate velocities in max, come out new TUIO library for Processing, that do it inside herself, but I'm don't know about it ) And when I disconnect my cords with calculations it's still works
xD
first several seconds I'm just gonuts )))
Third dimension(pressure) I can try to do with blob size, but it needs to delicate tuning...
Cheers!
Hi! Is it possible for you to send me a compressed patch so I can understand better? Because I made this patch that tracks color to find the position of a conducting baton and I want to calculate the speed of my movement so that if I speed up my movement the music that is being played speeds up too. Can you help me?
;)