Mechanics of flapping