[distance][segment-box] alternative implementation that does not use forward declarations