示例#1
0
        private List<Particle> initParticles()
        {
            List<Particle> particles = new List<Particle>();
            Random rand=new Random();
            MapRegion region = m_rm.region;

            for (int i = 0; i < m_particleNum;i++ )
            {
                int roadIndex = rand.Next(region.roads.Count);

                Road road = region.roads[roadIndex];

                int segment = rand.Next(road.points.Count-1);

                double k = (road.points[segment + 1].y - road.points[segment].y) /
                    (road.points[segment + 1].x - road.points[segment].x);
                double a = road.points[segment].y - k * road.points[segment].x;

                double x = rand.NextDouble() * (road.points[segment + 1].x - road.points[segment].x) +
                    road.points[segment].x;
                double y = k * x + a;

                Particle p=new Particle(new MapPoint(x,y),road.id);
                particles.Add(p);
            }

            return particles;
        }
示例#2
0
 bool moveParticle(out Particle p,DistAngleInfo movement)
 {
 }