Exemplo n.º 1
0
    public void AddEdges(S2Cap index_cap, int num_edges, MutableS2ShapeIndex index)
    {
        var fractal = new S2Testing.Fractal();

        fractal.SetLevelForApproxMaxEdges(num_edges);
        index.Add(new S2Loop.Shape(
                      fractal.MakeLoop(S2Testing.GetRandomFrameAt(index_cap.Center),
                                       index_cap.RadiusAngle())));
    }
Exemplo n.º 2
0
            public void AddPoints(S2Cap index_cap, int num_points, TestIndex index)
            {
                S2Testing.Fractal fractal = new();
                fractal.SetLevelForApproxMaxEdges(num_points);
                fractal.FractalDimension = (1.5);
                var loop = (
                    fractal.MakeLoop(S2Testing.GetRandomFrameAt(index_cap.Center),
                                     index_cap.RadiusAngle()));

                for (int i = 0; i < loop.NumVertices; ++i)
                {
                    index.Add(loop.Vertex(i), i);
                }
            }
Exemplo n.º 3
0
            public void AddPoints(S2Cap index_cap, int num_points, TestIndex index)
            {
                int            sqrt_num_points = (int)Math.Ceiling(Math.Sqrt(num_points));
                S2PointVector3 frame           = S2Testing.GetRandomFrameAt(index_cap.Center);
                double         radius          = index_cap.RadiusAngle().Radians;
                double         spacing         = 2 * radius / sqrt_num_points;

                for (int i = 0; i < sqrt_num_points; ++i)
                {
                    for (int j = 0; j < sqrt_num_points; ++j)
                    {
                        S2Point point = new(Math.Tan((i + 0.5) * spacing - radius),
                                            Math.Tan((j + 0.5) * spacing - radius), 1.0);
                        index.Add(S2.FromFrame(frame, point.Normalize()),
                                  i * sqrt_num_points + j);
                    }
                }
            }
Exemplo n.º 4
0
    public void Test_VisitIntersectingShapes_Polygons()
    {
        MutableS2ShapeIndex index = new();
        S2Cap center_cap          = new(new(1, 0, 0), S1Angle.FromRadians(0.5));

        S2Testing.Fractal fractal = new();
        for (int i = 0; i < 10; ++i)
        {
            fractal.SetLevelForApproxMaxEdges(3 * 64);
            S2Point center = S2Testing.SamplePoint(center_cap);
            index.Add(new S2Loop.Shape(
                          fractal.MakeLoop(S2Testing.GetRandomFrameAt(center),
                                           S1Angle.FromRadians(S2Testing.Random.RandDouble()))));
        }
        // Also add a big polygon containing most of the polygons above to ensure
        // that we test containment of cells that are ancestors of index cells.
        index.Add(NewPaddedCell(S2CellId.FromFace(0), 0));
        new VisitIntersectingShapesTest(index).Run();
    }
Exemplo n.º 5
0
    public void Test_S2LaxPolygonShape_CompareToS2Loop()
    {
        for (int iter = 0; iter < 100; ++iter)
        {
            var fractal = new S2Testing.Fractal();
            fractal.MaxLevel         = (S2Testing.Random.Uniform(5));
            fractal.FractalDimension = (1 + S2Testing.Random.RandDouble());
            S2Point center = S2Testing.RandomPoint();
            var     loop   = fractal.MakeLoop(
                S2Testing.GetRandomFrameAt(center), S1Angle.FromDegrees(5));

            // Compare S2Loop to S2LaxLoopShape.
            CompareS2LoopToShape(loop, new S2LaxLoopShape(loop));

            // Compare S2Loop to S2LaxPolygonShape.
            var loops = new List <List <S2Point> > {
                loop.CloneVertices().ToList()
            };
            CompareS2LoopToShape(loop, new S2LaxPolygonShape(loops));
        }
    }