1

我正在开展一个项目,将 Kinect 捕获的关节数据映射到机器人。我需要计算肘部和膝盖的角度。以左膝为例,我得到了髋膝和膝角向量,并试图计算两个向量之间的角度。代码如下

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 左右。我仔细检查了算法和编码,非常困惑。感谢任何建议。

4

1 回答 1

0

我认为你的问题可能是:

Vector3D AKL = Vector3D.Subtract(AL, KL);

您复制的代码中不存在 AL。
你是说HR吗?

于 2013-08-09T19:07:49.423 回答