public static SolutionSpec Solve(Polygon poly, SolutionSpec initialSolution, TimeSpan?timeout = null)
        {
            if (poly.GetSignedSquare() < 0)
            {
                throw new InvalidOperationException("poly.GetSignedSquare() < 0");
            }
            timeout = timeout ?? TimeSpan.FromSeconds(20);
            var sw       = Stopwatch.StartNew();
            var solution = initialSolution ?? SolutionSpec.CreateTrivial(x => x);

            do
            {
                var foldsCount = 0;
                foreach (var segment in poly.Segments)
                {
                    var s = solution.Fold(segment);
                    if (s != solution)
                    {
                        foldsCount++;
                    }
                    solution = s;
                }
                if (foldsCount == 0)
                {
                    return(solution);
                }
            } while (sw.Elapsed < timeout);
            Console.Write($"Solution folding failed to complete in: {timeout.Value} ");
            return(solution);
        }
        public void Writable()
        {
            var pts          = new[] { Vector.Parse("0,0"), Vector.Parse("0,1"), Vector.Parse("1,1"), Vector.Parse("1,0") };
            var solutionSpec = new SolutionSpec(pts, new[] { new Facet(0, 1, 2, 3) }, pts);

            Approvals.Verify(solutionSpec);
        }
Example #3
0
        private static SolutionSpec MakeFinalFolds(SolutionSpec sol, Rational k, IEnumerable <Vector> points)
        {
            //var starts = segments.ToLookup(s => s.Start);
            //var ends = segments.ToLookup(s => s.End);
            var count = 0;

            foreach (var p in points)
            {
                if (count == 3)
                {
                    break;
                }
                var segs = sol.GetAllDestSegments().Where(s => s.Start.Equals(p) || s.End.Equals(p));
                foreach (var segment in segs)
                {
                    var otherPoint = segment.Start.Equals(p) ? segment.End : segment.Start;
                    var direction  = otherPoint - p;
                    var near       = p + direction * k;
                    var mirror     = new Segment(near, near + new Vector(direction.Y, -direction.X));
                    var sol2       = sol.Fold(mirror);
                    //Console.WriteLine($"Increase = {sol2.Facets.Length - sol.Facets.Length}");
                    if (sol2.Facets.Length == sol.Facets.Length + 2)
                    {
                        sol = sol2.Fold(mirror.Move(direction * k));
                        count++;
                        //Console.WriteLine($"win at {p}");
                        break;
                    }
                }
            }
            return(sol);
        }
Example #4
0
        public void Paint(Graphics g, int size, SolutionSpec spec)
        {
            PaintBackground(g, size);
            g.ScaleTransform(size, size);

            PaintPolygons(g, spec.Polygons);
        }
 private static void PostSolution(int problemId, SolutionSpec solution)
 {
     try
     {
         var res = ProblemsSender.Post(solution, problemId);
         if (res == 1.0)
         {
             var repo           = new ProblemsRepo();
             var problemSpec    = repo.Get(problemId);
             var problemSpecStr = problemSpec.ToString();
             var toSend         = repo.GetAllNotSolvedPerfectly().Where(p => p.ToString() == problemSpecStr).ToList();
             foreach (var sameProb in toSend)
             {
                 res = Math.Min(res, ProblemsSender.Post(solution, sameProb.id));
             }
             MessageBox.Show($"Resemblance = 1.0. {toSend.Count} same problem. min resemblence = {res}");
         }
         else
         {
             MessageBox.Show("Resemblance = " + res + " no same problems");
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString(), e.Message);
     }
 }
        public static Form CreateVisualizerForm(this SolutionSpec solution, int problemId = -1)
        {
            var form  = new Form();
            var split = new SplitContainer();

            split.Dock = DockStyle.Fill;
            var menu = new MenuStrip();

            if (problemId >= 0)
            {
                menu.Items.Add("submit").Click += (sender, args) => PostSolution(problemId, solution);
            }
            form.Controls.Add(split);
            form.Controls.Add(menu);
            split.Panel1.DoubleClick += (sender, args) =>
            {
                CopyToClipboard(solution);
            };
            split.Panel2.DoubleClick += (sender, args) =>
            {
                CopyToClipboard(solution);
            };
            form.WindowState = FormWindowState.Maximized;
            Painter painter = new Painter();

            split.Panel1.Paint +=
                (sender, args) => painter.Paint(args.Graphics, Math.Min(split.Panel1.ClientSize.Height, split.Panel1.ClientSize.Width), solution);
            split.Panel2.Paint +=
                (sender, args) => painter.PaintDest(args.Graphics, Math.Min(split.Panel2.ClientSize.Height, split.Panel2.ClientSize.Width), solution);
            split.Resize += (sender, args) => split.Invalidate();
            form.Text     = "Solution (Doule click to copy solution to clipboard) " + problemId;
            return(form);
        }
