docs: public double compute(double x0, double y0, double x1, double y1) {
  
  		double sum = 0;
  
  		double slopeX = x1-x0;
  		double slopeY = y1-y0;
  
  		length = Math.sqrt(slopeX*slopeX + slopeY*slopeY);
  
  		int sgnX = (int)Math.signum(slopeX);
  		int sgnY = (int)Math.signum(slopeY);
  
  		int px = (int)x0;
  		int py = (int)y0;
  
  		if( slopeX == 0 || slopeY == 0 ) {
  			// handle a pathological case
  			if( slopeX == slopeY )
  				return 0;
  
  			double t;
  			if (slopeX == 0) {
  				t = slopeY > 0 ? py + 1 - y0 : py - y0;
  			} else {
  				t = slopeX > 0 ? px + 1 - x0 : px - x0;
  			}
  
  			t /= (slopeX+slopeY);
  			if (t > 1) t = 1;
  			if( t > 0 )
  				sum += t * image.unsafe_getD(px, py);
  			double deltaT = (sgnX+sgnY)/ (slopeX+slopeY);
  
  			while (t < 1) {
  				px += sgnX;
  				py += sgnY;
  				double nextT = t + deltaT;
  				double actualDeltaT = deltaT;
  				if (nextT > 1) {
  					actualDeltaT = 1 - t;
  				}
  				t = nextT;
  				sum += actualDeltaT * image.unsafe_getD(px, py);
  			}
  		} else {
  			double deltaTX = slopeX > 0 ? px + 1 - x0 : px - x0;
  			double deltaTY = slopeY > 0 ? py + 1 - y0 : py - y0;
  			deltaTX /= slopeX;
  			deltaTY /= slopeY;
  
  			double t = Math.min(deltaTX,deltaTY);
  			if (t > 1) t = 1;
  			if( t > 0 )
  				sum += t * image.unsafe_getD(px, py);
  
  			double x = x0 + t*slopeX;
  			double y = y0 + t*slopeY;
  			px = (int)x;
  			py = (int)y;
  			int nx = px + sgnX;
  			int ny = py + sgnY;
  
  			while( t < 1 ) {
  				deltaTX = (nx-x)/slopeX;
  				deltaTY = (ny-y)/slopeY;
  
  				double deltaT = Math.min(deltaTX,deltaTY);
  
  				// see if it already hit the destination
  				if( deltaT <= UtilEjml.TEST_F64 ) {
  					deltaT = Math.max(deltaTX,deltaTY);
  				}
  				double nextT = t + deltaT;
  				if( nextT > 1 ) {
  					deltaT = 1-t;
  				}
  
  				double sampleT = t + 0.5f*deltaT;
  				x = x0 + sampleT*slopeX;
  				y = y0 + sampleT*slopeY;
  
  				sum += deltaT*image.unsafe_getD((int)x,(int)y);
  				t = t + deltaT;
  				x = x0 + t*slopeX;
  				y = y0 + t*slopeY;
  				px = (int)x;
  				py = (int)y;
  				nx = px + sgnX;
  				ny = py + sgnY;
  
  			}
  		}
  
  		sum *= length;
  
  		return sum;
  	}