public void GetCodeTest(int x, int y) { ulong t = Hilbert.GetCode(new Vector2Int(x, y)); t = (t << 2) >> 2; Console.WriteLine(t); }
public static List <PointF> Execute(int depth, float delta) { List <PointF> rv = new List <PointF>(); float dy = 0; float dx = delta; rv.Add(new PointF(0, 0)); Hilbert h = new Hilbert(); h.DoHilbert(rv, depth, dx, dy); return(rv); }
private static void rot_test() //****************************************************************************80 // // Purpose: // // ROT_TEST tests ROT. // // Modified: // // 02 January 2016 // // Author: // // John Burkardt // { int y; Console.WriteLine(""); Console.WriteLine("ROT_TEST:"); Console.WriteLine(" ROT rotates and flips a quadrant appropriately."); Console.WriteLine(""); Console.WriteLine(" X Y X0 Y0 X1 Y1"); Console.WriteLine(""); int m = 3; int n = (int)Math.Pow(2, m); int ry = 0; for (y = 0; y < 8; y++) { int x; for (x = 0; x < 8; x++) { int rx = 0; int x0 = x; int y0 = y; Hilbert.rot(n, ref x0, ref y0, rx, ry); rx = 1; int x1 = x; int y1 = y; Hilbert.rot(n, ref x1, ref y1, rx, ry); Console.WriteLine(" " + x.ToString().PadLeft(2) + " " + y.ToString().PadLeft(2) + " " + x0.ToString().PadLeft(2) + " " + y0.ToString().PadLeft(2) + " " + x1.ToString().PadLeft(2) + " " + y1.ToString().PadLeft(2) + ""); } } }
private static void xy2d_test() //****************************************************************************80 // // Purpose: // // XY2D_TEST tests XY2D. // // Modified: // // 24 December 2015 // // Author: // // John Burkardt // { int x; int y; Console.WriteLine(""); Console.WriteLine("XY2D_TEST:"); Console.WriteLine(" XY2D converts an (X,Y) 2D coordinate to a Hilbert linear D coordinate."); int m = 3; int n = (int)Math.Pow(2, m); Console.WriteLine(""); string cout = " "; for (x = 0; x < n; x++) { cout += x.ToString().PadLeft(3); } Console.WriteLine(cout); Console.WriteLine(""); for (y = n - 1; 0 <= y; y--) { cout = " " + y.ToString().PadLeft(3) + ": "; for (x = 0; x < n; x++) { int d = Hilbert.xy2d(m, x, y); cout += d.ToString().PadLeft(3); } Console.WriteLine(cout); } }
private void Start() { winLabel.SetActive(false); loseLabel.SetActive(false); TheoremConfig theorem = theorems[Random.Range(0, theorems.Length)]; theoremSymbols = theorem.GetTheoremSymbols(); hilbert = FindObjectOfType <Hilbert>(); speechController = FindObjectOfType <SpeechBubbleController>(); levelController = FindObjectOfType <LevelController>(); symbolSpawner = FindObjectOfType <SymbolSpawner>(); symbolSpawner.SetTheoremImage(theorem); StartCoroutine(symbolSpawner.SpawnSymbols(theorem)); }
private static void d2xy_test() //****************************************************************************80 // // Purpose: // // D2XY_TEST tests D2XY. // // Modified: // // 24 December 2015 // // Author: // // John Burkardt // { int d; int x = 0; int y = 0; Console.WriteLine(""); Console.WriteLine("D2XY_TEST:"); Console.WriteLine(" D2XY converts a Hilbert linear D coordinate to an (X,Y) 2D coordinate."); const int m = 3; int n = (int)Math.Pow(2, m); Console.WriteLine(""); Console.WriteLine(" D X Y"); Console.WriteLine(""); for (d = 0; d < n * n; d++) { Hilbert.d2xy(m, d, ref x, ref y); Console.WriteLine(" " + d.ToString().PadLeft(3) + " " + x.ToString().PadLeft(3) + " " + y.ToString().PadLeft(3) + ""); } }
static void AddGridSubject(Clipper c, double w, double h, LaserGRBL.GrblFile.L2LConf cnf) { LaserGRBL.RasterConverter.ImageProcessor.Direction dir = cnf.dir; double step = cnf.res / cnf.fres; double dstep = step * Math.Sqrt(2); //step for diagonal (1.414) double rdstep = step * (1 / Math.Sqrt(2)); //step for diagonal (1.414) List <List <IntPoint> > paths = new List <List <IntPoint> >(); //se si vuole sfasare per via dell'offset è necessario applicare questa correzione a x e y //ma i risultati possono essere brutti rispetto a ciò che ci si aspetta //double stepmm = 1 / cnf.fres; //double cX = (stepmm - cnf.oX % stepmm) * cnf.res; //double cY = (stepmm - cnf.oY % stepmm) * cnf.res; if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewHorizontal || dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewGrid) { for (int y = 1; y < (h / step); y++) { AddSegment(paths, 0, y * step, w, y * step, y % 2 == 1); } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewVertical || dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewGrid) { for (int x = 1; x < (w / step); x++) { AddSegment(paths, x * step, 0, x * step, h, x % 2 == 0); } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewDiagonal || dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewDiagonalGrid) { for (int i = 0; i < (w + h) / dstep; i++) { AddSegment(paths, 0, i * dstep, i * dstep, 0, i % 2 == 0); } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewReverseDiagonal || dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewDiagonalGrid) { for (int i = 0; i < (w + h) / dstep; i++) { AddSegment(paths, 0, h - (i * dstep), i * dstep, h, i % 2 == 1); } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewCross) { double cl = step / 3; //cross len for (int y = 1; y < (h / step); y++) { for (int x = 1; x < (w / step); x++) { AddSegment(paths, (x * step) - cl, y * step, (x * step) + cl, y * step, y % 2 == 1); //stanghette orizzontali AddSegment(paths, x * step, (y * step) - cl, x * step, (y * step) + cl, x % 2 == 0); //stanghette verticali } } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewDiagonalCross) { double cl = rdstep / 3; for (int y = 0; y < (h / step) + 1; y++) { for (int x = 0; x < (w / step) + 1; x++) { AddSegment(paths, (x * step) - cl, (y * step) - cl, (x * step) + cl, (y * step) + cl, x % 2 == 1); //stanghetta verso l'alto AddSegment(paths, (x * step) + cl, (y * step) - cl, (x * step) - cl, (y * step) + cl, x % 2 == 1); //stanghetta verso il basso } } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewSquares) { double cl = step / 3; for (int y = 0; y < (h / step) + 1; y++) { for (int x = 0; x < (w / step) + 1; x++) { List <IntPoint> list = new List <IntPoint>(); AddPathPoint(list, (x * step) - cl, y * step); AddPathPoint(list, x * step, (y * step) + cl); AddPathPoint(list, (x * step) + cl, y * step); AddPathPoint(list, x * step, (y * step) - cl); AddPathPoint(list, (x * step) - cl, y * step); AddPathPoints(paths, list); } } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewZigZag) { double hs = dstep / 2; //halfstep for (int i = 1; i < (w + h) / dstep; i++) { List <IntPoint> list = new List <IntPoint>(); if (i % 2 == 1) { double my = 0; double mx = (i * dstep) - hs; AddPathPoint(list, mx, my); while (mx > 0) { AddPathPoint(list, mx, my += hs); AddPathPoint(list, mx -= hs, my); } } else { double mx = 0; double my = (i * dstep) - hs; AddPathPoint(list, mx - 1, my + 1); //non togliere questo +/-1, sembra che freghi l'algoritmo clipper obbligandolo a mantenere la mia direzione AddPathPoint(list, mx, my); while (my > 0) { AddPathPoint(list, mx += hs, my); AddPathPoint(list, mx, my -= hs); } } AddPathPoints(paths, list); } } if (dir == LaserGRBL.RasterConverter.ImageProcessor.Direction.NewHilbert) { int n = 6; float ts = (float)(Math.Pow(2, n) * step); //genera un elemento da n ricorsioni su step //la sua dimensione sarà 2^n * step List <PointF> texel = Hilbert.Execute(n, (float)(step)); for (int y = 0; y < (h / ts); y++) { for (int x = 0; x < (w / ts); x++) { List <IntPoint> list = new List <IntPoint>(); for (int i = 0; i < texel.Count; i++) { AddPathPoint(list, texel[i].X + (x * ts), texel[i].Y + (y * ts)); } AddPathPoints(paths, list); } } } c.AddPaths(paths, PolyType.ptSubject, false); }
public void GetPositionTest(ulong code) { Vector2Int re = Hilbert.GetPosition(code); Console.WriteLine(re); }
public void GetNearTest(ulong code, int mark) { ulong t = Hilbert.GetNear(code, mark); Console.WriteLine(Hilbert.GetPosition(t)); }