Computing Plane Equations
We've added two new instance variables. The first is simply an optimization that detects the case when all three vertices are the same color. In this case we'll call the slightly faster FlatTri methods that we inherited. The second is a scale factor that we'll disscuss next.

Next we add a new method to compute the plane equations of our parameters. The PlaneEqn() method performs the required matrix multiply and avoids computing the inverse of the triangle area more than once.


	    public void PlaneEqn(int eqn[], int p0, int p1, int p2) {
	        int Ap, Bp, Cp;
	        if (scale <= 0) {
	            scale = (1 << EdgeEqn.FRACBITS) / ((double) area);
	        }
	        double sp0 = scale * p0;
	        double sp1 = scale * p1;
	        double sp2 = scale * p2;
	        Ap = (int)(edge[0].A*sp2 + edge[1].A*sp0 + edge[2].A*sp1);
	        Bp = (int)(edge[0].B*sp2 + edge[1].B*sp0 + edge[2].B*sp1);
	        Cp = (int)(edge[0].C*sp2 + edge[1].C*sp0 + edge[2].C*sp1);
	        eqn[0] = Ap;
	        eqn[1] = Bp;
	        eqn[2] = Ap*xMin + Bp*yMin + Cp + (1 << (EdgeEqn.FRACBITS - 1));
	    }
	
Lecture 6   Slide 26   6.837 Fall '01