kmax function

Calculate max curvature