Example #7
0
        public void PaintDest(Graphics g, int size, SolutionSpec spec)
        {
            PaintBackground(g, size);
            g.ScaleTransform(size, size);

            var i     = 0;
            var poly  = spec.PolygonsDest;
            var vs    = poly.SelectMany(p => p.Vertices).ToList();
            var minX  = vs.Select(v => v.X).Min();
            var minY  = vs.Select(v => v.Y).Min();
            var shift = -new Vector(minX, minY);
            var fi    = 0;

            foreach (var polygon in poly)
            {
                Color color = ColorTranslator.FromHtml("#" + ColourValues[(i++) % ColourValues.Length]);
                PaintPolygon(g, color, polygon.Move(-minX, -minY));
                var vi = 0;
                foreach (var vertex in polygon.Vertices)
                {
                    var v     = vertex + shift;
                    var font  = new Font("Arial", 0.04f);
                    var index = spec.Facets[fi].Vertices[vi];
                    g.DrawString(index.ToString(), font, Brushes.Black, v.X.AsFloat(), v.Y.AsFloat());
                    vi++;
                }
                fi++;
            }
        }
Example #8
0
 public void Solve(int problemId)
 {
     var problemsRepo = new ProblemsRepo();
     var problem      = problemsRepo.Get(problemId);
     var poly         = problem.Polygons.Single();
     //			var dx = (int) problem.Polygons.SelectMany(p => p.Vertices).Select(x => x.X.Denomerator).Max();
     //			var dy = (int) problem.Polygons.SelectMany(p => p.Vertices).Select(x => x.Y.Denomerator).Max();
     //			foreach (var x in Enumerable.Range(0, dx).Select(x => new Rational(x, dx)))
     //				foreach (var y in Enumerable.Range(0, dy).Select(y => new Rational(y, dy)))
     {
         //					var shift = new Vector(x, y);
         var shift              = new Vector(0, 0);
         var initialSolution    = SolutionSpec.CreateTrivial(v => v + shift);
         var solution           = ConvexPolygonSolver.Solve(poly.GetConvexBoundary(), initialSolution);
         var packedSolution     = solution.Pack();
         var packedSolutionSize = packedSolution.Size();
         var solutionSize       = solution.Size();
         Console.WriteLine($"{shift}: {solutionSize}; packed: {packedSolutionSize}");
         if (packedSolutionSize <= 5000)
         {
             ProblemsSender.Post(packedSolution, problemId, false);
             //						return;
         }
     }
 }
Example #9
0
 public string PostProblem(long publishTime, SolutionSpec solution)
 {
     if (sw.Elapsed < TimeSpan.FromSeconds(1))
     {
         Thread.Sleep(TimeSpan.FromSeconds(1));
     }
     try
     {
         using (var client = CreateClient())
         {
             var content = new MultipartFormDataContent();
             content.Add(new StringContent(publishTime.ToString()), "publish_time");
             content.Add(new StringContent(solution.ToString()), "solution_spec", "solution.txt");
             //workaround: http://stackoverflow.com/questions/31129873/make-http-client-synchronous-wait-for-response
             var res = client.PostAsync($"{baseUrl}problem/submit", content).ConfigureAwait(false).GetAwaiter().GetResult();
             if (!res.IsSuccessStatusCode)
             {
                 Console.WriteLine(res.ToString());
                 Console.WriteLine(res.Content.ReadAsStringAsync().Result);
                 throw new HttpRequestException(res.ReasonPhrase);
             }
             return(res.Content.ReadAsStringAsync().Result);
         }
     }
     finally
     {
         sw.Restart();
     }
 }
