Angle measurement by Joints Orientations

Hello Sergio Morancho!

To determine the bend angle, we need the coordinates of three reference points,
for example, the elbow is necessary to know the position of the joints: elbow, shoulder, and wrist.

To calculate the angle value, you can use the Vector3.Angle method for two vectors:
from the shoulder to the elbow and from the hand to the elbow.

Here is an example of a method for calculating the angle in degrees:

float Angle(nuitrack.Skeleton skeleton, nuitrack.JointType targetJoint, nuitrack.JointType parentJoint, nuitrack.JointType childJoint)
{
	Vector3 targetPosition = skeleton.GetJoint(targetJoint).ToVector3();
	Vector3 parentPosition = skeleton.GetJoint(parentJoint).ToVector3();
	Vector3 childPosition = skeleton.GetJoint(childJoint).ToVector3();

	return Vector3.Angle(parentPosition - targetPosition, childPosition - targetPosition);
}

Let me know if there’s anything else I can do for you.

1 Like