public bool OnHead(HeadAnalysis head) { var dist = Math.Sqrt( Math.Pow(Center.X - head.Center.X, 2) + Math.Pow(Center.Y - head.Center.Y, 2) + Math.Pow(Center.Z - head.Center.Z, 2)); var threshold = 2 * (Radius + head.Radius); // Debug.Print("dist: {0}, threshold: {1}", dist, threshold); return dist < threshold; }
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]; } }
public bool OverHead(HeadAnalysis head) { var diffY = Center.Y - head.Center.Y; return diffY > 4 * Radius; }