Newton's law of universal gravitation enables us to calculate the field at any point set up by an array of point masses (or spheres). Force fields are usually represented graphically by sets of fieldlines and equipotentials. A fieldline is a continuous line that is tangent to the field at every point along its length. For a single point mass, a fieldline is a straight line extending from the point mass to infinity. For a set of masses or extended objects, fieldlines are curves that extend to infinity without crossing (except, as we will see, when they are constrained by symmetry). Equipotentials are perpendicular to the field at every point along their length. For a single point mass an equipotential is a circle, and for a set of point masses it is a closed curve.
The sample program plots fieldlines and equipotentials in the vicinity of identical spheres placed at the vertices of an equilateral triangle. We can start the curves anywhere we wish, but it is usual when dealing with spheres to start fieldlines at points equally spaced around each sphere, and plot out to the boundary in the direction opposite to the field. We can calculate the field at a point, draw a line segment in the field direction, calculate the field at the next point, and continue the process as long as we wish, but we do not get a very accurate plot by this procedure. It is not easy to see if a fieldline is drawn accurately, but an equipotential that is not drawn accurately shows up clearly because it fails to close.
We can make a much more accurate plot without reducing the step size by drawing the line segment in the direction of the field half a step ahead of where we are. We do not need additional computation to find this point: all we need do is project ahead half of the step we have just taken.
Equipotentials are drawn perpendicular to the field using the fact that the product of the slopes of perpendicular curves is negative one.
Note that symmetry constrains the fieldlines to intersect at the center of the equilateral triangle. (More is said about this in Laplace's Equation.) The field is zero at the center, and the potential is nearly constant over the entire central region.
Another type of plot can be generated by calculating the gravitational potential at each pixel in the field of view, and using it to set the pixel's color. Equipotentials are not 'drawn' - they appear as the boundaries between regions of different color. The computational aspect of the program that generates this type of plot is very simple. The only decision that needs to be made concerns the width of the potential region to be plotted as a single color. The program uses six colors and linear scaling, i.e. the potential changes by the same amount across each color band.