# Gaussian curvature of a parametric surface s(u, v)

$% This version will make mathjax ignore the width of the annotation and keep the main % formula centered. Obviously this mean the annotation is forcefully placed to the right % and may bleed out: \newcommand{Annotation}[1]{ \rlap{~~~~~~\raise 0.8em {\color{grey}\scriptsize{ #1 }}} } \newcommand{annotation}[1]{ {~~~~~~\raise 0.8em {\color{grey}\scriptsize{ #1 }}} } \newcommand{red}[1]{ { \color{red} #1 } } \newcommand{dot}[2]{ { \langle #1 \cdot #2 \rangle } }$

You may want to look at the article where I define the Gaussian curvature (the article focus on triangle mesh surface but the general definition applies for all kind of surfaces).

# Formula

The formula for the Gaussian curvature $K$ of a parametric surface $\mathbf{\vec s}(u, v) : \mathbb R^2 \rightarrow \mathbb R^3$ is:

$$K = \frac{{LN - M^2}}{{EG - F^2}}$$

where:

\begin{align*} & E = \mathbf{\vec s}_u \cdot \mathbf{\vec s}_u \\ & F = \mathbf{\vec s}_u \cdot \mathbf{\vec s}_v \\ & G = \mathbf{\vec s}_v \cdot \mathbf{\vec s}_v \\ & L = \mathbf{\vec s}_{uu} \cdot \mathbf{\vec n} \\ & M = \mathbf{\vec s}_{uv} \cdot \mathbf{\vec n}\\ & N = \mathbf{\vec s}_{vv} \cdot \mathbf{\vec n} \end{align*}

(Dropping the vector arrow from here for simplicity.)

Here, $\mathbf{s}_u$, $\mathbf{s}_v$, $\mathbf{s}_{uu}$, $\mathbf{s}_{uv}$, and $\mathbf{s}_{vv}$ are partial derivatives of the parametric surface with respect to $u$ and $v$, the operator "$\ \cdot \$" is the dot product, and $\mathbf{n}(u, v)$ is the unit normal vector to the surface:

$$\mathbf n = \frac{\mathbf{s}_u \times\mathbf{s}_v}{ \| \mathbf{s}_u \times\mathbf{s}_v \| }$$

So we have:

$$K = \frac{ (\mathbf{s}_{uu} \cdot \mathbf{n})(\mathbf{s}_{vv} \cdot \mathbf{n}) - (\mathbf{s}_{uv} \cdot \mathbf{n})^2}{ (\mathbf{s}_u \cdot \mathbf{s}_u)(\mathbf{s}_v \cdot \mathbf{s}_v) - (\mathbf{s}_u \cdot \mathbf{s}_v)^2}$$

Page 5 line 14 of this document shows an even more compact way to express it:

$$K = \frac{ (\mathbf{s}_{u} \times \mathbf{s}_{v} ) \cdot ( \mathbf{n}_u \times \mathbf{n}_v)} { \| \mathbf{s}_{u} \times \mathbf{s}_{v} \|^2 }$$

# Note

This formula is calculated using the first ($\mathrm I$) and second fundamental form ($\mathrm{I\!I}$).

$$K = \frac{\det(\mathrm{I\!I})}{\det(\mathrm I)}$$

Where the first fundamental form is defined relying $\vec s(u,v)$:

$$\mathrm I = \begin{bmatrix} (\vec s_u \cdot \vec s_u) & (\vec s_u \cdot \vec s_v) \\ (\vec s_v \cdot \vec s_u) & (\vec s_v \cdot \vec s_v) \\ \end{bmatrix}$$

And the second fundamental form relies on $\vec n(u,v)$ as well:

$$\mathrm{I\!I} = \begin{bmatrix} (\vec s_{uu} \cdot \vec n) & (\vec s_{uv} \cdot \vec n) \\ (\vec s_{vu} \cdot \vec n) & (\vec s_{vv} \cdot \vec n)) \\ \end{bmatrix}$$

An alternate expression of $(\mathrm{I\!I})$ is also:

$$\mathrm{I\!I} = - \begin{bmatrix} (\vec s_{u} \cdot \vec n_u) & (\vec s_{u} \cdot \vec n_v) \\ (\vec s_{v} \cdot \vec n_u) & (\vec s_{v} \cdot \vec n_v)) \\ \end{bmatrix}$$

Let's show that $(\vec s_{uu} \cdot \vec n) = -(\vec s_{u} \cdot \vec n_u)$. First we start from the fact $\vec s_u \cdot \vec n = 0$ since the normal $\vec n$ is orthogonal to any tangent $\vec s_u$ or $\vec s_v$ of the surface. Now we differentiate with respect to $u$:

\begin{aligned} (\vec s_u \cdot \vec n)_u &= 0 \\ (\vec s_u)_u \cdot \vec n + \vec s_u \cdot (\vec n)_u &= 0 \annotation{\text{dot product rule}} \\ \vec s_{uu} \cdot \vec n + \vec s_u \cdot \vec n_u &= 0 \\ \vec s_{uu} \cdot \vec n &= - \vec s_u \cdot \vec n_u \end{aligned}

The other elements of the alternate expression of $(\mathrm{I\!I})$ can be derived in a similar fashion.

# Vector calculus exercise

## Exercise 1

Let's show $\vec s_u \cdot \vec n = 0$ with algebraic development:

\begin{aligned} \vec s_u \cdot \vec n &= \vec s_u \cdot \frac{\mathbf{s}_u \times\mathbf{s}_v}{ \| \mathbf{s}_u \times\mathbf{s}_v \| } \end{aligned}

You need to use the scalar triple product:

\begin{aligned} &a \cdot ( b \times c)= \\ &b \cdot ( c \times a)= \\ &c \cdot ( a \times b)\phantom{=} \end{aligned}

Tips: going trough the above lines in a top to down fashion, to find the line below the other, you need to shift the letter left, while doing a wrap-around (i.e. pacman like motion)

\begin{aligned} \vec s_u \cdot \vec n &= \vec s_u \cdot \frac{\mathbf{s}_u \times\mathbf{s}_v}{ \| \mathbf{s}_u \times\mathbf{s}_v \| } \\ &= \vec s_v \cdot \frac{\mathbf{s}_u \times\mathbf{s}_u}{ \| \mathbf{s}_u \times\mathbf{s}_v \| } \Annotation{\text{scalar triple product}} \\ &= \vec s_v \cdot \frac{\vec 0}{ \| \mathbf{s}_u \times\mathbf{s}_v \| } \Annotation{\text{ cross product of a vector with itself is 0 }}\\ &= 0 \end{aligned}

## Exercise 2

Let's show that $(\vec s_{uu} \cdot \vec n) = -(\vec s_{u} \cdot \vec n_u)$ algebraically. You may want to take a look at my cheat sheet on vector valued function differentiation

$$\Bigr [ \vec n(u,v) \Bigl ]_u = \left[ \frac{S_u \times S_v}{ \| S_u \times S_v \|} \right ]_u$$

To get more digest expressions we will use $g = g(u, v) = S_u(u,v) \times S_v(u,v)$, with this notation we also have $\| g \|^2 = g \cdot g$ or $\| g \| = \sqrt{g \cdot g}$. Therefore:

\begin{aligned} \Bigl [ \vec n(u,v) \Bigr ]_u &= \left[ \frac{g}{ \| g \|} \right ]_u \\ &= \frac{ \vec g_u . \|g\| + \vec g . \Bigr[ \| g \| \Bigl ]_u }{ \| \vec g \|^2} \end{aligned} Let's develop $\Bigl[ \| g \| \Bigr ]_u$: \begin{aligned} \Bigl[ \| g \| \Bigr ]_u &= \Biggl [ \sqrt{ \dot{g}{g} } \Biggr ]_u \\ &= \Bigl [ \dot{g}{g} \Bigr ]_u \ \ \frac{1}{2 \sqrt{\dot{g}{g}} } \Annotation{\text{chain rule}} \\ &= \Bigl ( \dot{g_u}{g} + \dot{g}{g_u} \Bigr ) \ \ \frac{1}{2 \sqrt{\dot{g}{g}} } \Annotation{\text{dot product rule}} \\ &= \Bigl ( 2 \dot{g_u}{g} \Bigr ) \ \ \frac{1}{2 \sqrt{\dot{g}{g}} } \\ &= \Bigl ( \dot{g_u}{g} \Bigr ) \ \ \frac{1}{\sqrt{\dot{g}{g}} } \\ &= \frac{\dot{g_u}{g}}{\sqrt{\dot{g}{g}} } \\ &= \frac{\dot{g_u}{g}}{ \| g \| } \\ \end{aligned}

Plug that in:

\begin{aligned} \Bigl [ \vec n(u,v) \Bigr ]_u &= \frac{ \vec g_u . \|g\| + \vec g . \Bigr[ \| g \| \Bigl ]_u }{ \| \vec g \|^2} \\ &= \frac{ \vec g_u . \|g\|}{ \| \vec g \|^2} + \frac{ \vec g . \Bigr[ \| g \| \Bigl ]_u }{ \| \vec g \|^2} \\ &= \frac{ \vec g_u }{ \| \vec g \|} + \frac{ \vec g . \Bigr[ \| g \| \Bigl ]_u }{ \| \vec g \|^2} \\ &= \frac{ \vec g_u }{ \| \vec g \|} + \frac{ \vec g . \Bigr( \frac{\dot{g_u}{g}}{ \| g \| } \Bigl ) }{ \| \vec g \|^2} \\ &= \frac{ \vec g_u }{ \| \vec g \|} + \frac{ \vec g }{ \| \vec g \|^2} . \frac{\dot{g_u}{g}}{ \| g \| } \\ &= \frac{ \vec g_u }{ \| \vec g \|} + \frac{ \vec g }{ \| \vec g \|^3} . \dot{g_u}{g}\\ \end{aligned}

From there it's best to apply $\vec s_{u} \cdot \vec n_u$ in order to simplify things:

\begin{aligned} \vec s_{u} \cdot \vec n_u &= \vec s_{u} \cdot \left ( \frac{ \vec g_u }{ \| \vec g \|} + \frac{ \vec g }{ \| \vec g \|^3} . \dot{g_u}{g} \right ) \\ &= \frac{ \vec s_{u} \cdot \vec g_u }{ \| \vec g \|} + \frac{\vec s_{u} \cdot \vec g }{ \| \vec g \|^3} . \dot{g_u}{g} \\ &= \frac{ \vec s_{u} \cdot \vec g_u }{ \| \vec g \|} + \frac{\vec s_{u} \cdot \vec n }{ \| \vec g \|^2} . \dot{g_u}{g} \\ &= \frac{ \vec s_{u} \cdot \vec g_u }{ \| \vec g \|} + \frac{ 0 }{ \| \vec g \|^2} . \dot{g_u}{g} \annotation{\text{We showed this in exercise 1}}\\ &= \frac{ \vec s_{u} \cdot \vec g_u }{ \| \vec g \|} \\ \end{aligned}

Let's develop in terms of $\vec s$

\begin{aligned} -\frac{ \vec s_{u} \cdot \vec g_u }{ \| \vec g \|} &= -\frac{ \vec s_{u} \cdot \Bigl [ s_u \times s_v \Bigr ]_u }{\| s_u \times s_v \|}\\ &= -\frac{ \vec s_{u} \cdot \Bigl [ s_{uu} \times s_v + s_u \times s_{vu} \Bigr ] }{\| s_u \times s_v \|} \annotation{\text{cross product rule}}\\ &= -\frac{ \vec s_{u} \cdot ( s_{uu} \times s_v) + \vec s_{u} \cdot (s_u \times s_{vu}) }{\| s_u \times s_v \|}\\ &= -\frac{ \vec s_{uu} \cdot ( s_v \times s_u ) + s_{vu} \cdot (s_u \times \vec s_{u}) }{\| s_u \times s_v \|} \annotation{\text{scalar trible product}}\\ &= -\frac{ \vec s_{uu} \cdot ( s_v \times s_u ) + s_{vu} \cdot (0) }{\| s_u \times s_v \|}\\ &= \frac{ \vec s_{uu} \cdot ( s_u \times s_v ) }{\| s_u \times s_v \|} \annotation{\text{cross product is anti-commutative}}\\ &= \vec s_{uu} \cdot \vec n \end{aligned}

# References

- Second fundamental form
- First fundamental form
- Page 4 line 19 coefficients are given as matrix elements (the coefficients E, F, G, L, M, and N are not explicitly used)
- Curvature formulas for implicit curves and surfaces by Ronald N. Goldman