public override UserPerformanceAnalysisInfo IsInBetweenOrientations(BodyPartOrientation initialOrientation, BodyPartOrientation finalOrientation) { HeadOrientation initialHeadOrientation = (HeadOrientation)initialOrientation; HeadOrientation finalHeadOrientation = (HeadOrientation)finalOrientation; UserPerformanceAnalysisInfo headInclinationInfo = BodyPartOrientation.IsVectorOnPathInPlane(this.calibratedInclination, initialHeadOrientation.calibratedInclination, finalHeadOrientation.calibratedInclination); if (headInclinationInfo.failed) { Console.WriteLine("Failed when checking head inclination"); return headInclinationInfo; } else if (Vector3D.AngleBetween(initialHeadOrientation.inclination, finalHeadOrientation.inclination) <= SharedContent.GetAllowableDeviationInDegrees()) { //The actual exercise has a negligable change in the head inclination return new UserPerformanceAnalysisInfo(true); } else { return headInclinationInfo; } }
public override UserPerformanceAnalysisInfo IsInBetweenOrientations(BodyPartOrientation initialOrientation, BodyPartOrientation finalOrientation) { LimbOrientation initialLimbOrientation = (LimbOrientation)initialOrientation; LimbOrientation finalLimbOrientation = (LimbOrientation)finalOrientation; UserPerformanceAnalysisInfo[] limbComponentPerformanceInfo = new UserPerformanceAnalysisInfo[Enum.GetValues(typeof(LimbComponentID)).Length]; //Upper limb UserPerformanceAnalysisInfo upperLimbInclinationInfo = BodyPartOrientation.IsVectorOnPathInPlane(this.calibratedUpperLimbInclination, initialLimbOrientation.calibratedUpperLimbInclination, finalLimbOrientation.calibratedUpperLimbInclination); if (upperLimbInclinationInfo.failed) { Console.WriteLine("Failed when checking upper limb inclination"); return upperLimbInclinationInfo; } if (Vector3D.AngleBetween(initialLimbOrientation.upperLimbInclination, finalLimbOrientation.upperLimbInclination) <= SharedContent.GetAllowableDeviationInDegrees()) { upperLimbInclinationInfo.negligableAction = true; } limbComponentPerformanceInfo[(int)LimbComponentID.UpperLimb] = upperLimbInclinationInfo; //Lower limb UserPerformanceAnalysisInfo lowerLimbInclinationInfo = BodyPartOrientation.IsVectorOnPathInPlane(this.calibratedLowerLimbInclination, initialLimbOrientation.calibratedLowerLimbInclination, finalLimbOrientation.calibratedLowerLimbInclination); if (lowerLimbInclinationInfo.failed) { Console.WriteLine("Failed when checking lower limb inclination"); return lowerLimbInclinationInfo; } if (Vector3D.AngleBetween(initialLimbOrientation.lowerLimbInclination, finalLimbOrientation.lowerLimbInclination) <= SharedContent.GetAllowableDeviationInDegrees()) { lowerLimbInclinationInfo.negligableAction = true; } limbComponentPerformanceInfo[(int)LimbComponentID.LowerLimb] = lowerLimbInclinationInfo; //Bend in limb if (this.calibratedBendInLimb < Math.Min(initialLimbOrientation.calibratedBendInLimb, finalLimbOrientation.calibratedBendInLimb) - SharedContent.GetAllowableDeviationInDegrees() || this.calibratedBendInLimb > Math.Max(initialLimbOrientation.calibratedBendInLimb, finalLimbOrientation.calibratedBendInLimb) + SharedContent.GetAllowableDeviationInDegrees()) { return new UserPerformanceAnalysisInfo(true, String.Format("The bend in the {0} is not in the range defined in the exercise step", Enum.GetName(typeof(SharedContent.BodyPartID), this.limbID))); } UserPerformanceAnalysisInfo bendInLimbInfo = new UserPerformanceAnalysisInfo(false); double currentChangeInBendInLimb = Math.Abs(this.calibratedBendInLimb - initialLimbOrientation.calibratedBendInLimb); double totalChangeInBendInLimb = Math.Abs(finalLimbOrientation.calibratedBendInLimb - initialLimbOrientation.calibratedBendInLimb); if (Math.Abs(finalLimbOrientation.bendInLimb - initialLimbOrientation.bendInLimb) <= SharedContent.GetAllowableDeviationInDegrees()) { bendInLimbInfo.negligableAction = true; } else { bendInLimbInfo.percentComplete = (int)(100 * (currentChangeInBendInLimb / totalChangeInBendInLimb)); } limbComponentPerformanceInfo[(int)LimbComponentID.BendInLimb] = bendInLimbInfo; if (bendInLimbInfo.negligableAction && upperLimbInclinationInfo.negligableAction && lowerLimbInclinationInfo.negligableAction) { return new UserPerformanceAnalysisInfo(true); } int maxPercent = int.MinValue, minPercent = int.MaxValue, maxPercentIndex = 0, minPercentIndex = 0, percentSum = 0, numPercents = 0; foreach (LimbComponentID limbComponentID in Enum.GetValues(typeof(LimbComponentID))) { if (!limbComponentPerformanceInfo[(int)limbComponentID].negligableAction) { percentSum += limbComponentPerformanceInfo[(int)limbComponentID].percentComplete; numPercents++; if (limbComponentPerformanceInfo[(int)limbComponentID].percentComplete > maxPercent) { maxPercentIndex = (int)limbComponentID; maxPercent = limbComponentPerformanceInfo[(int)limbComponentID].percentComplete; } if (limbComponentPerformanceInfo[(int)limbComponentID].percentComplete < minPercent) { minPercentIndex = (int)limbComponentID; minPercent = limbComponentPerformanceInfo[(int)limbComponentID].percentComplete; } } } if ((limbComponentPerformanceInfo[maxPercentIndex].percentComplete - limbComponentPerformanceInfo[minPercentIndex].percentComplete) > SharedContent.GetAllowableDeviationInPercent()) { Console.WriteLine("Vector3D.AngleBetween(initialLimbOrientation.upperLimbInclination, finalLimbOrientation.upperLimbInclination) = {0}", Vector3D.AngleBetween(initialLimbOrientation.upperLimbInclination, finalLimbOrientation.upperLimbInclination)); Console.WriteLine("maxChange is for the {0} with {1} percent. minChange is for the {2} with {3} percent", Enum.GetName(typeof(LimbComponentID), (LimbComponentID)maxPercentIndex), limbComponentPerformanceInfo[maxPercentIndex].percentComplete, Enum.GetName(typeof(LimbComponentID), (LimbComponentID)minPercentIndex), limbComponentPerformanceInfo[minPercentIndex].percentComplete); return new UserPerformanceAnalysisInfo(true, String.Format("The difference in the percentage completion of the movement for the {0} and {1} of the {2} exceeded the maximum allowable deviation of {3}", Enum.GetName(typeof(LimbComponentID), (LimbComponentID)maxPercentIndex), Enum.GetName(typeof(LimbComponentID), (LimbComponentID)minPercentIndex), Enum.GetName(typeof(SharedContent.BodyPartID), this.limbID), SharedContent.GetAllowableDeviationInPercent())); } else { return new UserPerformanceAnalysisInfo(percentSum / numPercents); } }
public abstract UserPerformanceAnalysisInfo IsInBetweenOrientations(BodyPartOrientation initialOrientation, BodyPartOrientation finalOrientation);
public override UserPerformanceAnalysisInfo IsInBetweenOrientations(BodyPartOrientation initialOrientation, BodyPartOrientation finalOrientation) { TorsoOrientation initialTorsoOrientation = (TorsoOrientation)initialOrientation; TorsoOrientation finalTorsoOrientation = (TorsoOrientation)finalOrientation; //Compute inclination information UserPerformanceAnalysisInfo inclinationInfo = BodyPartOrientation.IsVectorOnPathInPlane(this.calibratedInclination, initialTorsoOrientation.calibratedInclination, finalTorsoOrientation.calibratedInclination); if (inclinationInfo.failed) return inclinationInfo; if (Vector3D.AngleBetween(initialTorsoOrientation.inclination, finalTorsoOrientation.inclination) <= SharedContent.GetAllowableDeviationInDegrees()) { //The actual exercise has a negligable change in the torso inclination inclinationInfo.negligableAction = true; } //Compute rotation information if (this.calibratedRotation < Math.Min(initialTorsoOrientation.calibratedRotation, finalTorsoOrientation.calibratedRotation) - SharedContent.GetAllowableDeviationInDegrees() || this.calibratedRotation > Math.Max(initialTorsoOrientation.calibratedRotation, finalTorsoOrientation.calibratedRotation) + SharedContent.GetAllowableDeviationInDegrees()) { //The current rotation is not within the range specified by the initial and final orientations return new UserPerformanceAnalysisInfo(true, "User's torso rotation is not in the range defined by the exercise step"); } UserPerformanceAnalysisInfo rotationInfo = new UserPerformanceAnalysisInfo(false); if (Math.Abs(finalTorsoOrientation.rotation - initialTorsoOrientation.rotation) <= SharedContent.GetAllowableDeviationInDegrees()) { //The actual exercise has a negligable change in the torso rotation rotationInfo.negligableAction = true; } double currentRotationTraveled = Math.Abs(this.calibratedRotation - initialTorsoOrientation.calibratedRotation); double totalRotationToTravel = Math.Abs(finalTorsoOrientation.calibratedRotation - initialTorsoOrientation.calibratedRotation); rotationInfo.percentComplete = (int)(100 * (currentRotationTraveled / totalRotationToTravel)); if (rotationInfo.negligableAction && inclinationInfo.negligableAction) { return new UserPerformanceAnalysisInfo(true); } else if (inclinationInfo.negligableAction) { return rotationInfo; } else if (rotationInfo.negligableAction) { return inclinationInfo; } else { if (Math.Abs(inclinationInfo.percentComplete - rotationInfo.percentComplete) > SharedContent.GetAllowableDeviationInPercent()) { return new UserPerformanceAnalysisInfo(true, String.Format("The difference in the percentage completion of the change in torso inclination and change in torso rotation exceeded the maximum allowable deviation of {0}", SharedContent.GetAllowableDeviationInPercent())); } //Return the average percent complete return new UserPerformanceAnalysisInfo((int)((inclinationInfo.percentComplete + rotationInfo.percentComplete) / 2.0)); } }