public void MoveParticles(SimulationStructure structure, float step, int simStep)
        {
            var dampingF = (float)(1 / Math.Exp(step));

            foreach (var particleSection in structure.GetAllSections())
            {
                particleSection.ApplyToAllParticles(particle =>
                {
                    particle.Position += particle.Velocity * step;
                    particle.Velocity += step * (gravityPoint - particle.Position);
                    bouncer.BounceParticle(ref particle);
                    if (particle.Velocity.LengthSquared() > maxSpeedSquared)
                    {
                        particle.Velocity *= 0.9f;
                    }
                    return(particle);
                });
            }
            centerRemainTime -= step;
            if (centerRemainTime < 0)
            {
                UpdateGravityPoint(structure);
            }
            costCalculator.CalculateTotalCost(structure, simStep);
        }
 public void MoveParticles(SimulationStructure structure, float step, int simStep)
 {
     foreach (var allSection in structure.GetAllSections())
     {
         allSection.ApplyToAllParticles(
             particle =>
         {
             var randomAcceleration = step * acceleration *
                                      (
                 new Vector3((float)(randomizer.NextDouble() - 0.5d),
                             (float)(randomizer.NextDouble() - 0.5d),
                             (float)(randomizer.NextDouble() - 0.5d)) +
                 accelerationBias);
             particle.Velocity += randomAcceleration;
             if (particle.Velocity.LengthSquared() > maxSpeedSquared)
             {
                 particle.Velocity.Normalize();
                 particle.Velocity = particle.Velocity * (float)Math.Sqrt(maxSpeedSquared);
             }
             particle.Position += particle.Velocity * step;
             bouncer.BounceParticle(ref particle);
             return(particle);
         });
     }
     costCalculator.CalculateTotalCost(structure, simStep);
 }
Ejemplo n.º 3
0
        public void MoveParticles(SimulationStructure structure, float step, int simStep)
        {
            var f = ((float)Math.Sin((float)simStep / 400));


            foreach (var allSection in structure.GetAllSections())
            {
                allSection.ApplyToAllParticles(particle =>
                {
                    particle.Velocity = new Vector3((particle.Velocity.X + f / 5) * 0.5f, 0,
                                                    0);
                    particle.Position += particle.Velocity * step;
                    bouncer.BounceParticle(ref particle);
                    return(particle);
                });
            }

            costCalculator.CalculateTotalCost(structure, simStep);
        }