Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Drawing;
- using System.Collections.Generic;
- namespace Identifier
- {
- public static class Points
- {
- private static bool ContainsPoint(Point p, Point[] pts)
- {
- foreach (Point pp in pts)
- {
- if (pp.X == p.X && pp.Y == p.Y)
- {
- return true;
- }
- }
- return false;
- }
- private static bool PointsInPoints(Point[] a, Point[] b)
- {
- foreach (Point p in a)
- {
- if (!ContainsPoint(p, b))
- return false;
- }
- return true;
- }
- private static bool Unique(Point[] a, Point[][] b, int skip)
- {
- for(int i = 0; i < b.Length; i++)
- {
- if (i <= skip) {
- continue;
- }
- if (PointsInPoints(a, b[i]))
- return false;
- }
- return true;
- }
- public static bool TPAsEqual(Point[] a, Point[] b)
- {
- if (a.Length == b.Length)
- {
- for (int i = 0; i < a.Length; i++)
- {
- if (!(a[i].X == b[i].X && a[i].Y == b[i].Y))
- return false;
- }
- return true;
- }
- return false;
- }
- public static Point[] FindUniqueSet(Point[] arr, Point[][] total, int max, int skip)
- {
- for (int i = 1; i < max; i++)
- {
- Combination<Point> c = new Combination<Point>(arr, i);
- int cc = 0;
- foreach (Point[] pts in c)
- {
- if (Unique(pts, total, skip))
- {
- Debug.WriteLine("Succesful Combination - Length: "+pts.Length);
- foreach (Point p in pts)
- {
- Debug.WriteLine("--> X: "+p.X+ " "+" Y: "+p.Y);
- }
- return pts;
- }
- cc++;
- if (cc > 50)
- break;
- }
- }
- return new Point[] {};
- }
- private static Point[] Crop(Point[] p)
- {
- int minX = p[0].X;
- int minY = p[0].Y;
- foreach (Point point in p)
- {
- if (point.X < minX)
- minX = point.X;
- if (point.Y < minY)
- minY = point.Y;
- }
- List<Point> n = new List<Point>();
- foreach (Point point in p)
- {
- n.Add(new Point(point.X - minX, point.Y - minY));
- }
- return n.ToArray();
- }
- }
- }
Add Comment
Please, Sign In to add comment