Base equations for movement:
dt = t(i+1) - ti
v(ti+1) = v(ti) + (f(ti)/m)dt
p(ti+1) = p(ti) + v(ti+1)dt
Center of Mass:
If the density of the figure is uniform, then the center of mass is the same as the geometric center also known as centroid.
Since rigid body are continues through the particles, we should not
use a discrete equation, but use an integral to calculate the Center of mass
of a Rigid Body:
Where r is the position of each point ,p is a function that gives the density at each point within the body (there's the [v]olume part).
For sake of simplicity, we will not be using any advanced methods, like SAT or DBVT.
The method we are using is the Axis Aligned Bounding Boxes
that can be calculated using AABBvsAABB
function.
We simply check if one Axis-Aligned box is inside another Axis-Aligned Box: