Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用现有关节角度计算Kinect骨骼膝盖和肘部角度_C#_Kinect_Angle - Fatal编程技术网

C# 使用现有关节角度计算Kinect骨骼膝盖和肘部角度

C# 使用现有关节角度计算Kinect骨骼膝盖和肘部角度,c#,kinect,angle,C#,Kinect,Angle,我正在做一个项目,将Kinect捕捉到的关节数据映射到机器人上。我需要计算肘部和膝盖的角度。 以左膝为例,我得到髋膝和膝关节角度向量,并试图计算两个向量之间的角度。 代码如下 Vector3D KL = new Vector3D(skeleton.Joints[JointType.KneeLeft].Position.X, skeleton.Joints[JointType.KneeLeft].Position.Y, skeleton.Joints[JointType.KneeLeft].Pos

我正在做一个项目,将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左右。 我仔细检查了算法和编码,非常困惑。
谢谢你的建议

我想你的问题可能是:

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

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

你在AngleBetween(AKL,KHL)函数中做什么如果你提供它的代码,我可以更好地告诉你出了什么问题,你应该使用以下公式计算两个向量之间的角度cos0=(U.V)/| U | V |其中U和V是3D向量,以便更好地理解检查链接