Linear Velocity
The next step in making our physics engine more realistic is in creating the RigidbodyVolume
class. This new class will have a shape and volume. The shape will be a sphere or a box. This new class will have Linear Velocity. Linear Velocity moves an object in a linear fashion, which means that there will be no rotation. Gravity pulling a sphere straight down is a linear motion caused by Linear Velocity.
Ideally, we would want the collision shape (Sphere
or Box
) to be stored outside the RigidbodyVolume
class. However, for the sake of keeping the code presented in this book easy to follow, we will include the collision shape in the RigidbodyVolume
class.
The RigidbodyVolume
class will perform Euler Integration. We will include the variables needed for Euler Integration (position, velocity, forces and mass) in the new class. All the new variables will be public. These variables will be directly accessable as opposed to having accessor and mutator functions. We do this to keep...