# Planes

To get a good understanding of planes, we need to have a grasp on the way in which we typically represent lines.

Usually we would represent a line like this with the form:

$y=3x$

But we can also represent the same line in terms of $x$ too:

$x=\frac{1}{3}y$

In fact, you do not have to represent the function in terms of either $x$ or $y$. It is perfectly valid to move both over to one side and pose the relationship as their difference or sum. This is called an implicit function:

$0=\frac{1}{3}y-x$$0=3x-y$

So that is four ways to represent the same function! This becomes even more important when we start moving into three dimensions. Consider the function:

$z=3x+2y$

This is just another way of saying that the $z$ is defined as three times the $x$ co-ordinate plus two times the $y$ co-ordinate, where the $x$ and $y$ co-ordinates sit on a flat plane vertically in space.

In this guide, I am going to use a slightly different convention than what most other mathematics visualisations may use, where the$z$ axis appears to go up and down. Instead, the $z$ axis here extends "inwards" and "outwards", just like it does in OpenGL.

Considering the dependencies that are at play here, also note that we can legitimately represent this function in terms of $x$ or $y$ as well.

$x=-\frac{2}{3}y+\frac{1}{3}z$$y=-\frac{3}{2}x+\frac{1}{2}z$

In fact, we can represent the whole thing as three different implicit functions too.

$3x+2y-z=0$$-\frac{2}{3}y+\frac{1}{3}z-x=0$$-\frac{3}{2}x+\frac{1}{2}z-y=0$

What I have said up to this point carried an important assumption, which was that $y$ had a dependency on $x$ in the form of $y=x$. If we relax that restriction and allow any $y$ for any $x$ co-ordinate, then what you end up with is a plane.

Notice that this plane is really just what we would get if it we took our existing line and then drew it starting from every possible point on the $x$ axis.

Note also that in order for the lines to appear to be "on" the plane, we had to shift their $y$ co-ordinates too - it would not work if we just applied an $x$ translation to the same line. The requisite shift here was to ensure that the lines continued to satisfy the equation defining the plane itself:

$3x+2y-z=0$

The line coming out from the origin was defined by the same equation, starting at the point $\left(0,0,0\right)$, which satisfies the equality because $3×0+2×0-0=0$.

However, if we want a line to start from $x=1$, notice what happens in the equation:

$3×1+2×0-0=3\ne 0$

In order to make the equality "work", we have to adjust either the $y$ co-ordinate or the $z$ co-ordinate such that $2y-z=-3$. In this case, we can just tweak the $y$ co-ordinate and make that $-\frac{3}{2}$, eg:

$3×1+2×-\frac{3}{2}-0=0$

As we explored earlier, there are lots of different ways that we could write the equation for this particular plane. However, the equation $3x+2y-z=0$ is sort of a "standard form" for writing equations for planes, generalizable as $Ax+By+Cz=D$. As it turns out, this notation has some very useful properties.

The first is what happens when $D=0$ and we treat the remaining coefficients as a vector from the origin.

Notice anything interesting about that vector? The vector that you see appears to point directly outward in the direction that the plane is "facing". That vector has a special name, the normal vector.

In computer graphics, the normal vector is used for all sorts of things.

Importantly, it can tell us pretty easily whether or not a surface is facing towards the camera or away from it. Just take the dot product between the direction that the camera is facing and the normal vector itself. Recall that if two surfaces are perpendicular, then their dot product will be zero. Similarly, if we were to say that for arguments sake a surface was not facing in any $x$ or $y$ direction and was facing towards the camera in the $-z$ direction and the camera was likewise only looking straight-on in the$z$, then the dot product will be negative.

$\left(0,0,-1\right)\cdot \left(0,0,1\right)=-1$

If the surface is facing away from the camera, then the dot product will be positive.

$\left(0,0,1\right)\cdot \left(0,0,1\right)=1$

You can see that as we rotate a surface around, say around the $x$ axis, that eventually the dot product flips around.

$y=$
$z=$
$\left(x,y,z\right)\cdot \left(0,0,1\right)=$ -1.00

Another very handy thing about this notation is what would happen if we tried to find the rate of change of this plane. If we rearrange the form a little we can make some trivial statements aobut how this plane is changing:

$z=3x+2y$

Without going into the calculus of it, we can say that $z$ changes by a factor of 3 for every change in the $x$. It also changes by a factor of 2 for every change in the $y$ direction. With those two facts we can come up with a gradient vector which shows the tangent that the surface is tracing out: $\left(3,2,1\right)$. These are the coefficients that we had earlier!

Planes can be a little tough the visualize, so it helps to have a good graps of the three unit planes and their corresponding normal vectors.

$z=1$
$x=1$
$y=1$