Example #10
0
        public void Fold_Demo()
        {
            var origSolution = SolutionSpec.CreateTrivial(x => x);
            var result       = origSolution.Fold("1,3/4 0,1/4");

            result = result.Fold("1,1 1/4,0");
            result.CreateVisualizerForm().ShowDialog();
        }
Example #11
0
        public void PackWithRotations_EmptySolution()
        {
            var origSolution = SolutionSpec.CreateTrivial();
            var result       = origSolution.PackWithRotations();

            result.SourcePoints.Should().Equal(origSolution.SourcePoints);
            result.Facets.Select(FacetToString).ToArray().Should().BeEquivalentTo(origSolution.Facets.Select(FacetToString));
            result.DestPoints.Should().Equal(origSolution.DestPoints);
        }
Example #12
0
        public void Fold_ByMiddleLine(string segment, string expectedSrcPoints, string expectedDestPoints, string expectedFacets)
        {
            var origSolution = SolutionSpec.CreateTrivial(x => x);
            var result       = origSolution.Fold(segment);

            result.SourcePoints.Should().Equal(expectedSrcPoints.Split('|').Select(Vector.Parse).ToArray());
            result.Facets.Select(FacetToString).ToArray().Should().BeEquivalentTo(expectedFacets.Split('|'));
            result.DestPoints.Should().Equal(expectedDestPoints.Split('|').Select(Vector.Parse).ToArray());
        }
Example #13
0
        public void Fold_ByBoundary(string segment, string expectedDestPoints)
        {
            var origSolution = SolutionSpec.CreateTrivial(x => x);
            var result       = origSolution.Fold(segment);

            result.SourcePoints.Should().Equal(origSolution.SourcePoints);
            result.Facets.Should().Equal(origSolution.Facets);
            result.DestPoints.Should().Equal(expectedDestPoints.Split('|').Select(Vector.Parse).ToArray());
        }
Example #14
0
        public void RemoveBadFacetsVertices_EmptySolution()
        {
            var origSolution = SolutionSpec.CreateTrivial();
            var result       = origSolution.RemoveBadFacetsVertices();

            result.SourcePoints.Should().Equal(origSolution.SourcePoints);
            result.Facets.Select(FacetToString).ToArray().Should().BeEquivalentTo(origSolution.Facets.Select(FacetToString));
            result.DestPoints.Should().Equal(origSolution.DestPoints);
        }
Example #15
0
        public void Fold_Nothing(string segment)
        {
            var origSolution = SolutionSpec.CreateTrivial(x => x);
            var result       = origSolution.Fold(segment);

            result.SourcePoints.Should().Equal(origSolution.SourcePoints);
            result.Facets.Should().Equal(origSolution.Facets);
            result.DestPoints.Should().Equal(origSolution.DestPoints);
        }
Example #16
0
        public static SolutionSpec TrySolveInOneShot(ProblemSpec problem, Polygon convexPolygon)
        {
            SolutionSpec solution        = null;
            var          initialSolution = TryGetInitialSolution(problem, convexPolygon);

            if (initialSolution != null)
            {
                solution = Solve(convexPolygon, initialSolution);
            }
            return(solution);
        }
