I'm reading this article to understand hardware triangle rasterization, but I'm getting stuck in a particular part that defines line equations (that make up a triangle) as follows:
Note that when we move e.g. one pixel to the right, we add one to X and leave Y the same. Our edge equations have the form $E(X,Y)=aX+bY+c$ with a, b, c being per-triangle constants, so for $X+1$ it will be $E(X+1,Y)=a(X+1)+bY+c=E(X,Y)+a$. In other words, once you have the values of the edge equations at a given point, the values of the edge equations for adjacent pixels are just a few adds away.
I'm used to equations of a line like $y=mx+b$, the point slope form of this, or $Ax+Bx+C=0$, where the equation holds true if and only if a point is on a line. The equations of a line in this article are very confusing coming from this background, though:
- They look like they're functions $f: \mathbf{R}^2 \rightarrow \mathbf{R}$, but this doesn't define a line in any meaningful way that I can think of.
- Somehow we need separate equations for the same line at different points, which also does not make sense.
- The claim that $a$, $b$, and $c$ are per-triangle constants, combined with the fact that these numbers, taken together, identify a unique equation would seem to imply that all three equations of a line to make up a triangle have the same equation which is just, what?
What's going on here? How does this style of equation of a line work?
The function $\, E(X,Y)=aX+bY+c \,$ is used to define a one dimensional curve in two dimensions. If you look at the graph of this function using $\, Z = E(X,Y)\,$ you can see that it is a plane. The intersection of this plane with the plane $\, Z = 0\,$ is a straight line whose equation is $\, E(X,Y) = 0.\,$ Another way to see this is to solve the equation to get $\, Y = -(aX+c)/b\,$ which of the form $\, y = mx+b\,$ which you mentioned.
This generalizes to any number of dimensions. For example $\, E(X,Y,Z)=aX+bY+cZ+d\,$ can be used to define a plane in three dimensions in the same way. The equation of a plane being $\,E(X,Y,Z) = 0.\,$ In the same way, you can solve the equation to get $\, Z = -(aX+bY+d)/c\,$ which is the equation of a plane as mentioned before.
The article linked to states:
just before giving the function $\, E(X,Y)=aX+bY+c. \,$ In this context $\, E(X,Y)\,$ gives a measure of the signed distance from a point $\,(X,Y)\,$ to a line $\, E(X,Y)=0 \,$ which contains one of the edges of a triangle, and where, obviously, the distance of a point on the line to the line itself is zero.