public float getHeight(float x, float z) { x /= stepScale.x; z /= stepScale.z; float col = FastMath.floor(x); float row = FastMath.floor(z);  if (col < 0 || row < 0 || col >= size - 1 || row >= size - 1) { return Float.NaN; } float intOnX = x - col, intOnZ = z - row;  float topLeft, topRight, bottomLeft, bottomRight;  int focalSpot = (int) (col + row * size);    topLeft = heightMap[focalSpot] * stepScale.y;   topRight = heightMap[focalSpot + 1] * stepScale.y;   bottomLeft = heightMap[focalSpot + size] * stepScale.y;    bottomRight = heightMap[focalSpot + size + 1] * stepScale.y;   return FastMath.LERP(intOnZ, FastMath.LERP(intOnX, topLeft, topRight), FastMath.LERP(intOnX, bottomLeft, bottomRight)); }
public float getHeight(Vector2f position) { return getHeight(position.x, position.y); }
    public float getHeight(float x, float z) {        x /= stepScale.x;        z /= stepScale.z;        float col = FastMath.floor(x);        float row = FastMath.floor(z);        if (col < 0 || row < 0 || col >= size - 1 || row >= size - 1) { return Float.NaN; }        float intOnX = x - col, intOnZ = z - row;        float topLeft, topRight, bottomLeft, bottomRight;        int focalSpot = (int) (col + row * size);        // find the heightmap point closest to this position (but will always        // be to the left ( < x) and above (< z) of the spot.        topLeft = heightMap[focalSpot] * stepScale.y;        // now find the next point to the right of topLeft's position...        topRight = heightMap[focalSpot + 1] * stepScale.y;        // now find the next point below topLeft's position...        bottomLeft = heightMap[focalSpot + size] * stepScale.y;        // now find the next point below and to the right of topLeft's        // position...        bottomRight = heightMap[focalSpot + size + 1] * stepScale.y;        // Use linear interpolation to find the height.        return FastMath.LERP(intOnZ, FastMath.LERP(intOnX, topLeft, topRight),                FastMath.LERP(intOnX, bottomLeft, bottomRight));    }