A normal vector to a curve at a particular point is a vector perpendicular to the tangent vector of the curve at that point (also called a gradient). For an implicit 2D function in the form $f(x,y) = 0$ the 2D gradient is
For an implicit 3D function the normal is the vector perpendicular to the surface, the surface normal at a point $\mathbf{p}$ is given by the gradient of the implicit function
For a plane we know that the dot product of the normal $\mathbf{n}$ and any vector that lies in the plane is zero, therefore we can model a plane as the following implicit equation
Where $\mathbf{p}$ and $\mathbf{a}$ are any two points lying on the plane, sometimes we want the equation of a plane through points $\mathbf{a, b, c}$, the normal can be found by taking the cross product of any two vectors on the plane
Transforming normal vectors
Normal vectors do not transform the way we would like when they’re multiplied by a transformation matrix, if the points on a surface are transformed by the transformation matrix $\mathbf{M}$, a vector $\mathbf{t}$ tangent to the surface will still be tangent to the transformed surface, however a surface normal vector $\mathbf{n}$ may not be normal to the transformed surface
For example when a transformation matrix $\mathbf{M} = \mathbf{H_x}(s)$ that skews points toward the $x$ axis multiplies the normal vector $\mathbf{n}$, the resulting vector $\mathbf{Mn}$ is not normal to the surface, we would like to find a transformation matrix $\mathbf{N}$ so that $\mathbf{Nn}$ is indeed the surface normal
To find the value of $\mathbf{N}$ we start from the fact that the normal $\mathbf{n}$ and the tangent $\mathbf{t}$ are perpendicular
Expressed as a matrix multiplication
After the transformation they’re still perpendicular so
Applying the transpose
Relating \eqref{post-transformation} with \eqref{perpendicular} we see that the only way that both equations hold true is that
The value of $\mathbf{N}$ is then