示例#1
0
 public Scan(Scan scan)
 {
     this.xyScan = new List <int[]>(scan.getXYScan());
     this.rByPhi = scan.getRbyPhi();
 }
示例#2
0
        private int X2 = -1, Y2 = -1; //supposed 1 scan center

        public void setCenter0(int X, int Y)
        {
            X0    = X;
            Y0    = Y;
            scan0 = new Scan();
        }
示例#3
0
 public void setCenter1(int X, int Y)
 {
     X1    = X;
     Y1    = Y;
     scan1 = new Scan();
 }
        /// <summary>
        /// Возвращает скан с точной карты в заданных координатах
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="scanColor">цвет скана для отрисовки</param>
        /// <returns></returns>
        public Scan getScan(int X, int Y, Color scanColor)
        {
            Scan scan = new Scan();
            int  y    = new int();
            int  x    = new int();
            bool flagR;        //Будет true, если на текущем угле сканирования видно препятствие, иначе false и радиус от текущего угла будет равен нулю
            bool flagRepeated; //Будет true, если точка уже сохранена в списке скана

            Random rand = new Random(System.DateTime.Now.Millisecond);

            //    Stopwatch stopwatch = Stopwatch.StartNew();
            for (int i = 0; i < Parameters.getN_phi(); i++)
            {
                flagR = false;
                for (ushort r = 1; r < Parameters.getR_scan1(); r++)
                {
                    x = (int)Math.Round(r * Math.Cos(i * Parameters.getScan_step()));
                    y = (int)Math.Round(r * Math.Sin(i * Parameters.getScan_step()));
                    if (preciseMap[x + X, y + Y].Color == Parameters.wallColor)
                    {
                        scan.rByPhi[i] = r;
                        flagRepeated   = false;
                        for (int j = 0; j < scan.xyScan.Count; j++)
                        {
                            if ((scan.xyScan[j][0] == x) && (scan.xyScan[j][1] == y))
                            {
                                flagRepeated = true;
                            }
                        }
                        if (!flagRepeated)
                        {
                            switch (r_scanNoiseMode)
                            {
                            case 1:
                                r = rNoising1(ref r, ref rand);
                                break;

                            case 2:
                                r = rNoising2(ref r, ref rand);
                                break;

                            case 3:
                                r = rNoising3(ref r, ref rand);
                                break;
                            }

                            x = (int)Math.Round(r * Math.Cos(i * Parameters.getScan_step()));
                            y = (int)Math.Round(r * Math.Sin(i * Parameters.getScan_step()));
                            scan.xyScan.Add(new int[2] {
                                x, y
                            });
                        }
                        scan.scanBmp[x + Parameters.getR_scan(), y + Parameters.getR_scan()] = new Pixel(scanColor);
                        flagR = true;
                        break;
                    }
                }
                if (!flagR)
                {
                    scan.rByPhi[i] = 0;
                }
            }

            //   stopwatch.Stop();
            //    Console.WriteLine("Time wasted: "+stopwatch.ElapsedMilliseconds);
            return(scan);
        }