To compute if a segment is backward or forward, only use the part of the segment inside the costmap.