void UpdateAcceleration(BallMass ball) { var resultant = new Vector(); foreach (var b in BallMasses) { if (b == ball) { continue; } var distance = b.Position - ball.Position; var distanceValue = distance.Magnitude; var accel = GravityConst * b.Mass / (distanceValue * distanceValue); resultant.UpdateByAddWith(accel * distance.UnitVector); } ball.Acceleration = resultant; }
void UpdatePosition(BallMass ball) { ball.Velocity.UpdateByAddWith(ball.Acceleration); ball.Position.UpdateByAddWith(ball.Velocity); }
public void RemoveBallMass(BallMass ball) { _ballMasses.Remove(ball); }
public void AddBallMass(BallMass ball) { _ballMasses.Add(ball); }