Beispiel #1
0
    private static void ExpectSameOrder(S2PointLoopSpan loop1, S2.LoopOrder order1, S2PointLoopSpan loop2, S2.LoopOrder order2)
    {
        Assert.Equal(loop1.Count, loop2.Count);
        int i1 = order1.first, i2 = order2.first;
        int dir1 = order1.dir, dir2 = order2.dir;

        for (int n = loop1.Count; --n >= 0;)
        {
            Assert.Equal(loop1[i1], loop2[i2]);
            i1 += dir1;
            i2 += dir2;
        }
    }
Beispiel #2
0
    // Check that the curvature is *identical* when the vertex order is
    // rotated, and that the sign is inverted when the vertices are reversed.
    private static void CheckCurvatureInvariants(S2PointLoopSpan loop_in)
    {
        S2.LoopOrder order_in = S2.GetCanonicalLoopOrder(loop_in);
        var          loop     = loop_in.ToList();
        double       expected = S2.GetCurvature(loop);

        for (int i = 0; i < loop.Count; ++i)
        {
            loop.Reverse();
            Assert.Equal((expected == S2.M_2_PI) ? expected : -expected,
                         S2.GetCurvature(loop));
            ExpectSameOrder(loop_in, order_in, loop, S2.GetCanonicalLoopOrder(loop));
            loop.Reverse();
            loop.RotateInPlace(1);
            Assert.Equal(expected, S2.GetCurvature(loop));
            ExpectSameOrder(loop_in, order_in, loop, S2.GetCanonicalLoopOrder(loop));
        }
    }
Beispiel #3
0
 // Given a loop whose vertices are represented as characters (such as "abcd" or
 // "abccb"), verify that S2.GetCanonicalLoopOrder returns the given result.
 private void TestCanonicalLoopOrder(string input_str, S2.LoopOrder expected_order)
 {
     Assert.Equal(expected_order, S2.GetCanonicalLoopOrder(MakeTestLoop(input_str)));
 }