Kinect でキャプチャした関節データをロボットにマッピングするプロジェクトに取り組んでいます。肘と膝の角度を計算する必要があります。たとえば、左膝を例にとると、股関節と膝の角度ベクトルを取得し、2 つのベクトルの間の角度を計算しようとしました。コードは以下です
Vector3D KL = new Vector3D(skeleton.Joints[JointType.KneeLeft].Position.X, skeleton.Joints[JointType.KneeLeft].Position.Y, skeleton.Joints[JointType.KneeLeft].Position.Z);
Vector3D KR = new Vector3D(skeleton.Joints[JointType.KneeRight].Position.X, skeleton.Joints[JointType.KneeRight].Position.Y, skeleton.Joints[JointType.KneeRight].Position.Z);
Vector3D HL = new Vector3D(skeleton.Joints[JointType.HipLeft].Position.X, skeleton.Joints[JointType.HipLeft].Position.Y, skeleton.Joints[JointType.HipLeft].Position.Z);
Vector3D HR = new Vector3D(skeleton.Joints[JointType.HipRight].Position.X, skeleton.Joints[JointType.HipRight].Position.Y, skeleton.Joints[JointType.HipRight].Position.Z);
//caculte knee angle
Vector3D AKL = Vector3D.Subtract(AL, KL);
Vector3D KHL = Vector3D.Subtract(KL, HL);
double LAngAK_KH = Vector3D.AngleBetween(AKL, KHL);
出てくる角度は、通常の立ち姿勢で約 180 度です。ただし、出力は常に約 15 です。アルゴリズムとコーディングを再確認したところ、非常に混乱しました。アドバイスをいただければ幸いです。