/// <summary> /// length of hip center - spine - shoulder center - head /// </summary> /// <param name="skeleton"></param> /// <param name="bone"></param> /// <param name="startJoint"></param> /// <param name="endJoint"></param> private void calCenterBoneLength(Skeleton skeleton, HummanBoneEnum bone, JointType startJoint, JointType endJoint) { double length = calDescartesLength(skeleton.Joints[startJoint].Position, skeleton.Joints[endJoint].Position); if (_boneLengths.ContainsKey(bone)) { double oldLength; _boneLengths.TryGetValue(bone, out oldLength); _boneLengths[bone] = (length + oldLength) / 2; } else { _boneLengths.Add(bone, length); } }
/// <summary> /// length of shoulder center - shoulder - elbow - wrist - hand, hip center - hip - knee - ankle - foot /// </summary> /// <param name="skeleton"></param> /// <param name="bone"></param> /// <param name="startJoint"></param> /// <param name="endJoint"></param> private void calSideBoneLength(Skeleton skeleton, HummanBoneEnum bone, JointType startJoint, JointType endJoint) { double leftLength = calDescartesLength(skeleton.Joints[startJoint].Position, skeleton.Joints[endJoint].Position); double rightLength = calDescartesLength(skeleton.Joints[GetSymmetricJoint(startJoint)].Position, skeleton.Joints[GetSymmetricJoint(endJoint)].Position); double length = (leftLength + rightLength) / 2; if (_boneLengths.ContainsKey(bone)) { double oldLength; _boneLengths.TryGetValue(bone, out oldLength); _boneLengths[bone] = (length + oldLength) / 2; } else { _boneLengths.Add(bone, length); } }