コード例 #1
0
 public bool InHand(HandAnalysis otherHand)
 {
     var dist = Math.Sqrt(
             Math.Pow(Center.X - otherHand.Center.X, 2) +
             Math.Pow(Center.Y - otherHand.Center.Y, 2) +
             Math.Pow(Center.Z - otherHand.Center.Z, 2));
     var threshold = 2 * (Radius + otherHand.Radius);
     // Debug.Print("dist: {0}, threshold: {1}", dist, threshold);
     return dist < threshold;
 }
コード例 #2
0
        public SkeletonAnalysis(Skeleton skeleton)
        {
            _skeleton = skeleton;
            LeftForeArmElevationRatio = double.NaN;
            RightForeArmElevationRatio = double.NaN;
            ElevationOk = false;
            HandsOk = false;
            HeadOk = false;

            if (IsTracking(JointType.WristLeft, JointType.WristRight))
            {

                if (
                    IsTracking(JointType.Spine, JointType.ShoulderCenter) &&
                    IsTracking(JointType.ShoulderLeft, JointType.ElbowLeft) &&
                    IsTracking(JointType.ShoulderRight, JointType.ElbowRight)
                    )
                {
                    var spine = FromJoints(JointType.Spine, JointType.ShoulderCenter);
                    spine.Normalize();
                    var leftForeArm = FromJoints(JointType.ElbowLeft, JointType.WristLeft);
                    var rightForeArm = FromJoints(JointType.ElbowRight, JointType.WristRight);
                    var leftComp = Vector3D.DotProduct(leftForeArm, spine);
                    var rightComp = Vector3D.DotProduct(rightForeArm, spine);

                    LeftForeArmElevationRatio = leftComp/leftForeArm.Length;
                    RightForeArmElevationRatio = rightComp/rightForeArm.Length;
                    ElevationOk = true;
                }

                if (IsTracking(JointType.HandLeft, JointType.HandRight))
                {
                    _leftHand = new HandAnalysis(skeleton.Joints[JointType.WristLeft],
                        _skeleton.Joints[JointType.HandLeft]);
                    _rightHand = new HandAnalysis(skeleton.Joints[JointType.WristRight],
                        _skeleton.Joints[JointType.HandRight]);
                    HandsOk = true;
                }

                if (IsTracking(JointType.Head))
                {
                    _head = new HeadAnalysis(skeleton.Joints[JointType.Head], skeleton.Joints[JointType.ShoulderCenter]);
                    HeadOk = true;
                }
            }

            if (IsTracking(JointType.Head))
            {
                _distanceCalcPoint = skeleton.Joints[JointType.Head];
            }
        }