Exemple #1
0
        protected static IEnumerable <WayPoint> ImportWayPoints(string filePath)
        {
            var list = new List <WayPoint>();

            foreach (var s in new StringReader(hc[filePath]).ReadToEnd().Split(new [] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                var xs = s.Split();
                var wp = new WayPoint {
                    Coordinates = new Point
                    {
                        X = Convert.ToInt32(xs[0]),
                        Y = Convert.ToInt32(xs[1])
                    }
                };

                if (xs.Length == 3)
                {
                    wp.Angle = Math.PI * 2 - Convert.ToDouble(xs[2], CultureInfo.InvariantCulture) + 2 * Math.PI;
                }

                list.Add(wp);
            }

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].Angle < 2 * Math.PI)
                {
                    list[i].Angle = AngleUtils.GetDirection(list[i].Coordinates, list[(i + 1) % list.Count].Coordinates);
                }
                list[i].Angle = AngleUtils.Normalize(list[i].Angle);
            }
            return(list);
        }