private void RenderPanel_MouseMove(object sender, MouseEventArgs e) { if (selectedParticleIndex != -1) { mousePosition = new Vector(e.X, e.Y); } }
private void RenderPanel_MouseDown(object sender, MouseEventArgs e) { mousePosition = new Vector(e.X, e.Y); for (int i = 0; i < _simulation.Particles.Count; ++i) { Vector temp = mousePosition - _simulation.Particles[i].Position; if (Vector.Length(temp) <= _simulation.Particles[i].MetaData.Radius) { selectedParticleIndex = i; break; } } }
public static void MultiplyLength(ref Vector a,double multiple) { a.X *= multiple; a.Y *= multiple; }
public static void Normalize(ref Vector a) { double invLength = 1/Length(a); a.X *= invLength; a.Y *= invLength; }
public static double Length(Vector a) { return Math.Sqrt(Math.Pow(a.X, 2) + Math.Pow(a.Y, 2)); }