Added function for calculating gravity and moment of inertia