optimized the point grid position calculating algorithm