Ejemplo n.º 1
0
        public static void ApplyGravity(Particle Particle)
        {
            //http://upload.wikimedia.org/math/2/5/8/2584a12584dcea216e766c4bbcb514eb.png
            //My idiocy makes this shit infinite.
            float DragCoefficient = Convert.ToSingle((2) / (Particle.Element.Density * Math.Pow(Particle.Velocity.Y, 2) * 1));

            if (Particle.Velocity.Y < 0)
                Particle.Velocity.Y *= -1;
            else if (Particle.Velocity.Y == 0)
                Particle.Velocity.Y = 0.001f;
            Particle.Velocity.Y *= gravConstant;

            Particle.Velocity.X *= (1 - Particle.Element.Friction);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets neighbors of particle.
        /// 
        /// Indices:
        /// 
        /// 0 1 2
        /// 3   4
        /// 5 6 7
        /// </summary>
        /// <returns>An array of the neighbors.</returns>
        public Particle[] getNeighbors()
        {
            int X = Convert.ToInt32(this.Position.X);
            int Y = Convert.ToInt32(this.Position.Y);
            Particle[] neighbors = new Particle[8];
            neighbors[0] = this.core.particleMap.GetParticleAt(X - 1, Y + 1);
            neighbors[1] = this.core.particleMap.GetParticleAt(X, Y + 1);
            neighbors[2] = this.core.particleMap.GetParticleAt(X + 1, Y + 1);
            neighbors[3] = this.core.particleMap.GetParticleAt(X - 1, Y);
            neighbors[4] = this.core.particleMap.GetParticleAt(X + 1, Y);
            neighbors[5] = this.core.particleMap.GetParticleAt(X - 1, Y - 1);
            neighbors[6] = this.core.particleMap.GetParticleAt(X, Y - 1);
            neighbors[7] = this.core.particleMap.GetParticleAt(X + 1, Y - 1);

            return neighbors;
        }
Ejemplo n.º 3
0
 public void RemoveParticle(Particle part)
 {
 }
Ejemplo n.º 4
0
 public void AddParticle(Particle part)
 {
     Particles[Particles.Length - 1] = part;
 }