/** * calculates z and adjusts for border conditions * * @param x * @param y * @return */ private float calculateZ(float x, float y) { float z = 0; z = 1 - x * x - y * y; if (z > 0) { z = (float) Math.sqrt(z); } else { z = 0; } return z; }