Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Kinect joints to rotation (quaternions)

$
0
0

How rotations are calculated from joint positions in Kinect SDK?

I want to get the same values as I can get from BoneOrientations collection (from Skeleton object): quaternions for HierarchicalRotations and quaternions for AbsoluteRotations. For example for start joint ElbowRight(x: 0.46, y: 0.42, z: 2.29) and end joint WristRight(x: 0.46, y: 0.61, z: 2.23) hierarchical rotation quaternion is equal Q(w: 0.75, x: 0.67, y: 0.00, z: 0.00).

I wrote some math methods which I can be heplful (I think), like:

public static Quaternion Quaternion(SkeletonPoint firstVector, SkeletonPoint secondVector)
{
SkeletonPoint crossProductVector = CrossProduct(firstVector, secondVector);
float vectorALength = firstVector.GetLength();
float vectorBLength = secondVector.GetLength();

Quaternion quaternion = new Quaternion
{
X = crossProductVector.X,
Y = crossProductVector.Y,
Z = crossProductVector.Z,
W = (float)Math.Sqrt(vectorALength * vectorALength * vectorBLength * vectorBLength)
+ DotProduct(firstVector, secondVector)
};

return quaternion;
}


public static Quaternion NormalizeQuaternion(Quaternion quaternion)
{
float normalizationFactor = 1.0f / (float)Math.Sqrt(
quaternion.X * quaternion.X
+ quaternion.Y * quaternion.Y
+ quaternion.Z * quaternion.Z
+ quaternion.W * quaternion.W);

quaternion.X *= normalizationFactor;
quaternion.Y *= normalizationFactor;
quaternion.Z *= normalizationFactor;
quaternion.W *= normalizationFactor;

return quaternion;
}


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>