java - Quantify a change of direction given an array of 3d points -
i working on piece of software written in java uses processing.core library classes , simpleopenni track user's hand xbox kinect.
what trying figure out how determine when user's hand movement changes direction abruptly.
what have @ disposal array of pvectors (essentially vector of x,y,and z coordinates: a point in 3d space) record user's hand position past 30 frames or so.
i imagine there must way obtain value represents amount of directional change in real-time given recent few points recorded. maybe fit curve , take derivatives?
ideally solution should not computationally expensive, trying implement real-time worthy solution.
any direction can offer appreciated!
let position (that is, 0 frames ago) (x0, y0, z0)
let position n
frames ago (xn, yn, zn)
.
let position 2n
frames ago (xm, ym, zm)
.
then change in position between frames 2n
, n
(xn-xm, yn-ym, zn-zm)
.
can think of average velocity during n
frames.
, change in position between n
, (x0-xn, y0-yn, z0-zn)
.
represents average velocity during next n
frames.
now have velocity n
frames ended n
frames ago, , have velocity n
frames ended now.
the change in velocity during last n
frames must difference between 2 vectors. each coordinate:
ax = (x0-xn) - (xn-xm) = x0 -2xn + xm
ay = (y0-yn) - (yn-ym) = y0 -2yn + ym
az = (z0-xn) - (zn-zm) = z0 -2zn + zm
the magnitude of acceleration |a| = sqrt( (ax)^2 + (ay)^2 + (az)^2 )
if you're concerned "large" changes , prefer speed on accuracy, may able away a' = (ax)^2 + (ay)^2 + (az)^2
or a" = abs(ax) + abs(ay) + abs(az)
the idea want each component contribute whole regardless of whether it's positive or negative, "force" positive either squaring or taking absolute value.
hope helps!
Comments
Post a Comment