/// <summary> /// Copies current values to other joint angle. /// </summary> /// <param name="copy"></param> public void copyTo(JointAngles copy) { copy.name = this.name; copy.roll = this.roll; copy.pitch = this.pitch; copy.yaw = this.yaw; copy.x = this.x; copy.y = this.y; copy.z = this.z; copy.fConfidence = this.fConfidence; }
/// <summary> /// Makes new JointAngles from current values. /// </summary> /// <returns></returns> public JointAngles copyJointAngles() { JointAngles copy = new JointAngles(this.name); copy.roll = this.roll; copy.pitch = this.pitch; copy.yaw = this.yaw; copy.x = this.x; copy.y = this.y; copy.z = this.z; copy.fConfidence = this.fConfidence; return copy; }
/// <summary> /// Calculates vector between two points in space. /// </summary> /// <param name="joint1">First point in space.</param> /// <param name="joint2">Second point in space.</param> /// <returns></returns> private static List<float> getDirectionVector(JointAngles joint1, JointAngles joint2) { List<float> d_vec = new List<float>(); d_vec.Add(joint2.x - joint1.x); d_vec.Add(joint2.y - joint1.y); d_vec.Add(joint2.z - joint1.z); return d_vec; }
/// <summary> /// Reads in joint data specified above. /// </summary> /// <param name="joint"></param> /// <returns></returns> public static JointAngles parseJoint(XElement joint) { JointAngles jointAngles = new JointAngles("Temp"); foreach (XElement element in joint.Descendants()) { if (element.Name == "Position") { foreach (XElement position in element.Descendants()) { if (position.Name == "X") jointAngles.x = float.Parse(position.Value); else if (position.Name == "Y") jointAngles.y = float.Parse(position.Value); else if (position.Name == "Z") jointAngles.z = float.Parse(position.Value); } } else if (element.Name == "Angles") { foreach (XElement position in element.Descendants()) { if (position.Name == "Roll") jointAngles.roll = float.Parse(position.Value); else if (position.Name == "Yaw") jointAngles.yaw = float.Parse(position.Value); else if (position.Name == "Pitch") jointAngles.pitch = float.Parse(position.Value); } } } return jointAngles; }