I've posted this a million times here but....
Code:
//No assembly
double BI(double v1,double v2,double v3,double v4,double f1,double f2)
{
double val1=v1+f1*(v2-v1);
double val2=v3+f1*(v4-v3);
return (val1+f2*(val2-val1));
}
//Inline assembly
double BI(double v1,double v2,double v3,double v4,double f1,double f2)
}
double val1=0.0,val2=0.0,rval=0.0;
asm {
fld [v2]
fsub [v1]
fmul [f1]
fadd [v1]
fstp [val1]
fld [v4]
fsub [v3]
fmul [f1]
fadd [v3]
fstp [val2]
fld [val2]
fsub [val1]
fmul [f2]
fadd [val1]
fstp [rval]
}
return rval;
}
But to do what you want only requires 2 separate linear interpolations rather than one bilinear. Essentially you are doing a bilinear interpolation but its easier to do two singles which is:
interpolated_value=v1+f1*(v2-v1);
where f1 is the interpolant.
Code:
//Scan conversion
double m=(x2-x1)/(y2-y1);
double cm=(c2-c1)/y2-y1);
int x=x1;
int c=c1;
for (double y=y1;y<y2;y+=1.0)
{
edge[(int)y].x=x;
edge[(int)y].c=c;
x+=m;
c+=cm;
}
//Drawing from left edge to right edge
double x1=(double)left_edge[y].x;
double x2=(double)right_edge[y].x;
double c1=(double)left_edge[y].c;
double c2=(double)right_edge[y].c;
cm=(c2-c1)/(x2-x1);
double c=(double)c1;
for (double x=x1;x<x2;x++)
{
putpixel((int)x,(int)y,(int)c);
c+=cm;
}
So it is a type of bilinear interpolation since you first interpolate on y and then x. The data type conversions might be wrong in my examples but I'm sure you can get it right. Using < and > with doubles is not a good idea.