Ejemplo n.º 1
0
        private static void HyperidealSquares()
        {
            Mobius rot = new Mobius();

            rot.Isometry(Geometry.Spherical, Math.PI / 4, new Vector3D());

            List <Segment> segs = new List <Segment>();

            int[] qs = new int[] { 5, -1 };
            foreach (int q in qs)
            {
                TilingConfig   config   = new TilingConfig(4, q, 1);
                Tile           t        = Tiling.CreateBaseTile(config);
                List <Segment> polySegs = t.Boundary.Segments;
                polySegs = polySegs.Select(s => { s.Transform(rot); return(s); }).ToList();
                segs.AddRange(polySegs);
            }

            Vector3D v1 = new Vector3D(1, 0);

            v1.RotateXY(Math.PI / 6);
            Vector3D v2 = v1;

            v2.Y *= -1;
            Vector3D cen;
            double   rad;

            H3Models.Ball.OrthogonalCircle(v1, v2, out cen, out rad);
            Segment seg = Segment.Arc(v1, v2, cen, false);

            rot.Isometry(Geometry.Spherical, Math.PI / 2, new Vector3D());
            for (int i = 0; i < 4; i++)
            {
                seg.Transform(rot);
                segs.Add(seg.Clone());
            }

            SVG.WriteSegments("output1.svg", segs);

            System.Func <Segment, Segment> PoincareToKlein = s =>
            {
                return(Segment.Line(
                           HyperbolicModels.PoincareToKlein(s.P1),
                           HyperbolicModels.PoincareToKlein(s.P2)));
            };
            segs = segs.Select(s => PoincareToKlein(s)).ToList();

            Vector3D v0 = new Vector3D(v1.X, v1.X);
            Vector3D v3 = v0;

            v3.Y *= -1;
            Segment seg1 = Segment.Line(v0, v1), seg2 = Segment.Line(v2, v3);
            Segment seg3 = Segment.Line(new Vector3D(1, 1), new Vector3D(1, -1));

            for (int i = 0; i < 4; i++)
            {
                seg1.Transform(rot);
                seg2.Transform(rot);
                seg3.Transform(rot);
                segs.Add(seg1.Clone());
                segs.Add(seg2.Clone());
                segs.Add(seg3.Clone());
            }

            SVG.WriteSegments("output2.svg", segs);
        }