float[] Y = ip.getYValues();
float x0 = (float)p0.getX();
float y0 = (float)p0.getY();
float x1 = (float)p1.getX();
float y1 = (float)p1.getY();
Plane out = ip.getPlane();
float denom;
denom = x1 - x0;
if(denom < 0.1f) {
/*
* Since we use the slope to compute the gradient, we have a nasty
* singularity when the slope is infinite. If the slope is near
* infinite, we compute the gradient on the plane mirrored about
* y=x and then flip the result back when we are done.
*/
if(w == h) {
_computeInternal(out, w, h, X, Y, y0, x0, y1, x1);
Plane tmp = ip.getPlane();
for(int j = 0; j < h; j++) {
for(int i = 0; i < w; i++) {
tmp.data[i][j] = out.data[j][i];
}
}
ip.putPlane(out);
out = tmp;
} else {
Plane yxOut = ip.getYXPlane();
_computeInternal(yxOut, h, w, Y, X, y0, x0, y1, x1);
for(int j = 0; j < h; j++) {
for(int i = 0; i < w; i++) {
out.data[i][j] = yxOut.data[(int)h - j - 1][(int)w - i - 1];
}