meshonline / kinect-openni-bvh-saver

This project is based on OpenNI2, NITE2, and OpenCV2, it will automatically save many skeleton animation clips to bvh files.
MIT License
206 stars 57 forks source link

Explanation of CreateQuaternion Function #10

Closed mshooter closed 2 years ago

mshooter commented 2 years ago

Hi,

I am trying to implement a .bvh exporter myself. I would like to understand more about your function CreateQuaternion. could you explain in pseudo code what you are exactly doing in the CreateQuaternion Function? What I understand is that you are computing the forward, up and right vector of the joint and then convert it into a matrix and then quaternion? However, I do not understand the "constrain to body's axis x", "reverse the direction because knees can only bend to back" and "inverse bind pose" comments. additionally, why is the left foot quaterion equal to the left knee quaternion?

Thank you!

meshonline commented 2 years ago

"constrain to body's axis x", it is actually a Lerp(a, b, t) function, when t is 0.0, use a; when t is 1.0, use b.

"reverse the direction because knees can only bend to back", force to inverse direction of the cross product vector at the knees.

"inverse bind pose", is a standard function to calculate the inverse of a matrix. mr = mat3_inverse(mat3_rotation_z(kPiDiv2 * arm_angle_scaler)); m = mat3_multiply(mr, m);

Then we let m = mr * m to get the relative transform.