/// <summary> /// function returns 1 when task complete /// </summary> /// public static int moveLeftArm(Body body, double tolerance, double armTolerance, double startAngle, double endAngle) { JointType SpineShoulder = JointType.SpineShoulder; JointType ShoulderLeft = JointType.ShoulderLeft; JointType ElbowLeft = JointType.ElbowLeft; JointType WristLeft = JointType.WristLeft; JointType[] bodyParts = new JointType[] { SpineShoulder, ShoulderLeft, ElbowLeft, WristLeft }; foreach (JointType part in bodyParts) { if (body.Joints[part].TrackingState != TrackingState.Tracked) { return(-72); } } if (!CheckBodyForm.isSpineStraight(body, tolerance))//&& !Exercise.hasStarted) { return(-1); } if (!CheckBodyForm.isStraight(body, armTolerance, ShoulderLeft, ElbowLeft, WristLeft))//&& !Exercise.hasStarted) { return(-2); } //draw box/line showing where arm should be if (Exercise1Part1.hasStarted && CheckBodyForm.isAtAngle(body, tolerance, endAngle, SpineShoulder, ShoulderLeft, ElbowLeft) && body.Joints[WristLeft].Position.Y > body.Joints[ShoulderLeft].Position.Y) { return(1); } if (Exercise1Part1.hasStarted) { return(-45); } if (CheckBodyForm.isAtAngle(body, tolerance, startAngle, SpineShoulder, ShoulderLeft, ElbowLeft) && body.Joints[WristLeft].Position.Y < body.Joints[ShoulderLeft].Position.Y) { Exercise1Part1.hasStarted = true; } return(-100); }
/// <summary> /// function returns 1 when task complete /// </summary> /// public static int bendRightArm(Body body, double tolerance, double armTolerance) { JointType SpineShoulder = JointType.SpineShoulder; JointType ShoulderRight = JointType.ShoulderRight; JointType ElbowRight = JointType.ElbowRight; JointType WristRight = JointType.WristRight; JointType[] bodyParts = new JointType[] { SpineShoulder, ShoulderRight, ElbowRight, WristRight }; foreach (JointType part in bodyParts) { if (body.Joints[part].TrackingState != TrackingState.Tracked) { return(-72); } } if (!CheckBodyForm.isSpineStraight(body, tolerance))//&& !Exercise.hasStarted) { return(-1); } if (hasStarted && CheckBodyForm.isStraight(body, armTolerance, SpineShoulder, ShoulderRight, ElbowRight) && CheckBodyForm.isAtAngle(body, tolerance, 90, ShoulderRight, ElbowRight, WristRight) && body.Joints[WristRight].Position.Y > body.Joints[ShoulderRight].Position.Y) { return(1); } if (hasStarted) { return(-45); } if (CheckBodyForm.isStraight(body, armTolerance, SpineShoulder, ShoulderRight, ElbowRight)) { hasStarted = true; } return(-100); }