-1

我有以下问题:我需要代码来冻结关节的第一个位置,因为我想用它来计算距离我该怎么做?

4

1 回答 1

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...
    }       
}
于 2013-02-27T19:36:58.377 回答