Example #17
0
        public void PackFacetNumbers_TwiceFoldedSolution()
        {
            var origSolution         = SolutionSpec.CreateTrivial().Fold("1/2,0 1/2,1").Fold("1/2,1/2 0,1/2");
            var result               = origSolution.PackFacetNumbers();
            var expectedSourcePoints = "1/2,1/2|1/2,0|0,1/2|1/2,1|1,1/2|0,0|0,1|1,0|1,1";
            var expectedDestPoints   = "1/2,1/2|1/2,0|0,1/2|1/2,0|0,1/2|0,0|0,0|0,0|0,0";
            var expectedFacets       = "5 1 0 2|0 3 6 2|1 7 4 0|4 8 3 0";

            result.SourcePoints.Should().Equal(expectedSourcePoints.Split('|').Select(Vector.Parse).ToArray());
            result.DestPoints.Should().Equal(expectedDestPoints.Split('|').Select(Vector.Parse).ToArray());
            result.Facets.Select(FacetToString).ToArray().Should().BeEquivalentTo(expectedFacets.Split('|'));
        }
Example #18
0
        public void DoSomething_WhenSomething2(int problemId)
        {
            var repo         = new ProblemsRepo();
            var problemSpec  = repo.Get(problemId);
            var sourcePoints = new List <Vector>();
            var destPoints   = new List <Vector>();
            var facets       = new List <Facet>();

            for (int iX = 0; iX <= 31; iX++)
            {
                for (int iY = 0; iY <= 6; iY++)
                {
                    sourcePoints.Add(new Vector(iX / (Rational)31, iY / (Rational)6));
                    if (iY % 2 == 0)
                    {
                        if (iX % 2 == 0)
                        {
                            destPoints.Add("0,0");
                        }
                        else
                        {
                            destPoints.Add("1/31,0");
                        }
                    }
                    else
                    if (iX % 2 == 0)
                    {
                        destPoints.Add("0,1/6");
                    }
                    else
                    {
                        destPoints.Add("1/31,1/6");
                    }
                }
            }
            for (int iX = 0; iX < 31; iX++)
            {
                for (int iY = 0; iY < 6; iY++)
                {
                    facets.Add(new Facet(iX * 7 + iY, iX * 7 + 1 + iY, (iX + 1) * 7 + iY + 1, (iX + 1) * 7 + iY));
                }
            }
            var solution = new SolutionSpec(sourcePoints.ToArray(), facets.ToArray(), destPoints.ToArray());

            Console.Out.WriteLine($"size: {solution.Size()}; packed: {solution.Pack().Size()}");
            Console.Out.WriteLine($"facets: {solution.Facets.Length}; sourcePoints: {solution.SourcePoints.Length}; destPoints: {solution.DestPoints.Length}");

            //solution.CreateVisualizerForm().ShowDialog();

            var post = ProblemsSender.Post(solution, problemSpec.id);

            Console.Out.WriteLine(post);
        }
Example #19
0
        public static SolutionSpec Pack(this SolutionSpec source, bool deep = false)
        {
            if (source.Raw != null)
            {
                return(source);
            }
            var packed = source.DoNormalize().RemoveBadFacetsVertices().PackFacetNumbers();

            if (packed.Size() < 5000 && !deep)
            {
                return(packed);
            }
            return(packed.PackWithRotations());
        }
Example #20
0
        public SolutionSpec SolveMovingAndRotatingInitialSquare(ProblemSpec problem, int dpi = 10)
        {
            var shift = GetShift(problem);
            var ts    = from dx in Range(0, 1, dpi)
                        from dy in Range(0, 1, dpi)
                        let finalShift = shift.Move(dx, dy)
                                         from x in Range(0, 1, dpi * 2)
                                         select(Func <Vector, Vector>)(v => v.Rotate(x) + finalShift);
            var transform =
                ts.Select(t => Tuple.Create(t, SolutionEvaluator.EvaluateX(problem, SolutionSpec.CreateTrivial(t), dpi * 2)))
                .OrderByDescending(t => t.Item2)
                .FirstOrDefault()?.Item1;

            return(SolutionSpec.CreateTrivial(transform));
        }
