I am trying to create a .bvh file through kinect.
This means that you need to get a turn of each skeleton bone. I need turns in the corners of Euler. I already tried many different approaches, but any of them gave me a good result. Can someone give me advice on what I'm doing wrong?
Here is (I think) the bulk of my code.
foreach (Skeleton skeleton in newSkeleton)
{
if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
continue;
int j = 0;
foreach (BoneOrientation orientation in skeleton.BoneOrientations)
{
Matrix4 matrix = orientation.HierarchicalRotation.Matrix;
double y = Math.Asin(matrix.M13);
double x = Math.Atan2(-matrix.M23, matrix.M33);
double z = Math.Atan2(-matrix.M12, matrix.M11);
rotationMatrix[j, 0] = x * 180 / Math.PI;
rotationMatrix[j, 1] = y * 180 / Math.PI;
rotationMatrix[j, 2] = z * 180 / Math.PI;
j++;
}
}
My Euler angles should be stored in an array rotationMatrixfor future use (saving to bvh file). Here is my problem ... the turns calculated in this way make no sense (I mean that they have nothing to do with positioning me ahead of the kinect), and they seem random.
Edit:
I will also need to explain some obscure topics about kinect. I tried Google, but could not.