protected float getHeight(int x, int z, float xm, float zm) {
        
        int index = findClosestHeightIndex(x, z);
        if (index < 0) {
            return Float.NaN;
        }
        
        float h1 = hdata[index];                // top left
        float h2 = hdata[index + 1];            // top right
        float h3 = hdata[index + width];        // bottom left
        float h4 = hdata[index + width + 1];    // bottom right

        //float dix = (x % 1f) ;
        //float diz = (z % 1f) ;
            
        if ((x == 0 && z == 0) || (x == width - 2 && z == width - 2)) {
            // top left or bottom right grid point
            /*  1----2
             *  | \ b|
             *  |a \ |
             *  3----4 */
            if (xm<zm)
                return h1 + xm*(h4-h3) + zm*(h3-h1);
            else
                return h1 + xm*(h2-h1) + zm*(h4-h2);
            
        } else {
            // all other grid points
            /*  1----2
             *  |a / |
             *  | / b|
             *  3----4 */
            if (xm<(1-zm))
                return h3 + (xm)*(h2-h1) + (1f-zm)*(h1-h3);
            else
                return h3 + (xm)*(h4-h3) + (1f-zm)*(h2-h4);
        }
    }
Get the two triangles that make up the grid section at the specified point.

For every grid space there are two triangles oriented like this:
 *----*
 |a / |
 | / b|
 *----*
The corners of the mesh have differently oriented triangles. The two
corners that we have to special-case are the top left and bottom right
corners. They are oriented inversely:
 *----*
 | \ b|
 |a \ |
 *----*
jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/LODGeomap.java