Calculate moment of inertia