Calculates the gravity