This chapter covers
- Modeling forces like gravity using scalar fields and vector fields
- Calculating force vectors using the gradient
- Taking the gradient of a function in Python
- Adding gravitational force to the asteroid game
- Calculating gradients and working with vector fields in higher dimensions
There has just been a catastrophic event in the universe of our asteroid game: a black hole has appeared in the center of the screen!
Figure: Oh no, a black hole!
As a result of this new object in our game, the spaceship and all of the asteroids will feel a “gravitational pull” toward the middle of the screen. This will make the game even more challenging and it will give us a mathematical challenge as well: understanding force fields.
Gravity is a familiar example of a force that acts “at a distance,” meaning that you don’t have to be touching an object to feel its gravitational pull. For instance, when you’re flying on an airplane, you can still walk around normally because even at 40,000 feet, the Earth is pulling you downward. Magnetism and static electricity are other familiar forces that act at a distance. In physics, we picture sources of these kinds of forces as generating an invisible force field around them. Anywhere in the Earth’s gravitational force field, called its gravitational field, an object will feel a pull toward the Earth.