class linesegment { public: float x0,y0,x1,y1; float currx; float incx; linesegment* next; linesegment* prev; linesegment() {x0=x1=y0=y1= -1; currx=-1; incx=0; next=prev=0;} linesegment(float xfirst, float yfirst, float xlast, float ylast); void updatex() {currx += incx;} }; linesegment::linesegment(float xfirst, float yfirst,float xlast, float ylast) { // set endpoints in correct order if ((yfirst< ylast) || (yfirst==ylast && xfirst<=xlast)) { x0 = xfirst; y0 = yfirst; x1 = xlast; y1 = ylast; } else { x0 = xlast; y0 = ylast; x1 = xfirst; y1 = yfirst; } // set x-intercept currx= x0; // set x-increment = inverse slope if (y0==y1) incx = 0; else incx = (x1-x0)/(y1-y0); }