Beispiel #1
0
void LCPPolyDist<Dimension,FVector,DVector>::VerifyWithTestPoints (
    const DVector* closest, int& statusCode)
{
    DVector* testPoints1 = new1<DVector>(13);
    DVector* testPoints2 = new1<DVector>(13);

    SetupTestPoints(1, mNumFaces1, mNumPoints1, closest[0], mA1, mB1,
        mPoints1, testPoints1);
    SetupTestPoints(2, mNumFaces2, mNumPoints2, closest[1], mA2, mB2,
        mPoints2, testPoints2);

    double diffSq = 0.0;
    double minValue = 0.0;
    DVector diff;
    int iLine = 0;
    int jLine = 0;

    // The min distance between generated points.  Note that one of these
    // points is the "solution".
    int i;
    for (i = 0; i < 13; ++i)
    {
        for (int j = 0; j < 13; ++j)
        {
            diff = testPoints1[i] - testPoints2[j];
            diffSq = diff.Dot(diff);
            if (i == 0 && j == 0)
            {
                minValue = diffSq;
            }
            else
            {
                if (diffSq < minValue)
                {
                    minValue = diffSq;
                    iLine = i;
                    jLine = j;
                }
            }
        }
    }

    diff = closest[0] - closest[1];
    float distance = (float)diff.Dot(diff);

    statusCode = SC_FOUND_SOLUTION;
    if (distance > diffSq)
    {
        mLog << "Test points closer than solution points by ";
        mLog << distance - diffSq << " squared units.\n";
        if ((distance - diffSq > mVerifyMinDifference)
        &&  (iLine != 12 || jLine != 12))
        {
            statusCode = SC_TEST_POINTS_TEST_FAILED;
        }
    }
    mLog << std::endl << " Solution points are separated by "
        << Mathf::Sqrt(distance);
    mLog << " units." << std::endl;
    mLog << "The smallest distance between test points is "
        << Mathf::Sqrt((float)minValue);
    mLog << std::endl << "and occurs for (" << testPoints1[iLine][0];
    for (i = 1; i < mDimension; ++i)
    {
        mLog << ", " << testPoints1[iLine][i];
    }
    mLog << ") and (" << testPoints2[jLine][0];
    for (i = 1; i < mDimension; ++i)
    {
        mLog << ", " << testPoints2[jLine][i];
    }
    mLog << ")" << std::endl;

    delete1(testPoints1);
    delete1(testPoints2);
}