I am working with a pose estimator that is giving me (x, y, z) for each joint. I am attempting to calculate angles based on these and running into some issues.
const find_angle = (Ax,Ay,Az,Bx,By,Bz,Cx,Cy,Cz) =>
{
var AB = Math.sqrt(Math.pow(Bx-Ax,2) + Math.pow(By-Ay,2) + Math.pow(Bz-Az,2));
var CB = Math.sqrt(Math.pow(Bx-Cx,2) + Math.pow(By-Cy,2) + Math.pow(Bz-Cz,2));
var AC = Math.sqrt(Math.pow(Cx-Ax,2) + Math.pow(Cy-Ay,2) + Math.pow(Cz-Az,2));
const radians = Math.acos((CB*CB+AB*AB-AC*AC) / (2*CB*AB));
const angle = (Math.abs(radians*180.0/Math.PI))
console.log(angle)
}
// Knee
find_angle(101, 166, 409, 107, 209, 790, 115, 248, 9564)
// Ankle
find_angle(100, 259, 1549, 97, 299, 9471, 95, 315, 1575)
Ouput:
The Knee output looks correct to me but Ankle does not. I was expecting an angle in the range of 70-90. I'm wondering if this function is too simple for what I am trying to do or what improvements could be made to make it consistent across all joints. User is facing the camera while pose is being estimated.