ear clipping algorithm improved