Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public Rplidar(Point _startPoint)
 {
     startPoint  = _startPoint;
     rp          = new SerialPort();
     rp.BaudRate = 115200;
     rp.PortName = "COM4";
     rp.Open();
     coor = new Coor();
 }
Exemplo n.º 3
0
        /* 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));
        }
Exemplo n.º 4
0
 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);
         }
     }
 }
Exemplo n.º 5
0
 public void Hide(Graphics g, Coor Ox)
 {
     try
     {
         foreach (var item in base.List)
         {
             item.Hide(g, Ox);
         }
     }
     catch (Exception) { }
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 public void Show(Graphics g, Coor Ox)
 {
     try
     {
         O.Show(g, Ox);
         foreach (var item in base.List)
         {
             item.Show(g, Ox);
         }
     }
     catch (Exception) { }
 }
Exemplo n.º 9
0
    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;
    }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
 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) { }
 }
Exemplo n.º 13
0
        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("存在しないベクトルです");
            }
        }
Exemplo n.º 14
0
        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("存在しないベクトルです");
            }
        }
Exemplo n.º 15
0
        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("存在しないベクトルです");
            }
        }
Exemplo n.º 16
0
        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);
                }
            }
        }
Exemplo n.º 17
0
        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;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        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());
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
 public Node(Coor coor, TileState tile)
 {
     this.Tile = tile;
     this.Coor = coor;
     this.Next = new Node[4];
 }
Exemplo n.º 22
0
 public double GetMeanAltitude(Coor coor, Func <int, double> func)
 {
     return(ColorsManager.LinearApproximation(GetDeltas(coor), func));
 }
Exemplo n.º 23
0
Arquivo: Rect.cs Projeto: Ring-r/opt
 /// <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];
 }
Exemplo n.º 24
0
Arquivo: Rect.cs Projeto: Ring-r/opt
 /// <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];
 }
Exemplo n.º 25
0
        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));
                    }
                }
            }
        }
Exemplo n.º 26
0
Arquivo: Rect.cs Projeto: Ring-r/opt
 /// <summary>
 /// Конструктор по-умолчанию.
 /// </summary>
 public Rect()
 {
     coor = new Coor();
 }
Exemplo n.º 27
0
Arquivo: R.cs Projeto: Ring-r/opt
 /// <summary>
 /// Конструктор по-умолчанию.
 /// </summary>
 public R()
 {
     size = new Coor();
 }
Exemplo n.º 28
0
 public Earth2014Manager(Coor center, int accuracyMin = 1, int radiusGrad = 10)
     : this(ReliefType.Bed, accuracyMin)
 {
     _center = center;
     /// FillBuffer(center, radiusGrad);
 }
Exemplo n.º 29
0
 public double GetMeanAltitude(Coor coor)
 {
     return(GetMeanAltitude(coor, P => Pixels[P].Altitude.Value));
 }
Exemplo n.º 30
0
 public Point2 Offset(Coor coor)
 {
     return(new Point2(
                (int)Math.Round(X(coor.X)),
                (int)Math.Round(Y(coor.Y))));
 }
Exemplo n.º 31
0
 private Coor AddVector(Coor coor1, Coor coor2)
 {
     return(new Coor(coor1.X + coor2.X, coor1.Y + coor2.Y));
 }
Exemplo n.º 32
0
Arquivo: Region.cs Projeto: Ring-r/opt
 /// <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];
 }
Exemplo n.º 33
0
        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));
        }
Exemplo n.º 34
0
Arquivo: R.cs Projeto: Ring-r/opt
 /// <summary>
 /// Скопировать размер из внешней переменной.
 /// </summary>
 /// <param name="size">Внешняя переменная.</param>
 public virtual void CopySizeFrom(Coor size)
 {
     for (int i = 0; i < Dim; i++)
         this.size[i] = size[i];
 }
Exemplo n.º 35
0
Arquivo: R.cs Projeto: Ring-r/opt
 /// <summary>
 /// Скопировать размер во внешнюю переменную.
 /// </summary>
 /// <param name="size">Внешняя переменная.</param>
 public virtual void CopySizeTo(Coor size)
 {
     for (int i = 0; i < Dim; i++)
         size[i] = this.size[i];
 }
Exemplo n.º 36
0
 public int FullOffset(Coor coor)
 {
     return((int)Math.Round(
                (/*rounding is important*/ Math.Round(Y(coor.Y)) * _width)
                + X(coor.X)));
 }
Exemplo n.º 37
0
 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);
 }