7.2. The laws of motion

As well as being parallel, physics is homogeneous. We implement the principle of homogeneity by making sure to derive all of our classes from a base class that has the necessary laws built into it. We give the base class a move(dt) method that encapsulates the laws of motion. And we ensure homogeneity by making move(dt) non-virtual so that the child classes can’t override it.

What are the laws of physical motion that we need to use? Ordinarily we discuss motion in terms of a scalar mass quantity and four vector quantities: position, velocity, acceleration, and force. (Keep in mind that when we say, for instance, that velocity is a vector, we mean that velocity is a scalar speed times a unit direction vector.) The laws ...

Get Software Engineering and Computer Games now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.