Definition of affine function 
f(x, y) = Ax + By + Cfor some coefficients A, B, C.
Level lines 
Ax + By + C = Dwhere 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 = 0or 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 (x_{1}, y_{1}) and (x_{2}, y_{2}) on this line must satisfy
Ax_{1} + By_{1} = D and Ax_{2} + By_{2} = D.Thus we have
A(x_{1}  x_{2}) + B(y_{1}  y_{2}) = 0, and thusThus 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].
[A, B][x_{1}  x_{2}, y_{1}  y_{2}] = 0.
Distance from level lines to the origin 
Bx = Ay = 0.We solve for x and y to find the intersection,
[x, y] = [DA, DB] / (A^{2} + B^{2}).Then using Pythagoras' Theorem, we take √(x^{2} + y^{2}) to get the distance to the origin:
D / √(A^{2} + B^{2}).
Figure 3.2 


3D affine functions 
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 / √(A^{2} + B^{2} + C^{2}).