我有以下问题:我需要代码来冻结关节的第一个位置 因为我想用它来计算距离 我怎么能这样做?
答案 0 :(得分:1)
您可能正在寻找的是一些看起来像这样的代码(警告:未经测试的代码):
private SkeletonPoint _jointInitial;
private bool _initialized;
void MyMethodThatProcessesJoints(Joint joint)
{
if (!_initialized)
{
_jointInitial = joint.Position;
_initialized = true;
}
else
{
var pos = joint.Position;
var dx = pos.X - _jointInitial.X;
var dy = pos.Y - _jointInitial.Y;
var distance = Math.Sqrt(dx * dx + dy * dy);
// do something with distance...
}
}