Feature/distance

re-factor segment-box distance computation code