if max==min (e.g. elevation is flat), this returns 0. This could be a problem if you use the value to check distance like `if (dis<epsilon)` which never satisfied.  `if (dis<=epsilon)` is fine