예제 #1
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));
        }
    }
예제 #2
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)));
 }