public int[] getFinalAngles() { Skeleton first = skeleton; int[] lastFewValues = new int[7]; HandPositionLower measures = new HandPositionLower(first); double baseA = measures.getBaseAngle(); double horA = measures.getHorizonAngle(); double hDist = measures.getHandDistance(); PolygonAngles poly = new PolygonAngles(hDist); double theta, phi; theta = poly.getTheta(); phi = poly.getPhi(); Angles angles = new Angles(first); lastFewValues[1] = round(180 - (int)Mathematics.toDegrees(baseA)); lastFewValues[2] = round(180 - (int)Mathematics.toDegrees(horA + phi)); lastFewValues[3] = round((int)Mathematics.toDegrees(theta) + 90); lastFewValues[4] = round((int)Mathematics.toDegrees(theta) + 90); lastFewValues[5] = round((int)Mathematics.toDegrees(Math.Acos(angles.s2l()))); lastFewValues[5] = Math.Min(180, Math.Max(90, 180 - lastFewValues[5] + 90 - 20)); lastFewValues[6] = round(180 - (int)Mathematics.toDegrees(Math.Acos(angles.el())) - 30); if (lastFewValues[1] > 180) { lastFewValues[1] = 180; } return(lastFewValues); }
void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame == null) { return; } inputmethod = W.inputmethod; skeletonFrame.CopySkeletonDataTo(allSkeletons); //get the first tracked skeleton Skeleton first = (from s in allSkeletons where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault(); // skeleton data may not be available if (first == null) { return; } // display skeleton on window displaySkeleton(first); // Selecting the input method switch (inputmethod) { case 0: // input version 1 Angles angles1 = new Angles(first); AxisAngles = angles1.getFinalAngles(); break; case 2: // input version 2 HandPosition angles2 = new HandPosition(first); AxisAngles = angles2.getFinalAngles(); break; case 1: // input version 3 HandPositionLower angles3 = new HandPositionLower(first); AxisAngles = angles3.getFinalAngles(); break; default: MessageBox.Show("Error !!!"); break; } AxisAngles = medians.getNextMedian(AxisAngles); // Displaying on GUI W.axis1.Content = AxisAngles[1].ToString(); W.axis2.Content = AxisAngles[2].ToString(); W.axis3.Content = AxisAngles[3].ToString(); W.axis4.Content = AxisAngles[4].ToString(); W.axis5.Content = AxisAngles[5].ToString(); W.axis6.Content = AxisAngles[6].ToString(); if (W.RoboticArmMovement) { MoveRoboticArm(AxisAngles); } } }