use lengthSquared() and bitwise operators instead of length() and pow() for grid scale calculation.