If a (possibly non-flat) surface S in 3D space \R^3 is
parameterized by a system of
curvilinear coordinates \mathbf{r}(s, t) = (x(s, t), y(s, t), z(s, t)), with s and t
real variables, then a normal to
S is by definition a normal to a tangent plane, given by the cross product of the
partial derivatives \mathbf{n}=\frac{\partial \mathbf{r}}{\partial s} \times \frac{\partial \mathbf{r}}{\partial t}. If a surface S is given
implicitly as the set of points (x, y, z) satisfying F(x, y, z) = 0, then a normal at a point (x, y, z) on the surface is given by the
gradient \mathbf{n} = \nabla F(x, y, z). since
the gradient at any point is perpendicular to the level set of S. For a surface S in \R^3 given as the graph of a function z = f(x, y), an upward-pointing normal can be found either from the parametrization \mathbf{r}(x,y)=(x,y,f(x,y)), giving \mathbf{n} = \frac{\partial \mathbf{r}}{\partial x} \times \frac{\partial \mathbf{r}}{\partial y} = \left(1,0,\tfrac{\partial f}{\partial x}\right) \times \left(0,1,\tfrac{\partial f}{\partial y}\right) = \left(-\tfrac{\partial f}{\partial x}, -\tfrac{\partial f}{\partial y},1\right); or more simply from its implicit form F(x, y, z) = z-f(x,y) = 0, giving \mathbf{n} = \nabla F(x, y, z) = \left(-\tfrac{\partial f}{\partial x}, -\tfrac{\partial f}{\partial y}, 1 \right). Since a surface does not have a tangent plane at a
singular point, it has no well-defined normal at that point: for example, the vertex of a
cone. In general, it is possible to define a normal almost everywhere for a surface that is
Lipschitz continuous.
Orientation The normal to a (hyper)surface is usually scaled to have
unit length, but it does not have a unique direction, since its opposite is also a unit normal. For a surface which is the
topological boundary of a set in three dimensions, one can distinguish between two
normal orientations, the
inward-pointing normal and
outer-pointing normal. For an
oriented surface, the normal is usually determined by the
right-hand rule or its analog in higher dimensions. If the normal is constructed as the cross product of tangent vectors (as described in the text above), it is a
pseudovector.
Transforming normals When applying a transform to a surface it is often useful to derive normals for the resulting surface from the original normals. Specifically, given a 3×3 transformation matrix \mathbf{M}, we can determine the matrix \mathbf{W} that transforms a vector \mathbf{n} perpendicular to the tangent plane \mathbf{t} into a vector \mathbf{n}^{\prime} perpendicular to the transformed tangent plane \mathbf{Mt}, by the following logic: Write
n′ as \mathbf{Wn}. We must find \mathbf{W}. \begin{alignat}{5} W\mathbb n \text{ is perpendicular to } M\mathbb t \quad \, &\text{ if and only if } \quad 0 = (W \mathbb n) \cdot (M \mathbb t) \\ &\text{ if and only if } \quad 0 = (W \mathbb{n})^\mathrm{T} (M \mathbb{t}) \\ &\text{ if and only if } \quad 0 = \left(\mathbb{n}^\mathrm{T} W^\mathrm{T}\right) (M \mathbb{t}) \\ &\text{ if and only if } \quad 0 = \mathbb{n}^\mathrm{T} \left(W^\mathrm{T} M\right) \mathbb{t} \\ \end{alignat} Choosing \mathbf{W} such that W^\mathrm{T} M = I, or W = (M^{-1})^\mathrm{T}, will satisfy the above equation, giving a W \mathbb n perpendicular to M \mathbb t, or an \mathbf{n}^{\prime} perpendicular to \mathbf{t}^{\prime}, as required. Therefore, one should use the inverse transpose of the linear transformation when transforming surface normals. The inverse transpose is equal to the original matrix if the matrix is orthonormal, that is, purely rotational with no scaling or shearing. ==Hypersurfaces in
n-dimensional space==