Example #1
0
        //for a small dt, the newtonian method is stable
        //providing that forces and acceleration are both insignificant
        public MassParticle Elapse(Vector force, double dt)
        {
            var acc  = force / Mass;
            var dp   = Velocity * dt + acc * dt * dt * 0.5;
            var dv   = acc * dt;
            var newm = new MassParticle();

            newm.Velocity = Velocity + dv;
            newm.Position = Position + dp;
            newm.Mass     = Mass;
            return(newm);
        }
Example #2
0
        //add particle and assign a random position if not exist
        public void AddParticle(Vertex v)
        {
            AddVertex(v);
            if (HasParticle(v))
            {
                return;
            }
            var newp = new MassParticle();

            newp.Mass       = m;
            newp.Velocity   = Vector.Zero;
            newp.Position.X = (RNG.NextDouble() * 2 - 1) * L * 10;
            newp.Position.Y = (RNG.NextDouble() * 2 - 1) * L * 10;
            Particles[v]    = newp;
        }