コード例 #1
0
        /// <summary>
        /// Retruns the height of the specified body.
        /// </summary>
        /// <param name="body">The specified user body.</param>
        /// <returns>The height of the body in meters.</returns>
        public static double Height(this Body body)
        {
            const double HEAD_DIVERGENCE = 0.1;

            var head       = body.Joints[JointType.Head];
            var neck       = body.Joints[JointType.Neck];
            var shoulders  = body.Joints[JointType.SpineShoulder];
            var spine      = body.Joints[JointType.SpineMid];
            var waist      = body.Joints[JointType.SpineBase];
            var hipLeft    = body.Joints[JointType.HipLeft];
            var hipRight   = body.Joints[JointType.HipRight];
            var kneeLeft   = body.Joints[JointType.KneeLeft];
            var kneeRight  = body.Joints[JointType.KneeRight];
            var ankleLeft  = body.Joints[JointType.AnkleLeft];
            var ankleRight = body.Joints[JointType.AnkleRight];
            var footLeft   = body.Joints[JointType.FootLeft];
            var footRight  = body.Joints[JointType.FootRight];

            // Find which leg is tracked more accurately.
            int legLeftTrackedJoints  = JointExtensions.NumberOfTrackedJoints(hipLeft, kneeLeft, ankleLeft, footLeft);
            int legRightTrackedJoints = JointExtensions.NumberOfTrackedJoints(hipRight, kneeRight, ankleRight, footRight);

            double legLength = legLeftTrackedJoints > legRightTrackedJoints?JointExtensions.Distance(hipLeft, kneeLeft, ankleLeft, footLeft) : JointExtensions.Distance(hipRight, kneeRight, ankleRight, footRight);

            return(JointExtensions.Distance(head, neck, shoulders, spine, waist) + legLength + HEAD_DIVERGENCE);
        }
コード例 #2
0
        /// <summary>
        /// Returns the upper height of the specified body (head to waist).
        /// </summary>
        /// <param name="body">The specified user body.</param>
        /// <returns>The upper height of the body in meters.</returns>
        public static double UpperHeight(this Body body)
        {
            var head      = body.Joints[JointType.Head];
            var neck      = body.Joints[JointType.Neck];
            var shoulders = body.Joints[JointType.SpineShoulder];
            var spine     = body.Joints[JointType.SpineMid];
            var waist     = body.Joints[JointType.SpineBase];

            return(JointExtensions.Distance(head, neck, shoulders, spine, waist));
        }