0
\$\begingroup\$

I'm working on a project with the Kinect SDK and XNA 4. I need take the position of the hands and draw a sprite over it. I'm was doing it directly and because of that I get a "trembling hands" effect. So, I was thinking of making the sprite move from the previous position to the new one given in every frame by the new hand position.

This way, the sprite does not jump from one position to another. This is working just fine, but I'm using a constant value for the velocity, and I really would like to use a variable velocity given by the difference between the previous and the new position. That is: if the hand move more quickly in the reality, the velocity will be higher.

I really don't have a clue on how to make this work. Can somebody point me in the right direction?

\$\endgroup\$
1
\$\begingroup\$

By computing the velocity as some factor of the difference between the start and end position, you can achieve the association you want:

var velocity = (endPosition - startPosition) * scale;

The hard part be will choosing a value for scale. You can initially try constants -- such as 1.0f or 0.5f. This makes the velocity directly proportional to the start and end distance. If that feels good, great. If it doesn't you may need to try more complex scaling factors to achieve more of an easing curve where the velocity for small movements is low but increases greater than linearly as the movement delta becomes larger. For example, you might compute scale as:

scale = pow(0.25 * length(velocity)), 2)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.