intersection_dist function

Intersection distance (lowlevel function)