public void Show(Graphics g, Coor O) { this.O.Show(g, O); this.C1.Show(g, O); this.E1.Show1(g, O); this.E2.Show2(g, O); }
public Rplidar(Point _startPoint) { startPoint = _startPoint; rp = new SerialPort(); rp.BaudRate = 115200; rp.PortName = "COM4"; rp.Open(); coor = new Coor(); }
/* data in spherical geocoordinates!!! * 5 arc-min grids contain 2,160 x 4,320 data points, are 18 MB in size and extend from * -90+5/120 deg to +90-5/120 deg in latitude direction, and from * -180+5/120 deg to +180-5/120 deg in longitude direction. * * for 1 arc-min The first record is the South-West corner (-89.9917 deg latitude, * -179.9917 deg longitude), and the last record is the North-East corner * (89.9917 deg latitude, 179.9917 deg latitude) * Each grid file contains 10,800 x 21,600 = 233,280,000 records */ public int Offset(int accuracyMin = 1) { var equirectangular = new Equirectangular(accuracyMin); var coor = new Coor { X = X, Y = -Y }; return(equirectangular.FullOffset(coor)); }
public void InitBoard() { for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { Coor.Add(new Position("A1", 1).GetCoordinateFrom(i, j), 0); } } }
public void Hide(Graphics g, Coor Ox) { try { foreach (var item in base.List) { item.Hide(g, Ox); } } catch (Exception) { } }
public void Constructor() { var coor = new Coor("70.1:52"); Assert.AreEqual(70.1d, coor.X); Assert.AreEqual(52, coor.Y); coor = new Coor(new Point2(-90, 90)); Assert.AreEqual(Math.PI * 1.5, coor.Lambda); Assert.AreEqual(0, coor.Beta); }
public void Show(Graphics g, Coor O) { foreach (Segment n in nega) { n.Show(g, O, true); } foreach (Segment n in pose) { n.Show(g, O); } }
public void Show(Graphics g, Coor Ox) { try { O.Show(g, Ox); foreach (var item in base.List) { item.Show(g, Ox); } } catch (Exception) { } }
private void CreateBody(Hipstar body) { var go = Instantiate(SpherePrefab); go.transform.position = Coor.GetPosition(body); var radius = (float)body.radius * 2; go.transform.localScale = new Vector3(radius, radius, radius); var text = go.GetComponentsInChildren <TextMesh>(); text[0].text = body.name; text[1].text = body.desig; }
private static Coor Next(Coor coor) { if (coor.X == Field.Size - 1) { if (coor.Y == Field.Size - 1) { return(new Coor(0, 0)); } return(new Coor(0, coor.Y + 1)); } coor.X++; return(coor); }
private void AddDelta(Coor coor, Dictionary <int, double> deltas, int nearestFirstRingPixel) { int previous; FindNearestPixelInRing(coor, ref nearestFirstRingPixel, out previous); var delta = Pixels[nearestFirstRingPixel] - coor; deltas.Add(nearestFirstRingPixel, (delta * delta).Sum); if (nearestFirstRingPixel != previous) { delta = Pixels[previous] - coor; deltas.Add(previous, (delta * delta).Sum); } }
public void Show1(Graphics g, Coor Ox) { try { O.Show(g, Ox); foreach (var item in base.List) { if (item.X > O.X) { item.Show(g, Descart.Point, Ox, Form1.PX / 2); } else { item.Show(g, Ox); } } } catch (Exception) { } }
public static Coor OneStep(Coor start, int direction) { switch (direction) { case 0: return(new Coor(start.X - 1, start.Y)); case 1: return(new Coor(start.X, start.Y - 1)); case 2: return(new Coor(start.X + 1, start.Y)); case 3: return(new Coor(start.X, start.Y + 1)); default: throw new Exception("存在しないベクトルです"); } }
private bool IsOut(Coor coor, int vector) { switch (vector) { case 0: return(coor.X == -1); case 1: return(coor.Y == -1); case 2: return(coor.X == Field.Size); case 3: return(coor.Y == Field.Size); default: throw new Exception("存在しないベクトルです"); } }
private Coor OneBack(Coor coor, int direction) { switch (direction) { case 0: return(new Coor(coor.X + 1, coor.Y)); case 1: return(new Coor(coor.X, coor.Y + 1)); case 2: return(new Coor(coor.X - 1, coor.Y)); case 3: return(new Coor(coor.X, coor.Y - 1)); default: throw new Exception("存在しないベクトルです"); } }
private static Coor?MoveToStop(Coor start, int direction) { var next = start; Coor last; while (true) { last = next; next = OneStep(last, direction); var canMove = (CanMove(next)); if (canMove == null) { return(null); } else if (canMove == false) { return(last); } } }
public static void Calculate(ref Coor[] maxStartPosition, ref int[] maxRoute) { maxStartPosition = new Coor[Field.BallNum]; int maxpoint = 0; int katamuke = 0; var startBallPosition = new Coor[Field.BallNum]; for (int x0 = 0; x0 < Field.Size; x0++) { for (int y0 = 0; y0 < Field.Size; y0++) { for (int x1 = 0; x1 < Field.Size; x1++) { for (int y1 = 0; y1 < Field.Size; y1++) { if (Field.OriginalBoad[x0, y0] == TileState.Wall || Field.OriginalBoad[x1, y1] == TileState.Wall || (x0 == x1 && y0 == y1) ) { continue; } startBallPosition[0] = new Coor(x0, y0); startBallPosition[1] = new Coor(x1, y1); var field = new S10B2_O(); field.CalculateAllRoute(startBallPosition); if (field.MaxPoint > maxpoint || (field.MaxPoint == maxpoint && field.MaxRoute.Length > katamuke)) { maxpoint = field.MaxPoint; maxStartPosition[0] = startBallPosition[0]; maxStartPosition[1] = startBallPosition[1]; maxRoute = field.MaxRoute; katamuke = field.MaxRoute.Length; } } } } } }
public KeyValuePair <int, double>[] GetDeltas(Coor coor) { // find nearest 2 rings, may be 1 ring in polar areas var approximately = (int)((90 - coor.Y) / 180 * Pixels.Length); // beginning of ring above coor var nearestFirstRingPixelUp = Math.Max(Math.Min(Pixels.Length - 1, approximately), 0); nearestFirstRingPixelUp -= Pixels[nearestFirstRingPixelUp].PixelInRing - 1; while (nearestFirstRingPixelUp > 0 && coor.Y > Pixels[nearestFirstRingPixelUp].Y) { nearestFirstRingPixelUp -= HealpixManager.PixelsCountInRing(Pixels[nearestFirstRingPixelUp - 1].Ring); } // beginning of ring under coor var nearestFirstRingPixelDown = Math.Max(0, nearestFirstRingPixelUp); while (nearestFirstRingPixelDown < Pixels.Length && coor.Y < Pixels[nearestFirstRingPixelDown].Y) { nearestFirstRingPixelDown += HealpixManager.PixelsCountInRing(Pixels[nearestFirstRingPixelDown].Ring); } var deltas = new Dictionary <int, double>(); if (nearestFirstRingPixelUp >= 0) { AddDelta(coor, deltas, nearestFirstRingPixelUp); } if (nearestFirstRingPixelDown < Pixels.Length && nearestFirstRingPixelDown != nearestFirstRingPixelUp) { AddDelta(coor, deltas, nearestFirstRingPixelDown); } // approximation-normalization only for 2 closest points return((from d in deltas orderby d.Value select d).Take(2).ToArray()); }
public Coor Xy2Ang(HealpixPos healPos) { var result = new Coor(); if (Math.Abs(healPos.Y) > Math.PI / 2 * (K - 1) / H) { // polar var sign = healPos.Y > 0 ? 1 : -1; var sigma = (K + 1d) / 2 - Math.Abs(healPos.Y * H) / Math.PI; result.Beta = sign * Math.Asin(1 - sigma * sigma / K); var omega = K % 2 == 1 || result.Beta > 0 ? 1 : 0; var xc = -Math.PI + (2 * Math.Floor((healPos.X + Math.PI) * H / (2 * Math.PI) + (1d - omega) / 2) + omega) * Math.PI / H; result.Lambda = xc + (healPos.X - xc) / sigma; } else { // equatorial result.Lambda = healPos.X; result.Beta = Math.Asin(healPos.Y * H * 2 / (Math.PI * K)); } return(result); }
public void Offset() { var e = new Equirectangular(5); var coor = new Coor { X = 0, Y = 0 }; Assert.AreEqual(2160, e.Offset(coor).X); Assert.AreEqual(1080, e.Offset(coor).Y); e = new Equirectangular(new HealpixManager(5)); Assert.AreEqual(64, e.Offset(coor).X); // or 64? Assert.AreEqual(32, e.Offset(coor).Y); coor = new Coor { X = 180, Y = -90 }; Assert.AreEqual(127, e.Offset(coor).X); Assert.AreEqual(64, e.Offset(coor).Y); // or 64? coor = new Coor { X = -180, Y = -90 }; Assert.AreEqual(0, e.Offset(coor).X); }
public Node(Coor coor, TileState tile) { this.Tile = tile; this.Coor = coor; this.Next = new Node[4]; }
public double GetMeanAltitude(Coor coor, Func <int, double> func) { return(ColorsManager.LinearApproximation(GetDeltas(coor), func)); }
/// <summary> /// Получить координату размещения по индексу. /// </summary> /// <param name="index">Индекс.</param> /// <returns>Координата размещения.</returns> public void CopyCoorTo(Coor coor) { for (int i = 0; i < Dim; i++) coor[i] = this.coor[i]; }
/// <summary> /// Установить координату размещения по индексу. /// </summary> /// <param name="index">Индекс.</param> /// <param name="value">Новое значение координаты размещения.</param> /// <returns>Координата размещения.</returns> public void CopyCoorFrom(Coor coor) { for (int i = 0; i < Dim; i++) this.coor[i] = coor[i]; }
public static void CreateBoad() { Boad = new Node[Field.Size, Field.Size]; CanOutList = new List <Coor>(); //初期化 for (int x = 0; x < Field.Size; x++) { for (int y = 0; y < Field.Size; y++) { Boad[x, y] = new Node(new Coor(x, y), Field.OriginalBoad[x, y]); } } //対応付け(node初期化) for (int x = 0; x < Field.Size; x++) { for (int y = 0; y < Field.Size; y++) { var coor = new Coor(x, y); var targetTile = Boad[coor.X, coor.Y]; for (int direction = 0; direction < 4; direction++) { var nextTile = MoveToStop(coor, direction); if (nextTile != null) { targetTile.Next[direction] = Boad[nextTile.Value.X, nextTile.Value.Y]; } } } } //外に出られるノードを探す var count = 1; while (count != 0) { count = 0; for (int x = 0; x < Field.Size; x++) { for (int y = 0; y < Field.Size; y++) { // まだCanOutになっていなくて、CanOutに移動できるものはTrue if (Field.OriginalBoad[x, y] != TileState.Wall && !Boad[x, y].CanOut && (Boad[x, y].Next.Contains(null) || Boad[x, y].Next.Any(n => n.CanOut))) { Boad[x, y].CanOut = true; count++; } } } Console.WriteLine("count=" + count); } // 外に出られるノードのリスト for (int x = 0; x < Field.Size; x++) { for (int y = 0; y < Field.Size; y++) { if (Field.OriginalBoad[x, y] != TileState.Wall && Boad[x, y].CanOut ) { CanOutList.Add(new Coor(x, y)); } } } }
/// <summary> /// Конструктор по-умолчанию. /// </summary> public Rect() { coor = new Coor(); }
/// <summary> /// Конструктор по-умолчанию. /// </summary> public R() { size = new Coor(); }
public Earth2014Manager(Coor center, int accuracyMin = 1, int radiusGrad = 10) : this(ReliefType.Bed, accuracyMin) { _center = center; /// FillBuffer(center, radiusGrad); }
public double GetMeanAltitude(Coor coor) { return(GetMeanAltitude(coor, P => Pixels[P].Altitude.Value)); }
public Point2 Offset(Coor coor) { return(new Point2( (int)Math.Round(X(coor.X)), (int)Math.Round(Y(coor.Y)))); }
private Coor AddVector(Coor coor1, Coor coor2) { return(new Coor(coor1.X + coor2.X, coor1.Y + coor2.Y)); }
/// <summary> /// Скопировать размер из внешней переменной. /// </summary> /// <param name="size">Внешняя переменная.</param> public override void CopySizeFrom(Coor size) { for (int i = 0; i < Dim; i++) if (!freez[i]) this.size[i] = size[i]; }
public double GetMeanDeltas(Coor coor, bool forBmp = false) { var s = (from d in GetDeltas(coor) orderby d.Value select d.Value).Take(2).Sum(); return(forBmp ? s * 5 : Math.Sqrt(s)); }
/// <summary> /// Скопировать размер из внешней переменной. /// </summary> /// <param name="size">Внешняя переменная.</param> public virtual void CopySizeFrom(Coor size) { for (int i = 0; i < Dim; i++) this.size[i] = size[i]; }
/// <summary> /// Скопировать размер во внешнюю переменную. /// </summary> /// <param name="size">Внешняя переменная.</param> public virtual void CopySizeTo(Coor size) { for (int i = 0; i < Dim; i++) size[i] = this.size[i]; }
public int FullOffset(Coor coor) { return((int)Math.Round( (/*rounding is important*/ Math.Round(Y(coor.Y)) * _width) + X(coor.X))); }
private static bool?CanMove(Coor coor) { return((coor.X == -1 || coor.Y == -1 || coor.X == Field.Size || coor.Y == Field.Size) ? (bool?)null : Field.OriginalBoad[coor.X, coor.Y] != TileState.Wall); }