Example #21
0
        public void PackWithRotations_Packs(string sourcePoints, string destPoints, string facets, string expectedSourcePoints, string expectedDestPoints, string expectedFacets)
        {
            var origSolution = new SolutionSpec(
                sourcePoints.Split('|').Select(Vector.Parse).ToArray(),
                facets.Split('|').Select(f => new Facet(f.Split(' ').Select(int.Parse).ToArray())).ToArray(),
                destPoints.Split('|').Select(Vector.Parse).ToArray());
            var expectedSolution = new SolutionSpec(
                expectedSourcePoints.Split('|').Select(Vector.Parse).ToArray(),
                expectedFacets.Split('|').Select(f => new Facet(f.Split(' ').Select(int.Parse).ToArray())).ToArray(),
                expectedDestPoints.Split('|').Select(Vector.Parse).ToArray());
            var result = origSolution.PackWithRotations();

            result.SourcePoints.Should().Equal(expectedSolution.SourcePoints);
            result.Facets.Select(FacetToString).ToArray().Should().BeEquivalentTo(expectedSolution.Facets.Select(FacetToString));
            result.DestPoints.Should().Equal(expectedSolution.DestPoints);
        }
Example #22
0
        public void EvaluateX(string problem, string solution, double expectedResult, double precision)
        {
            var problemPolygons = problem.Split('|').Select(x => new Polygon(x.Split(' ').Select(Vector.Parse).ToArray())).ToArray();
            var problemSpec     = new ProblemSpec(problemPolygons, new Segment[0]);

            var solutionPolygons = solution.Split('|').Select(x => new Polygon(x.Split(' ').Select(Vector.Parse).ToArray())).ToArray();
            var solutionPoints   = solutionPolygons.SelectMany(x => x.Vertices).Distinct().ToArray();
            var pointToIndex     = solutionPoints.Select((p, i) => new { p, i }).ToDictionary(x => x.p, x => x.i);
            var facets           = solutionPolygons.Select(x => new Facet(x.Vertices.Select(v => pointToIndex[v]).ToArray())).ToArray();
            var solutionSpec     = new SolutionSpec(solutionPoints, facets, solutionPoints);

            var evaluation = SolutionEvaluator.EvaluateX(problemSpec, solutionSpec, 100);

            Console.Out.WriteLine(evaluation);
            evaluation.Should().BeApproximately(expectedResult, precision);
        }
Example #23
0
        public static SolutionSpec TryGetInitialSolution(ProblemSpec problem, Polygon problemPolygon, TimeSpan?timeout = null)
        {
            timeout = timeout ?? TimeSpan.FromSeconds(10);
            SolutionSpec initialSolution = null;
            var          t = new Thread(() => { initialSolution = GetInitialSolutionByLongestRationalEdge(problemPolygon) ?? new ImperfectSolver().SolveMovingAndRotatingInitialSquare(problem); })
            {
                IsBackground = true
            };

            t.Start();
            if (!t.Join(timeout.Value))
            {
                t.Abort();
                t.Join();
                Console.Write($"Failed to get initial solution in {timeout}! Skipping");
            }
            return(initialSolution);
        }
Example #24
0
        public static SolutionSpec GetInitialSolutionAlongRationalEdge(Segment rationalEdge)
        {
            var initialSolution = SolutionSpec.CreateTrivial(x => x + rationalEdge.Start);
            var edgeLen         = new Rational(Arithmetic.Sqrt(rationalEdge.QuadratOfLength.Numerator), Arithmetic.Sqrt(rationalEdge.QuadratOfLength.Denomerator));
            var a = rationalEdge.ToVector() / edgeLen;
            var b = Vector.Parse("1,0");

            if (b.VectorProdLength(a) == 0)
            {
                if (b.ScalarProd(a) > 0)
                {
                    return(initialSolution);
                }
                return(initialSolution.Reflect(rationalEdge));
            }
            var bisect = new Segment(rationalEdge.Start, a + b + rationalEdge.Start);

            return(initialSolution.Reflect(bisect).Reflect(rationalEdge));
        }
