private void SetupParticles() { for (int i = 0; i < _particlesAmount; i++) { Vector pos = new Vector(this.Rand.Next(0, _viewResolution.Width), this.Rand.Next(0, _viewResolution.Height)); Particle point = new Particle(1, pos); point.ApplyVelocityField(this.SelectedVelocityField); _particles.Add(new FluidSimParticle { Id = i, Node = new CCDrawNode { Position = new CCPoint((float)pos.X, (float)pos.Y) }, Particle = point, LifeTime = GetNewLifeTime() }); _layer.AddChild(_particles[i].Node); _particles[i].Node.DrawSolidCircle(new CCPoint(0, 0), 0.3f, CCColor4B.White); } for (int i = 0; i < _touchParticlesAmount; i++) { Particle point = new Particle(1, new Vector()); point.ApplyVelocityField(this.SelectedVelocityField); _touchParticles.Add(new FluidSimParticle { Id = i, Node = new CCDrawNode { Position = new CCPoint(0, 0), Visible = false }, Particle = point, LifeTime = 0 }); _layer.AddChild(_touchParticles[i].Node); _touchParticles[i].Node.DrawSolidCircle(new CCPoint(0, 0), 0.8f, CCColor4B.Yellow); } _centreWheelNode.Position = new CCPoint(_viewResolution.Width / 2, _viewResolution.Height / 2); _spinningWheelNode.Position = new CCPoint(_centreWheelNode.Position.X, _centreWheelNode.Position.Y + (float)RadiusSlider.Value); _layer.AddChild(_centreWheelNode); _layer.AddChild(_spinningWheelNode); }
public void TestVelocityField() { ///Shear Flow ///(-U(y - height) ,0) VelocityField stream = CommonVelocityFields.UniformStream; CommonVelocityFields.FlowStrength = 3; Particle p = new Particle(5, new Vector(5, 5)); p.ApplyVelocityField(stream); p.Move(5); Vector result = p.Position; //flow strength 3, so should move 15 in x direction Vector expected = new Vector(20, 5); Assert.AreEqual(expected, result); }