User:Intel4004/MySandBox

Let us begin again with the standard equation for a line between points $$(x_0,y_0) \,$$ and $$(x_1,y_1) \,$$ defined in the xy-plane:

$$  y - y_0 = \frac{y_1-y_0}{x_1-x_0} (x-x_0) \Leftrightarrow \, $$ $$  y = \frac{y_1-y_0}{x_1-x_0}x + y_0 - \frac{y_1-y_0}{x_1-x_0}x_0 \Leftrightarrow \, $$



y = \frac{\Delta y}{\Delta x}x + q, \mbox{ where }\Delta x = (x_1-x_0)\mbox{ and }\Delta y = (y_1-y_0). $$

This corresponds to the slope-intercept form of a line in the following way:



y = \frac{\Delta y}{\Delta x}x + q \Leftrightarrow $$

y = mx + q, \mbox{ where }m = \frac{\Delta y}{\Delta x}\mbox{ and }q = y_0 - \frac{\Delta y}{\Delta x}x_0. $$

Here $$m$$ is the slope of the line and $$q$$ is the intercept of the line on the $$y$$-axis. At this point we can go directly to what is known as the implicit form of a line equation. This is done by moving everything over to the left side in the expression:



y = \frac{\Delta y}{\Delta x}x + q \Leftrightarrow $$

y - \frac{\Delta y}{\Delta x}x - q = 0 \Leftrightarrow $$

(\Delta y)x + (-\Delta x)y + \Delta x \cdot q = 0. \, $$

By doing this procedure of rewritting the expression for slope-intercept form we have arrived at a more general expression of a line i.e. the implicit form:



F(x,y) \equiv ax + by + c = 0, \mbox{ where }a = \Delta y, b = -\Delta x, \mbox{ and } c = \Delta x \cdot q. $$

For different values of $$x$$ and $$y$$ the function $$F(x,y) \,$$ can give non-zero results, but for exactly those points $$(x,y) \,$$ which are on the line we are seeking to rasterize - it equals zero.

The definition of $$F(x,y) \,$$:



F(x,y) = ax + by + c = \, $$

\begin{cases} F(x,y) < 0, & \mbox{if }(x,y)\mbox{ is a point above the line} \\ 0, & \mbox{if }(x,y)\mbox{ is a point on the line} \\ F(x,y) > 0, & \mbox{if }(x,y)\mbox{ is a point below the line} \end{cases} $$