Getting object velocity and acceleration continuously through Maya API


#1

Hi,

I am working on a plugin where I need to continuously calculate the translational and angular velocity and acceleration of multiple objects in a joint hierarchy.

I have so far not found any methods or tools that allow me to do so and am wondering if there is anything I have missed?

Currently I have the following 3 ideas but I would be happy to find that there’s an easier way :slight_smile:

  1. Brute force sampling of positions by running through my animation and recording worldspace coordinates and rotation of every object in question. I can then use finite differencing to calculate velocity and acceleration for the whole animation. This will be a rough estimate unless I sample at very small time steps but is potentially good enough. However, I would need to repeat the sampling every time I change anything, so not too intuitive for an animation workflow.
    Extensions could be made here where I only need to re-sample around the place where I made a change, but this still means that I will have to jump around in time and re-evaluate the whole rig multiple times every time I change something.

  2. If I in some way can access the analytical expression of my animation curves, then I can calculate the derivatives at much higher precision and I would not need to sample the whole animation. This obviously only helps for objects that are directly controlled by animation curves in both translation and rotation, however, I believe I can handle this by running my own kinematic calculations in parallel. I admit that this feels a little like double work but so far I have not found a better solution.
    Similarly, if I cannot access the analytical expression of my animation curves, then I can read the keyframes and their tangents and do my own spline interpolation. Double work again but maybe worth it?

  3. somehow use the built in physics engine to extract these values, possibly by constraining particles to each object or similar. I’m neither familiar with the physics engine, nor particles but I assume velocity and acceleration should be in there somewhere and maybe accessible?

Does anyone know of a better way, or some native Maya tools I could use to get part of the way?

Cheers and thanks in advance