When the same point is used as center and as nearestPt, the function would override center and give wrong results. Fix #118