Gravity in the Cyclone Physics Engine
I’m building up a 2D physics engine in c++ based on the Cyclone Physics Engine, http://procyclone.com, and I’m trying to figure out why the code uses a gravity vector multiplied by the mass to add force to an object,
void psiclone::Gravity::addForce(Body* body, double seconds) {
body->addForce(gravity * body->mass);
}
velocity.mX += acceleration.getX() * seconds;
From physics, we know that force = mass * acceleration
. Thus to calculate acceleration, they just divide force
by mass
. They are just sticking with physics definitions of the terms. gravity * seconds
would be velocity
.