Example #25
0
        public static SolutionSpec RemoveBadFacetsVertices(this SolutionSpec source)
        {
            var sourcePoints    = source.SourcePoints.ToList();
            var destPoints      = source.DestPoints.ToList();
            var facets          = source.Facets.ToList();
            var sourcePointsMap = sourcePoints.Select((p, i) => new { p, i }).ToDictionary(x => x.p, x => x.i);
            var usedVertices    = new HashSet <int>();

            for (var i = 0; i < facets.Count; i++)
            {
                var polygon        = new Polygon(facets[i].Vertices.Select(v => sourcePoints[v]).ToArray());
                var convexBoundary = polygon.RemoveExtraVertices();
                var newVertices    = convexBoundary.Vertices.Select(v => sourcePointsMap[v]).ToArray();
                facets[i] = new Facet(newVertices);
                usedVertices.UnionWith(newVertices);
            }
            var newIndexesMap = new Dictionary <int, int>();

            for (var origIndex = 0; origIndex < sourcePoints.Count; origIndex++)
            {
                if (usedVertices.Contains(origIndex))
                {
                    newIndexesMap[origIndex] = newIndexesMap.Count;
                }
            }
            for (var i = sourcePoints.Count - 1; i >= 0; i--)
            {
                if (!usedVertices.Contains(i))
                {
                    sourcePoints.RemoveAt(i);
                    destPoints.RemoveAt(i);
                }
            }
            foreach (var facet in facets)
            {
                for (int i = 0; i < facet.Vertices.Length; i++)
                {
                    facet.Vertices[i] = newIndexesMap[facet.Vertices[i]];
                }
            }

            return(new SolutionSpec(sourcePoints.ToArray(), facets.ToArray(), destPoints.ToArray()));
        }
Example #26
0
        public static double Evaluate(ProblemSpec problemSpec, SolutionSpec solutionSpec, int dpi)
        {
            var problemPolygons = problemSpec.Polygons;
            var destPoints      = solutionSpec.DestPoints.ToList();
            var allPoints       = problemPolygons.SelectMany(x => x.Vertices).Concat(destPoints).ToList();
            var minX            = allPoints.Min(x => x.X);
            var minY            = allPoints.Min(x => x.Y);
            var maxX            = allPoints.Max(x => x.X);
            var maxY            = allPoints.Max(x => x.Y);

            var positivePolygons = problemPolygons.Where(p => p.GetSignedSquare() >= 0).ToList();
            var negativePolygons = problemPolygons.Where(p => p.GetSignedSquare() < 0).ToList();
            var solutionPolygons = solutionSpec.Facets.Select(x => new Polygon(x.Vertices.Select(v => destPoints[v]).ToArray())).ToList();

            var deltaX       = (maxX - minX) / dpi;
            var deltaY       = (maxY - minY) / dpi;
            int intersection = 0;
            int union        = 0;

            for (var x = minX; x < maxX; x += deltaX)
            {
                for (var y = minY; y < maxY; y += deltaY)
                {
                    var p          = new Vector(x, y);
                    var inNegative = negativePolygons.Any(poly => p.GetPositionToPolygon(poly) == PointToPolygonPositionType.Inside);
                    var inPositive = positivePolygons.Any(poly => p.GetPositionToPolygon(poly) != PointToPolygonPositionType.Outside);
                    var inProblem  = inPositive && !inNegative;
                    var inSolution = solutionPolygons.Any(poly => p.GetPositionToPolygon(poly) != PointToPolygonPositionType.Outside);
                    if (inProblem && inSolution)
                    {
                        intersection++;
                    }
                    if (inProblem || inSolution)
                    {
                        union++;
                    }
                }
            }
            return((double)intersection / union);
        }
Example #27
0
        public static SolutionSpec PackFacetNumbers(this SolutionSpec source)
        {
            var rates = new Dictionary <int, int>();

            foreach (var facet in source.Facets)
            {
                foreach (var vertex in facet.Vertices)
                {
                    int rate;
                    rates.TryGetValue(vertex, out rate);
                    rates[vertex] = rate + 1;
                }
            }
            var orderedVertexes = rates.Select(r => new { vertex = r.Key, rate = r.Value }).OrderByDescending(r => r.rate).Select(r => r.vertex).ToList();
            var vertexesMap     = orderedVertexes.Select((v, i) => new { oldVertex = v, newVertex = i }).ToDictionary(x => x.oldVertex, x => x.newVertex);

            var sourcePoints = orderedVertexes.Select(v => source.SourcePoints[v]).ToArray();
            var facets       = source.Facets.Select(f => new Facet(f.Vertices.Select(v => vertexesMap[v]).ToArray())).ToArray();
            var destPoints   = orderedVertexes.Select(v => source.DestPoints[v]).ToArray();

            return(new SolutionSpec(sourcePoints, facets, destPoints));
        }
Example #28
0
        public static SolutionSpec PackWithRotations(this SolutionSpec source)
        {
            var best = source;

            for (int i = 0; i < 3; i++)
            {
                source = source.Rotate90();
                if (source.Size() < best.Size())
                {
                    best = source;
                }
            }
            source = source.ReflectSourcePoints("0,0 1,1");
            for (int i = 0; i < 4; i++)
            {
                source = source.Rotate90();
                if (source.Size() < best.Size())
                {
                    best = source;
                }
            }
            return(best);
        }
Example #29
0
        public SolutionSpec Kashalot(string r1 = "1/4", string r2 = "3/4")
        {
            var p1           = $"{r1},{r1}";
            var p2           = $"{r2},{r2}";
            var sourcePoints = $"0,0 0,1 1,1 1,0 {p1} {p2}".ToPoints();
            var destPoints   = $"0,0 1,0 1,1 1,0 {p1} {p2}".ToPoints();

            destPoints[0] = sourcePoints[0].Reflect($"{p1} 1,0");
            destPoints[2] = sourcePoints[2].Reflect($"{p2} 1,0");
            var res = new SolutionSpec(sourcePoints, new Facet[]
            {
                new Facet(0, 1, 4),
                new Facet(4, 1, 5),
                new Facet(1, 2, 5),
                new Facet(0, 4, 3),
                new Facet(3, 4, 5),
                new Facet(3, 5, 2),
            },
                                       destPoints
                                       );

            return(res);
        }
Example #30
0
        public SolutionSpec Kashalot2(string r1 = "1/16", string r2 = "1/4", string r3 = "4/5", string r4 = "24/25")
        {
            var p4           = $"{r1},{r1}";
            var p5           = $"{r2},{r2}";
            var p6           = $"{r3},{r3}";
            var p7           = $"{r4},{r4}";
            var sourcePoints = $"0,0 0,1 1,1 1,0 {p4} {p5} {p6} {p7}".ToPoints();
            var destPoints   = sourcePoints.ToArray();

            destPoints[1] = sourcePoints[1].Reflect("0,0 1,1");
            destPoints[4] = sourcePoints[4].Reflect($"{p5} 1,0");
            var p01 = sourcePoints[0].Reflect($"{p5} 1,0");

            destPoints[0] = p01.Reflect($"{destPoints[4]} 1,0");
            destPoints[7] = sourcePoints[7].Reflect($"{p6} 1,0");
            var p21 = sourcePoints[2].Reflect($"{p6} 1,0");

            destPoints[2] = p21.Reflect($"{destPoints[7]} 1,0");
            var res = new SolutionSpec(sourcePoints, new Facet[]
            {
                new Facet(1, 0, 4),
                new Facet(1, 5, 4),
                new Facet(1, 5, 6),
                new Facet(1, 7, 6),
                new Facet(1, 7, 2),
                new Facet(3, 0, 4),
                new Facet(3, 5, 4),
                new Facet(3, 5, 6),
                new Facet(3, 7, 6),
                new Facet(3, 7, 2),
            },
                                       destPoints
                                       );

            return(res);
        }