Is there a way to get the angle between finger joints

I’m using webxr hand tracking. when join webxr, I can get WebXrHand object. so I can also get joint mesh by hand.getJointMesh(WebXRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL);.
now I want to get the angle between indexProximal and wrist、between indexProximal and indexIntermediate、between indexIntermediate and indexDistal,is there a way?

cc @RaananW

So first - Babylon doesn’t offer a simplified API to do that. But, you can of course do it, as you have all of the information your require.
To get the angle between two fingers you will need to first get a direction vector for each finger. You can use the Proximal Phalanx of the two fingers and their Intermediate Phalanx or even the tip. Using those two vectors per finger will provide you the direction. Now that you have two direction vectors you can normalize them and get the angle between them using their dot product.

So - to simplify. For each finger:

  1. get the position of the proximal phalanx and the tip
  2. subtract those two vectors. This is your direction.

For those two vectors you are getting:

  1. calculate the normal between them
  2. Use BABYLON.Vector3.GetAngleBetweenVectors using those two vectors and the normal
  3. ???
  4. Profit!
1 Like

yes, now I can get the angle between two mesh.

function getAngle(originMesh: TransformNode, mesh1: TransformNode, mesh2: TransformNode) {
        const line1 = originMesh.position.subtract(mesh1.position);
        const line2 = originMesh.position.subtract(mesh2.position);
        const normal = Vector3.Cross(line1, line2).normalize();

        const angle = Vector3.GetAngleBetweenVectors(line1, line2, normal);
        return angle;
    }
1 Like