コード例 #1
0
        public Particle(double _x, double _y, IDrawer _drawer)
        {
            Drawer           = _drawer;
            m_CoordinatesNew = m_Coordinates = new PairDouble(_x, _y);

            Random k = new Random((int)DateTime.Now.ToBinary());
            Random r = new Random(k.GetHashCode());

            m_Speed = new PairDouble(Miscelaneous.ParticleSpeed * (0.5 - r.NextDouble()), Miscelaneous.ParticleSpeed * (0.5 - r.NextDouble()));
            m_Speed.Normalize();
        }
コード例 #2
0
        public virtual void Interract()
        {
            var cumulativeSpeed = new PairDouble(0, 0);

            foreach (var particle in m_Nearest)
            {
                cumulativeSpeed = cumulativeSpeed + particle.SpeedInDouble;
            }
            PairDouble averSpd = cumulativeSpeed / m_Nearest.Count();

            averSpd.Normalize();

            if (averSpd.IsNaN())
            {
                averSpd = new PairDouble(0, 0);
            }

            m_Speed = averSpd * Miscelaneous.ParticleSpeed;
            AddNoize(Miscelaneous.Noize);
        }