Force calculateForceFromBody(Body otherBody) { Vec2D distance = calculateDistanceFromBody(otherBody); Vec2D unit_distance = distance.getUnitVector(); if (distance.getMagnitude() != 0) { double forceMagnitude= (GRAVITYCONST * otherBody.getMass() * getMass()) / (pow(distance.getMagnitude(), 2)); double forceMagnitude_x = forceMagnitude * unit_distance.getX(); double forceMagnitude_y = forceMagnitude * unit_distance.getY(); return Force(forceMagnitude_x, forceMagnitude_y); } else { return Force(0,0); } }