Mechanics of swinging a bat