if ($dist <= getdistance($pref->[$idx-1], $pref->[$idx], $pt))