Part III - Affine Functions

Definition of affine function
A function f(x, y) is a 2D affine function if and only if

f(x, y) = Ax + By + C
for some coefficients A, B, C.

Level lines
We can understand 2D affine functions better by looking at their level lines. A level line of a function is a curve on which the function is constant. (In other words, a function takes the same value at every point of a level line.) To obtain the equation for a level line of a function simply set the function equal to a constant. For a 2D affine function this looks like

Ax + By + C = D
where D is some constant.

Consider the 2D affine function where C = 0, namely Ax + By. The level line of this function for D = 0 is

Ax + By = 0
or equivalently
[A, B][x, y] = 0.
Recall that when the dot product of two vectors is 0 the vectors are perpendicular to each other. Therefore [A, B] is perpendicular to [x, y]. Thus the level line Ax + By = 0 is the line through the origin perpendicular to [A, B]:
 
Figure 3.1

Now consider an arbitrary level line Ax + By = D of this function. Any two points (x1, y1) and (x2, y2) on this line must satisfy

Ax1 + By1 = D    and    Ax2 + By2 = D.
Thus we have
A(x1 - x2) + B(y1 - y2) = 0,    and thus

[A, B][x1 - x2, y1 - y2] = 0.
Thus the vector between any two points on this level line is perpendicular to [A, B]. So this level line Ax + By = D must also be a line perpendicular to [A, B].

Distance from level lines to the origin
Now we would like to find the perpendicular distance from an arbitrary level line to the origin. First, the line that runs perpendicular to Ax + By = D and through the origin is

-Bx = Ay = 0.
We solve for x and y to find the intersection,
[x, y] = [DA, DB] / (A2 + B2).
Then using Pythagoras' Theorem, we take √(x2 + y2) to get the distance to the origin:
D / √(A2 + B2).
 
Figure 3.2

3D affine functions
2D affine functions can be easily extended to 3D. A 3D affine function has the form

f(x, y, z) = Ax + By + Cz.

Just as in the 2D case, we can use the dot product to show that the level line Ax + By + Cz = 0 is the plane through the origin perpendicular to the vector [A, B, C]. In fact, using the same method as for the 2D case, we can show that every level line of the form Ax + By + Cz = D is perpendicular to the vector [A, B, C].

Finally, again applying the same method as for the 2D case, we can find that the perpendicular distance from a level line of a 3D affine function to the origin is given by

D / √(A2 + B2 + C2).