// detect whether hand is within the radius of robot private bool isHandWithinRadius(Robot robot, Skeleton skel) { Point currentPoint = SkeletonPointToScreen(skel.Joints[JointType.HandRight].Position); double distance = Math.Sqrt(Math.Pow(currentPoint.X - robot.center.X, 2) + Math.Pow(currentPoint.Y - robot.center.Y, 2)); if (distance <= robot.radious) { return true; } else return false; }
// draw the robot private void drawRobot(DrawingContext drawingContext, Robot robot) { drawingContext.DrawLine(robotPen, robot.topLeft, robot.topRight); drawingContext.DrawLine(robotPen, robot.topRight, robot.bottomRight); drawingContext.DrawLine(robotPen, robot.bottomRight, robot.bottomLeft); drawingContext.DrawLine(robotPen, robot.bottomLeft, robot.topLeft); drawingContext.DrawLine(robotPen, robot.topLeft, robot.center); drawingContext.DrawLine(robotPen, robot.topRight, robot.center); drawingContext.DrawLine(robotPen, robot.bottomLeft, robot.center); drawingContext.DrawLine(robotPen, robot.bottomRight, robot.center); textBox2.Text = "(" + Math.Round(robot.center.X) + " , " + Math.Round(robot.center.Y) + ")"; textBox3.Text = ""+ Math.Round(robot.angle.angle); if (handPath.iterator != null) textBox4.Text = "" + Math.Round(handPath.iterator.turnAngle.angle); }