Function calculateCurveComplexity