Calculation of contact point of tool on surface, curve