Esempio n. 1
0
    private static void TestInterpolate(S2Point a, S2Point b, double t, S2Point expected)
    {
        a        = a.Normalize();
        b        = b.Normalize();
        expected = expected.Normalize();

        // We allow a bit more than the usual 1e-15 error tolerance because
        // interpolation uses trig functions.
        S1Angle kError = S1Angle.FromRadians(3e-15);

        Assert.True(new S1Angle(S2.Interpolate(a, b, t), expected) <= kError);

        // Now test the other interpolation functions.
        S1Angle r = t * new S1Angle(a, b);

        Assert.True(new S1Angle(S2.GetPointOnLine(a, b, r), expected) <= kError);
        if (a.DotProd(b) == 0)
        {  // Common in the test cases below.
            Assert.True(new S1Angle(S2.GetPointOnRay(a, b, r), expected) <= kError);
        }
        if (r.Radians >= 0 && r.Radians < 0.99 * S2.M_PI)
        {
            S1ChordAngle r_ca = new(r);
            Assert.True(new S1Angle(S2.GetPointOnLine(a, b, r_ca), expected) <= kError);
            if (a.DotProd(b) == 0)
            {
                Assert.True(new S1Angle(S2.GetPointOnRay(a, b, r_ca), expected) <= kError);
            }
        }
    }