Creating Animation Curves for Motion Captured Data

Hello everyone.

I have this motion captured data corresponding to a human character animation.

I want to perform some pre-prossesing motion analysis stuff like to calculate kinematic parameters for each joint of my skeleton.

Thus I need the position of each joint per frame.
For example if we want the direction.x of the pelvis at
frame 2 we subtract the position.x of the joint at frame3 with the position.x of the joint at frame2.

In order to find these positions per frame I am using the AnimationUtility.GetEditorCurve(...)

This works well for the root joint(pelvis in my case)
but doesn’t work for the other joints like hips , ankles etc.

The case is that in the root bone there exist animation curves for the translation.x , translation.y,and translation.z( I can check that in the Animation View window in Unity ).
However , for the other joints there exist only rotational data.

This means that if I try to find the animation curve of the left hip by saying:

Animation curve xCurve = AnimationUtility.GetEditorCurve(animationClip,"jointName",typeof(Transform),"m_LocalPosition.x");

it will return a null reference since nothing exists

So, to the point:

How can I create (with scripting) this animation curve??

I know that I can create an empty animation curve and for each keyframe (mapped to a frame in my data) add the position data as it exists in the prerecorded animation, but I dont know how to retrieve this data.

In other words I don’t know how to find the
myJoint.transform.position.x value at a specific frame.

Any suggestion would be extremely helpful!!!
Thanks.

PS:I have a feeling that it has to do something with
sampling the trajectory of the particular joint but I am not sure how to do that.

As I saw in the Unity Locomotion System animation data, only the root is supposed to have translational information and all its children have rotational information(not any animation curves fro position.x ,position.y, and position.z).

However my question remains the same:

How can I get the position of a particular joint per (key)frame??

Since rigs are rotational armatures by their very nature the positional data is not really usable unless translational or scalar deformation is required. However…you could get the root translation and then calculate each of the bone lengths along the chains by using angle and distance calculations or simply subtraction of one transform position for the other . Once the script is done for one check its a breeze to iterate down a bone chain. You will probably have to run the animation to get an array of transform positions for each bone of interest as you can access their positions directly then .