Function calculateCurvature