Beispiel #1
0
        //public static List<LineSegment> GetLineSegments(List<DataUnit> items, double xSpeed, double ySpeed, double xAcceleration, double yAcceleration)
        //{
        //    return null;
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="items"></param>
        /// <param name="speed"></param>
        /// <param name="acceleration"></param>
        /// <returns>Item1: time, Item2: distance</returns>
        public static Tuple <double, double> GetMachineInfo(List <DataUnit> items, double speed, double acceleration)
        {
            double sumLen  = 0;
            double sumTime = 0;

            foreach (var m in items)
            {
                double len   = m.Length;
                double time  = 0;
                var    lines = new List <LineSegment>();
                if (m.Id == DataUnitTypes.Polyline)
                {
                    lines = MovementUtil.GetPolylineData(m.Points, speed, acceleration);
                }
                else
                {
                    lines = MovementUtil.GetArcData(m.Points, speed, acceleration);
                }
                foreach (var m1 in lines)
                {
                    double distance = Math.Sqrt(Math.Pow(m1.XDistance, 2) + Math.Pow(m1.YDistance, 2));
                    double speed1   = Math.Sqrt(Math.Pow(m1.XSpeed, 2) + Math.Pow(m1.YSpeed, 2));
                    double time1    = distance / speed1;
                    if (!double.IsNaN(time1) && !double.IsInfinity(time1))
                    {
                        time += time1;
                    }
                }
                sumLen  += len;
                sumTime += time;
            }

            return(Tuple.Create(sumTime, sumLen));
        }
Beispiel #2
0
        public static List <LineSegment> GetLineSegments(List <DataUnit> items, double speed, double acceleration)
        {
            var lines = new List <LineSegment>();

            foreach (var m in items)
            {
                if (m.Id == DataUnitTypes.Polyline)
                {
                    var tmp = MovementUtil.GetPolylineData(m.Points, speed, acceleration);
                    lines.AddRange(tmp);
                }
                else
                {
                    var tmp = MovementUtil.GetArcData(m.Points, speed, acceleration);
                    lines.AddRange(tmp);
                }
            }
            return(lines);
        }