11 Simulating Force Fields

 

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.

11.1   1 Modeling gravitational fields

 
 

11.1.1   Defining a vector field

 
 
 

11.1.2   Defining a simple force field

 

11.2   Adding gravity to the asteroid game

 
 
 
 

11.2.1   Making game objects feel gravity

 
 

11.2.2   Exercises

 
 

11.3   Introducing potential energy

 
 

11.3.1   Defining a potential energy scalar field

 
 

11.3.2   Plotting a scalar field as a heatmap

 
 
 
 

11.3.3   Plotting a scalar field as a contour map

 
 
 

11.4   4 Connecting energy and forces with the gradient

 
 

11.4.1   Measuring steepness with cross sections

 
 
 
 

11.4.2   Calculating partial derivatives

 
 
 

11.4.3   Finding the steepness of a graph with the gradient

 
 
 

11.4.4   Calculating force fields from potential energy with the gradient

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest