1
很抱歉,但我需要這個功能和計算Kinect的關節角度計算
一些象我現在有這些向量:
Vector3D ElbowLeft = new Vector3D(body.Joints[JointType.ElbowLeft].Position.X, body.Joints[JointType.ElbowLeft].Position.Y, body.Joints[JointType.ElbowLeft].Position.Z);
Vector3D WristLeft = new Vector3D(body.Joints[JointType.WristLeft].Position.X, body.Joints[JointType.WristLeft].Position.Y, body.Joints[JointType.WristLeft].Position.Z);
Vector3D ShoulderLeft = new Vector3D(body.Joints[JointType.ShoulderLeft].Position.X, body.Joints[JointType.ShoulderLeft].Position.Y, body.Joints[JointType.ShoulderLeft].Position.Z);
Vector3D Head = new Vector3D(body.Joints[JointType.Head].Position.X, body.Joints[JointType.Head].Position.Y, body.Joints[JointType.Head].Position.Z);
Vector3D Neck = new Vector3D(body.Joints[JointType.Neck].Position.X, body.Joints[JointType.Neck].Position.Y, body.Joints[JointType.Neck].Position.Z);
Vector3D SpineShoulder = new Vector3D(body.Joints[JointType.SpineShoulder].Position.X, body.Joints[JointType.SpineShoulder].Position.Y, body.Joints[JointType.SpineShoulder].Position.Z);
我使用這個功能
計算兩個向量之間的角度public double AngleBetweenTwoVectors(Vector3D vectorA, Vector3D vectorB)
{
double dotProduct = 0.0;
vectorA.Normalize();
vectorB.Normalize();
dotProduct = Vector3D.DotProduct(vectorA, vectorB);
return (double)Math.Acos(dotProduct)/Math.PI * 180;
}
我打電話來是這樣的:
double LeftElbowAngle = AngleBetweenTwoVectors(ElbowLeft - ShoulderLeft, ElbowLeft - WristLeft);
double NeckAngle = AngleBetweenTwoVectors(Neck - Head, Neck - SpineBase);
這是正確的嗎?林只是懷疑自己,因爲當我把我的手臂伸直或站起來,它直線檢測到的角度大約170 - 175而不是180.在我的脖子和我的肘關節
請記住,您有3個維度,讓手臂或頭部完美直線可能會不是很容易。其他角度怎麼看? – Chris
左右肘關節是170-178歲,看起來我是一個直的手臂。當我站得很直時,頸部也大致相同。與腿的膝蓋相同。我還沒有想出如何做手腕計算,因爲Kinect也將手腕連接到拇指......我的朋友幫助我確認一切都是數學上正確的。 – ShatteredPheonix
45,90和135度怎麼樣?看起來好嗎? – Chris