if (t > 1) t = 1; if( t > 0 ) sum += t * image.unsafe_getD(px, py); double deltaT = (sgnX+sgnY)/ (slopeX+slopeY); sum += actualDeltaT * image.unsafe_getD(px, py); if (t > 1) t = 1; if( t > 0 ) sum += t * image.unsafe_getD(px, py); y = y0 + sampleT*slopeY; sum += deltaT*image.unsafe_getD((int)x,(int)y); t = t + deltaT; x = x0 + t*slopeX;