I am working on a extension method to move one skeleton to a desired position in the kinect field os view.

My code receives a skeleton to be moved and the destiny position, i calculate the distance between the received skeleton hip center and the destiny position to find how much to move, then a iterate in the joint applying this factor. My code, actualy looks like this.

public static Skeleton MoveTo(this Skeleton skToBeMoved, Vector4 destiny)
    {
        Joint newJoint = new Joint();

        ///Based on the HipCenter (i dont know if it is reliable, seems it is.)
        float howMuchMoveToX = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.X - destiny.X);
        float howMuchMoveToY = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.Y - destiny.Y);
        float howMuchMoveToZ = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.Z - destiny.Z);
        float howMuchToMultiply = 1;

        // Iterate in the 20 Joints
        foreach (JointType item in Enum.GetValues(typeof(JointType)))
        {
            newJoint = skToBeMoved.Joints[item];

            // This adjust, try to keeps the skToBeMoved in the desired position
            if (newJoint.Position.X < 0)
                howMuchToMultiply = 1; // if the point is in a negative position, carry it to a "more positive" position
            else
                howMuchToMultiply = -1; // if the point is in a positive position, carry it to a "more negative" position

            // applying the new values to the joint
            SkeletonPoint pos = new SkeletonPoint()
            {
                X = newJoint.Position.X + (howMuchMoveToX * howMuchToMultiply),
                Y = newJoint.Position.Y, // * (float)whatToMultiplyY,
                Z = newJoint.Position.Z, // * (float)whatToMultiplyZ
            };

            newJoint.Position = pos;
            skToBeMoved.Joints[item] = newJoint;

            //if (skToBeMoved.Joints[Joint
Edit
Report