Chapter 19
20 min read
Section 168 of 353

Parametric Surfaces

Vector Calculus

Learning Objectives

By the end of this section, you will be able to:

  1. Define parametric surfaces using a two-parameter mapping mathbfr(u,v)=langlex(u,v),y(u,v),z(u,v)rangle\\mathbf{r}(u, v) = \\langle x(u,v), y(u,v), z(u,v) \\rangle
  2. Construct parameterizations for common surfaces including spheres, cylinders, cones, tori, and surfaces of revolution
  3. Compute tangent vectors mathbfru\\mathbf{r}_u and mathbfrv\\mathbf{r}_v, and derive the normal vector mathbfn=mathbfrutimesmathbfrv\\mathbf{n} = \\mathbf{r}_u \\times \\mathbf{r}_v
  4. Calculate surface area using the integral iintDmathbfrutimesmathbfrv,dA\\iint_D |\\mathbf{r}_u \\times \\mathbf{r}_v| \\, dA
  5. Understand smooth, regular, and orientable surfaces, and recognize non-orientable surfaces like the Mobius strip
  6. Apply parametric surface concepts to computer graphics, physics simulations, and machine learning

The Big Picture: From Curves to Surfaces

"A parametric surface is the natural extension of a parametric curve: instead of one parameter tracing a path, two parameters sweep out a sheet in three-dimensional space."

We have already seen how a single parameter tt can trace out a curve in space: mathbfr(t)=langlex(t),y(t),z(t)rangle\\mathbf{r}(t) = \\langle x(t), y(t), z(t) \\rangle. Now we add a second parameter, giving us the power to describe surfaces:

mathbfr(u,v)=langlex(u,v),y(u,v),z(u,v)rangle\\mathbf{r}(u, v) = \\langle x(u,v), y(u,v), z(u,v) \\rangle

Each point (u,v)(u, v) in a 2D parameter domain maps to a point on the surface in 3D space.

Think of it this way:

Parametric Curve

mathbfr(t)\\mathbf{r}(t): One parameter t sweeps out a 1D path (a wire in space)

Parametric Surface

mathbfr(u,v)\\mathbf{r}(u, v): Two parameters sweep out a 2D sheet (a fabric in space)

Analogy

Like mapping a flat piece of paper (u-v plane) onto a crumpled or curved shape in 3D

Why Parametric Surfaces Matter

Many surfaces cannot be written as graphs z=f(x,y)z = f(x, y). A sphere, for example, requires multiple function pieces as a graph. But with a single parameterization, we can describe the entire sphere smoothly. This makes parametric surfaces essential for computer graphics, physics, and engineering.


Historical Context

Leonhard Euler (1707-1783)

Euler first systematically studied surfaces in 3D space, developing the theory of curvature and introducing what we now call the Euler characteristic. His work on the geometry of surfaces laid the foundation for differential geometry.

Carl Friedrich Gauss (1777-1855)

Gauss revolutionized the study of surfaces with his Theorema Egregium ("Remarkable Theorem"), showing that Gaussian curvature is an intrinsic property - it depends only on measurements made on the surface itself, not on how the surface sits in space.

Bernhard Riemann (1826-1866)

Riemann generalized these ideas to higher dimensions, creating the concept of a manifold - a space that locally looks like mathbbRn\\mathbb{R}^n. This is the mathematical framework underlying Einstein's general relativity, where spacetime itself is a 4-dimensional manifold.

Modern Applications

Today, parametric surfaces are fundamental to: CAD/CAM systems (designing cars, planes, buildings), video game and movie graphics, 3D printing, medical imaging (CT/MRI surface reconstruction), and machine learning (neural radiance fields, mesh generation).


Definition of Parametric Surfaces

Definition: Parametric Surface

A parametric surface is a continuous function mathbfr:DtomathbbR3\\mathbf{r}: D \\to \\mathbb{R}^3 where DsubseteqmathbbR2D \\subseteq \\mathbb{R}^2 is a region in the uv-plane. We write:

mathbfr(u,v)=x(u,v)mathbfi+y(u,v)mathbfj+z(u,v)mathbfk\\mathbf{r}(u, v) = x(u, v)\\mathbf{i} + y(u, v)\\mathbf{j} + z(u, v)\\mathbf{k}

The set S=mathbfr(u,v):(u,v)inDS = \\{\\mathbf{r}(u, v) : (u, v) \\in D\\} is the image of the parameterization - the actual surface in 3D space.

Parameter Curves

Holding one parameter fixed while varying the other traces out curves on the surface:

  • u-curves (v = constant): Fix v, let u vary. These are shown in red in the visualizations below.
  • v-curves (u = constant): Fix u, let v vary. These are shown in green.

These curves form a coordinate grid on the surface, analogous to lines of latitude and longitude on a globe.


Classic Examples of Parametric Surfaces

1. The Sphere

mathbfr(u,v)=(cosusinv,sinusinv,cosv)\\mathbf{r}(u, v) = (\\cos u \\sin v, \\sin u \\sin v, \\cos v)

Domain: uin[0,2pi]u \\in [0, 2\\pi], vin[0,pi]v \\in [0, \\pi]

Interpretation: uu is the azimuthal angle (longitude), vv is the polar angle (co-latitude).

2. The Cylinder

mathbfr(u,v)=(cosu,sinu,v)\\mathbf{r}(u, v) = (\\cos u, \\sin u, v)

Domain: uin[0,2pi]u \\in [0, 2\\pi], vin[h,h]v \\in [-h, h]

Interpretation: uu wraps around the cylinder, vv goes up and down.

3. The Cone

mathbfr(u,v)=(vcosu,vsinu,v)\\mathbf{r}(u, v) = (v \\cos u, v \\sin u, v)

Domain: uin[0,2pi]u \\in [0, 2\\pi], vge0v \\ge 0

Interpretation: The radius increases linearly with height.

4. The Torus

mathbfr(u,v)=((R+rcosv)cosu,(R+rcosv)sinu,rsinv)\\mathbf{r}(u, v) = ((R + r\\cos v)\\cos u, (R + r\\cos v)\\sin u, r\\sin v)

Domain: u,vin[0,2pi]u, v \\in [0, 2\\pi]

Interpretation: A circle of radius rr rotated around a circle of radius RR.

5. Surface of Revolution

Rotating y=f(x)y = f(x) around the x-axis:

mathbfr(u,v)=(u,f(u)cosv,f(u)sinv)\\mathbf{r}(u, v) = (u, f(u)\\cos v, f(u)\\sin v)

This generates many important surfaces: spheres, ellipsoids, hyperboloids, paraboloids.

Interactive: Surface Explorer

Explore different parametric surfaces below. Observe how the parameter grid (u-curves and v-curves) covers the surface.

Loading 3D surface visualizer...

Tangent Planes and Normal Vectors

At any point on a smooth surface, we can define a tangent plane that best approximates the surface locally. This plane is spanned by two tangent vectors obtained by differentiating with respect to each parameter.

Tangent Vectors and Normal Vector

The partial derivatives of mathbfr(u,v)\\mathbf{r}(u, v) give tangent vectors to the surface:

mathbfru=fracpartialmathbfrpartialu=leftlanglefracpartialxpartialu,fracpartialypartialu,fracpartialzpartialurightrangle\\mathbf{r}_u = \\frac{\\partial \\mathbf{r}}{\\partial u} = \\left\\langle \\frac{\\partial x}{\\partial u}, \\frac{\\partial y}{\\partial u}, \\frac{\\partial z}{\\partial u} \\right\\rangle
mathbfrv=fracpartialmathbfrpartialv=leftlanglefracpartialxpartialv,fracpartialypartialv,fracpartialzpartialvrightrangle\\mathbf{r}_v = \\frac{\\partial \\mathbf{r}}{\\partial v} = \\left\\langle \\frac{\\partial x}{\\partial v}, \\frac{\\partial y}{\\partial v}, \\frac{\\partial z}{\\partial v} \\right\\rangle

The normal vector is perpendicular to both tangent vectors:

mathbfn=mathbfrutimesmathbfrv\\mathbf{n} = \\mathbf{r}_u \\times \\mathbf{r}_v

Why the Cross Product?

The vectors mathbfru\\mathbf{r}_u and mathbfrv\\mathbf{r}_v lie in the tangent plane (they are tangent to the u-curves and v-curves respectively). Their cross product is perpendicular to both, hence perpendicular to the entire tangent plane - this is the normal vector.

The Tangent Plane Equation

At point mathbfr(u0,v0)\\mathbf{r}(u_0, v_0), the tangent plane consists of all points:

mathbfP=mathbfr(u0,v0)+scdotmathbfru+tcdotmathbfrv\\mathbf{P} = \\mathbf{r}(u_0, v_0) + s \\cdot \\mathbf{r}_u + t \\cdot \\mathbf{r}_v

where s,tinmathbbRs, t \\in \\mathbb{R}.

Interactive: Tangent Plane Demo

Move the sliders to change the point on the surface. Observe how the tangent vectors and normal vector change.

Loading tangent plane demo...

Surface Area

The surface area of a parametric surface is computed by integrating the area of infinitesimal parallelograms over the parameter domain.

Surface Area Formula

For a parametric surface mathbfr(u,v)\\mathbf{r}(u, v) with (u,v)inD(u, v) \\in D:

A=iintDmathbfrutimesmathbfrv,dAA = \\iint_D |\\mathbf{r}_u \\times \\mathbf{r}_v| \\, dA

The quantity mathbfrutimesmathbfrv|\\mathbf{r}_u \\times \\mathbf{r}_v| is the surface area element, measuring how much area in the uv-plane gets stretched when mapped to the surface.

Intuition: The Parallelogram Approximation

A small rectangle [u,u+du]times[v,v+dv][u, u+du] \\times [v, v+dv] in parameter space maps to a small parallelogram on the surface. This parallelogram has:

  • Sides approximately mathbfru,du\\mathbf{r}_u \\, du and mathbfrv,dv\\mathbf{r}_v \\, dv
  • Area mathbfrutimesmathbfrv,du,dv|\\mathbf{r}_u \\times \\mathbf{r}_v| \\, du \\, dv

Summing these areas over all patches gives the total surface area.

Special Case: Graph Surfaces

For a surface given as a graph z=f(x,y)z = f(x, y) over a region DD, we can parameterize as mathbfr(x,y)=(x,y,f(x,y))\\mathbf{r}(x, y) = (x, y, f(x, y)). Then:

mathbfrxtimesmathbfry=sqrt1+fx2+fy2|\\mathbf{r}_x \\times \\mathbf{r}_y| = \\sqrt{1 + f_x^2 + f_y^2}

So the surface area formula becomes:

A=iintDsqrt1+left(fracpartialfpartialxright)2+left(fracpartialfpartialyright)2,dAA = \\iint_D \\sqrt{1 + \\left(\\frac{\\partial f}{\\partial x}\\right)^2 + \\left(\\frac{\\partial f}{\\partial y}\\right)^2} \\, dA

Worked Example: Hemisphere Surface Area (Hand Computation)

Before clicking the interactive viewer below, try this entire derivation with paper and a pencil. It is the most important computation in this section — every other surface-area problem follows the exact same six steps.

Click to expand: derive the area of a hemisphere of radius R from scratch

Goal. Compute the area of the upper hemisphere x2+y2+z2=R2,;zge0x^2 + y^2 + z^2 = R^2, \\; z \\ge 0. The famous answer is 2piR22\\pi R^2. We will reach it without using any shortcut formula — only A=iintDmathbfrutimesmathbfrv,du,dvA = \\iint_D |\\mathbf{r}_u \\times \\mathbf{r}_v| \\, du \\, dv.

Step 1. Pick a parameterization

Use spherical coordinates with uu the azimuthal angle and vv the angle from the north pole:

mathbfr(u,v)=(Rsinvcosu,;Rsinvsinu,;Rcosv)\\mathbf{r}(u, v) = (R\\sin v \\cos u, \\; R\\sin v \\sin u, \\; R\\cos v)

For the upper hemisphere the parameter domain is D=[0,2pi]times[0,pi/2]D = [0, 2\\pi] \\times [0, \\pi/2]: u sweeps once around, v goes from the north pole down to the equator.

Step 2. Compute the two tangent vectors

Differentiate each component with respect to uu first, treating vv as a constant:

mathbfru=(Rsinvsinu,;Rsinvcosu,;0)\\mathbf{r}_u = (-R\\sin v \\sin u, \\; R\\sin v \\cos u, \\; 0)

Now differentiate with respect to vv, treating uu as a constant:

mathbfrv=(Rcosvcosu,;Rcosvsinu,;Rsinv)\\mathbf{r}_v = (R\\cos v \\cos u, \\; R\\cos v \\sin u, \\; -R\\sin v)

Sanity check. At the equator (v=pi/2)(v = \\pi/2): mathbfru\\mathbf{r}_u points horizontally along the parallel, mathbfrv=(0,0,R)\\mathbf{r}_v = (0, 0, -R) points straight down — both tangent to the sphere, as expected.

Step 3. Take the cross product mathbfrutimesmathbfrv\\mathbf{r}_u \\times \\mathbf{r}_v

Set up the determinant:

\\mathbf{r}_u \\times \\mathbf{r}_v = \\begin{vmatrix} \\mathbf{i} & \\mathbf{j} & \\mathbf{k} \\\\ -R\\sin v \\sin u & R\\sin v \\cos u & 0 \\\\ R\\cos v \\cos u & R\\cos v \\sin u & -R\\sin v \\end{vmatrix}

Expand component by component:

mathbfitextcomponent=(Rsinvcosu)(Rsinv)0=R2sin2vcosu\\mathbf{i}\\text{-component} = (R\\sin v \\cos u)(-R\\sin v) - 0 = -R^2 \\sin^2 v \\cos u
mathbfjtextcomponent=bigl[(Rsinvsinu)(Rsinv)0bigr]=R2sin2vsinu\\mathbf{j}\\text{-component} = -\\bigl[(-R\\sin v \\sin u)(-R\\sin v) - 0\\bigr] = -R^2 \\sin^2 v \\sin u
mathbfktextcomponent=(Rsinvsinu)(Rcosvsinu)(Rsinvcosu)(Rcosvcosu)=R2sinvcosv(sin2u+cos2u)=R2sinvcosv\\mathbf{k}\\text{-component} = (-R\\sin v \\sin u)(R\\cos v \\sin u) - (R\\sin v \\cos u)(R\\cos v \\cos u) = -R^2 \\sin v \\cos v (\\sin^2 u + \\cos^2 u) = -R^2 \\sin v \\cos v

So:

mathbfrutimesmathbfrv=R2sinv,(sinvcosu,;sinvsinu,;cosv)\\mathbf{r}_u \\times \\mathbf{r}_v = -R^2 \\sin v \\,(\\sin v \\cos u, \\; \\sin v \\sin u, \\; \\cos v)

Notice the bracketed vector is exactly mathbfr(u,v)/R\\mathbf{r}(u,v)/R — the unit outward normal! The cross product is parallel to the position vector, as geometry demands for a sphere.

Step 4. Take the magnitude mathbfrutimesmathbfrv|\\mathbf{r}_u \\times \\mathbf{r}_v|

Square each component, sum, and take the square root:

mathbfrutimesmathbfrv2=R4sin2v,bigl(sin2vcos2u+sin2vsin2u+cos2vbigr)|\\mathbf{r}_u \\times \\mathbf{r}_v|^2 = R^4 \\sin^2 v \\,\\bigl(\\sin^2 v \\cos^2 u + \\sin^2 v \\sin^2 u + \\cos^2 v\\bigr)

Factor sin2v\\sin^2 v from the first two terms and use cos2u+sin2u=1\\cos^2 u + \\sin^2 u = 1:

=R4sin2v,(sin2v+cos2v)=R4sin2v= R^4 \\sin^2 v \\,(\\sin^2 v + \\cos^2 v) = R^4 \\sin^2 v

Take the positive square root (note sinvge0\\sin v \\ge 0 on [0,pi/2][0, \\pi/2]):

mathbfrutimesmathbfrv=R2sinv|\\mathbf{r}_u \\times \\mathbf{r}_v| = R^2 \\sin v

This is the famous spherical surface-area element dS=R2sinv,du,dvdS = R^2 \\sin v \\, du \\, dv you may have seen before — but now you derived it.

Step 5. Set up and integrate

The surface-area integral splits because the integrand has no u-dependence:

A=int02piint0pi/2R2sinv,dv,du=R2left(int02piduright)left(int0pi/2sinv,dvright)A = \\int_0^{2\\pi} \\int_0^{\\pi/2} R^2 \\sin v \\, dv \\, du = R^2 \\left(\\int_0^{2\\pi} du\\right) \\left(\\int_0^{\\pi/2} \\sin v \\, dv\\right)

The u-integral is trivial:

int02pidu=2pi\\int_0^{2\\pi} du = 2\\pi

For the v-integral, recall intsinv,dv=cosv\\int \\sin v \\, dv = -\\cos v:

int0pi/2sinv,dv=[cosv]0pi/2=cos(pi/2)+cos(0)=0+1=1\\int_0^{\\pi/2} \\sin v \\, dv = [-\\cos v]_0^{\\pi/2} = -\\cos(\\pi/2) + \\cos(0) = 0 + 1 = 1

Step 6. Multiply and interpret

A=R2cdot2picdot1=2piR2;;checkmarkA = R^2 \\cdot 2\\pi \\cdot 1 = 2\\pi R^2 \\;\\;\\checkmark

The full sphere therefore has area 4piR24\\pi R^2 (two hemispheres) — exactly the number on every geometry table. We never used a memorized formula; we built it from mathbfrutimesmathbfrv\\mathbf{r}_u \\times \\mathbf{r}_v alone.

The recipe in six words: parameterize, differentiate, cross, magnify, integrate, interpret. Any parametric surface yields its area through these same six steps — change only the parameterization, and the rest follows.

Quick numerical check at R = 1

Plug R=1R = 1 into 2piR22\\pi R^2: Aapprox6.283185ldotsA \\approx 6.283185\\ldots. The Python Riemann-sum demo further down converges to the same number — type R=1R = 1 and let it run.

Interactive: Surface Area Visualization

Watch how the surface is approximated by parallelograms. As the number of patches increases, the approximation converges to the true surface area.

Loading surface area visualization...

Smooth and Regular Surfaces

Definition: Smooth (Regular) Parametric Surface

A parametric surface mathbfr(u,v)\\mathbf{r}(u, v) is smooth (or regular) if:

  1. mathbfru\\mathbf{r}_u and mathbfrv\\mathbf{r}_v exist and are continuous
  2. mathbfrutimesmathbfrvneqmathbf0\\mathbf{r}_u \\times \\mathbf{r}_v \\neq \\mathbf{0} at every point (the tangent vectors are never parallel)

When mathbfrutimesmathbfrv=mathbf0\\mathbf{r}_u \\times \\mathbf{r}_v = \\mathbf{0}, the surface has a singularity - the normal is undefined and the tangent plane degenerates.

Examples of Singularities

SurfaceSingularityWhat Happens
Cone at apexv=0v = 0The tip is a point where all directions converge
Sphere at polesv=0,piv = 0, \\piAll longitude lines meet; direction undefined
Cusp on a surfacePointSharp corner where tangent plane is undefined

Singularities in Integration

When computing surface integrals, singularities must be handled carefully. Often we exclude small neighborhoods around singular points and show the integral still converges.


Orientability

An important property of surfaces is whether they are orientable - whether we can consistently choose a "positive" side everywhere.

Orientable Surfaces

An orientable surface has two distinct sides. We can choose a continuous unit normal vector field hatmathbfn\\hat{\\mathbf{n}} that varies smoothly over the entire surface.

Examples: Sphere, torus, paraboloid, any surface that encloses a volume.

Non-Orientable Surfaces

A non-orientable surface has only one side. If you try to define a continuous normal vector field, you return to your starting point with the normal pointing the opposite direction!

Examples: Mobius strip, Klein bottle.

The Mobius Strip

The Mobius strip is the most famous non-orientable surface. It is parameterized as:

mathbfr(u,v)=left((1+vcosfracu2)cosu,;(1+vcosfracu2)sinu,;vsinfracu2right)\\mathbf{r}(u, v) = \\left((1 + v\\cos\\frac{u}{2})\\cos u, \\;(1 + v\\cos\\frac{u}{2})\\sin u, \\;v\\sin\\frac{u}{2}\\right)

The key is the u/2u/2 term: as uu goes from 00 to 2pi2\\pi, the strip makes a half-twist, connecting back with opposite orientation.

Orientability and Surface Integrals

For flux integrals (like Stokes' Theorem), we need an oriented surface with a chosen normal direction. Non-orientable surfaces cannot have well-defined flux integrals over the whole surface.


Real-World Applications

1. Computer Graphics and CAD

Parametric surfaces are the foundation of 3D modeling. NURBS (Non-Uniform Rational B-Splines) are parametric surfaces used in:

  • Automotive design (car bodies, interiors)
  • Aerospace (aircraft fuselages, wing surfaces)
  • Product design (consumer electronics, furniture)
  • Animation and visual effects

2. Physics and Engineering

Parametric surfaces appear in:

  • Fluid dynamics: Describing the boundary of objects for flow calculations
  • Electromagnetism: Computing flux through surfaces (Gauss's Law)
  • Heat transfer: Modeling heat exchange surfaces
  • Structural analysis: Shell structures, membrane stress analysis

3. Medical Imaging

3D reconstruction from CT/MRI scans produces parametric surface representations of organs, tumors, and anatomical structures for:

  • Surgical planning
  • Prosthetic design
  • Radiation therapy targeting

Machine Learning Connections

Parametric surfaces appear throughout modern machine learning, particularly in 3D vision and generative models.

1. The Manifold Hypothesis

A fundamental assumption in ML is that high-dimensional data lies on a low-dimensional manifold (a generalization of surfaces to higher dimensions). Autoencoders and VAEs learn parameterizations of these manifolds.

VAE Decoder as Parameterization: A VAE with 2D latent space learns a mapping f:mathbbR2tomathbbRnf: \\mathbb{R}^2 \\to \\mathbb{R}^n from latent codes to observations. This is exactly a parametric surface!

2. 3D Generation and Reconstruction

  • Mesh Generation: Neural networks output vertex positions for triangle meshes, which are piecewise linear surfaces
  • Neural Radiance Fields (NeRF): Represent surfaces implicitly as level sets of density functions
  • Shape Deformation: Learn parameterized deformations of template surfaces

3. Surface Normals in Neural Rendering

Computing realistic lighting requires surface normals. In differentiable rendering:

textBrightness=max(0,mathbfncdotmathbfL)\\text{Brightness} = \\max(0, \\mathbf{n} \\cdot \\mathbf{L})

where mathbfn\\mathbf{n} is the surface normal and mathbfL\\mathbf{L} is the light direction. Gradients through this computation allow end-to-end learning of 3D geometry.

4. Physics-Informed Neural Networks (PINNs)

When solving PDEs on curved domains, the domain boundary is often a parametric surface. PINNs incorporate surface geometry through:

  • Boundary condition enforcement on parametric surfaces
  • Surface integrals computed via the parameterization
  • Differential operators expressed in surface coordinates

Key Insight for ML Practitioners

Understanding parametric surfaces helps you:

  • Design better 3D generative models
  • Implement differentiable rendering correctly
  • Work with mesh-based neural networks
  • Understand the geometry of latent spaces

Python Implementation

Visualizing Parametric Surfaces

Classic Parametric Surfaces
🐍parametric_surfaces.py
7Parametric Surface Definition

A parametric surface maps each (u, v) point in a 2D domain to a 3D point (x, y, z). This is the 2D analog of a parametric curve.

18Spherical Parameterization

The sphere uses spherical coordinates: u is the azimuthal angle (longitude), v is the polar angle (latitude from pole). This covers the entire sphere as u and v vary.

31Torus Parameterization

A torus is generated by rotating a circle of radius r around a circle of radius R. Parameter u goes around the main loop, v goes around the tube.

66Helicoid - Minimal Surface

The helicoid is a ruled surface (composed of straight lines) that is also a minimal surface. Along with the catenoid, it's one of only two ruled minimal surfaces.

78Möbius Strip - Non-orientable

The Möbius strip has only one side! The half-twist in the u/2 terms causes the normal vector to reverse after going around once, making it non-orientable.

94 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3from mpl_toolkits.mplot3d import Axes3D
4
5def parametric_surface_examples():
6    """
7    Visualize classic parametric surfaces in 3D.
8
9    A parametric surface r(u, v) = (x(u,v), y(u,v), z(u,v))
10    maps a 2D parameter domain to a 3D surface.
11    """
12    fig = plt.figure(figsize=(16, 12))
13
14    # 1. Sphere
15    ax1 = fig.add_subplot(2, 3, 1, projection='3d')
16    u = np.linspace(0, 2*np.pi, 50)
17    v = np.linspace(0, np.pi, 50)
18    U, V = np.meshgrid(u, v)
19
20    # Spherical parameterization: r(u,v) = (cos(u)sin(v), sin(u)sin(v), cos(v))
21    X = np.cos(U) * np.sin(V)
22    Y = np.sin(U) * np.sin(V)
23    Z = np.cos(V)
24
25    ax1.plot_surface(X, Y, Z, cmap='viridis', alpha=0.8)
26    ax1.set_title('Sphere\nr = (cos u sin v, sin u sin v, cos v)')
27
28    # 2. Torus
29    ax2 = fig.add_subplot(2, 3, 2, projection='3d')
30    R, r = 2, 0.5  # Major and minor radii
31
32    # Torus parameterization
33    X = (R + r*np.cos(V)) * np.cos(U)
34    Y = (R + r*np.cos(V)) * np.sin(U)
35    Z = r * np.sin(V)
36
37    ax2.plot_surface(X, Y, Z, cmap='plasma', alpha=0.8)
38    ax2.set_title('Torus (R=2, r=0.5)')
39
40    # 3. Paraboloid
41    ax3 = fig.add_subplot(2, 3, 3, projection='3d')
42    u = np.linspace(0, 2*np.pi, 50)
43    v = np.linspace(0, 1.5, 50)
44    U, V = np.meshgrid(u, v)
45
46    # Paraboloid: z = x² + y² in polar-like form
47    X = V * np.cos(U)
48    Y = V * np.sin(U)
49    Z = V**2
50
51    ax3.plot_surface(X, Y, Z, cmap='coolwarm', alpha=0.8)
52    ax3.set_title('Paraboloid\nz = x² + y²')
53
54    # 4. Helicoid
55    ax4 = fig.add_subplot(2, 3, 4, projection='3d')
56    u = np.linspace(0, 4*np.pi, 100)
57    v = np.linspace(-1, 1, 30)
58    U, V = np.meshgrid(u, v)
59
60    # Helicoid parameterization
61    X = V * np.cos(U)
62    Y = V * np.sin(U)
63    Z = U * 0.3
64
65    ax4.plot_surface(X, Y, Z, cmap='twilight', alpha=0.8)
66    ax4.set_title('Helicoid\n(Minimal Surface)')
67
68    # 5. Möbius Strip
69    ax5 = fig.add_subplot(2, 3, 5, projection='3d')
70    u = np.linspace(0, 2*np.pi, 100)
71    v = np.linspace(-0.3, 0.3, 20)
72    U, V = np.meshgrid(u, v)
73
74    # Möbius strip parameterization
75    X = (1 + V*np.cos(U/2)) * np.cos(U)
76    Y = (1 + V*np.cos(U/2)) * np.sin(U)
77    Z = V * np.sin(U/2)
78
79    ax5.plot_surface(X, Y, Z, cmap='magma', alpha=0.9)
80    ax5.set_title('Möbius Strip\n(Non-orientable)')
81
82    # 6. Saddle (Hyperbolic Paraboloid)
83    ax6 = fig.add_subplot(2, 3, 6, projection='3d')
84    u = np.linspace(-1.5, 1.5, 50)
85    v = np.linspace(-1.5, 1.5, 50)
86    U, V = np.meshgrid(u, v)
87
88    # Simple rectangular parameterization
89    X = U
90    Y = V
91    Z = U**2 - V**2
92
93    ax6.plot_surface(X, Y, Z, cmap='RdYlBu', alpha=0.8)
94    ax6.set_title('Saddle\nz = x² - y²')
95
96    plt.tight_layout()
97    plt.show()
98
99parametric_surface_examples()

Computing Tangent Planes and Normals

Tangent Plane Visualization
🐍tangent_plane.py
4Computing Tangent Vectors

The tangent vectors r_u = ∂r/∂u and r_v = ∂r/∂v are computed using central differences. These vectors lie in the tangent plane.

22Numerical Partial Derivatives

We approximate ∂r/∂u ≈ [r(u+h, v) - r(u-h, v)] / 2h using central differences, which has O(h²) error.

26Normal Vector

The normal n = r_u × r_v is perpendicular to both tangent vectors, hence perpendicular to the tangent plane. We normalize it to unit length.

56Tangent Plane Parameterization

The tangent plane at point P is {P + s·r_u + t·r_v : s, t ∈ ℝ}. We sample this for visualization.

98 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3from mpl_toolkits.mplot3d import Axes3D
4
5def compute_tangent_and_normal(surface_func, u, v, h=1e-6):
6    """
7    Compute the tangent vectors r_u, r_v and normal vector n
8    at a point (u, v) on a parametric surface.
9
10    The tangent plane is spanned by r_u and r_v.
11    The normal vector n = r_u × r_v is perpendicular to the surface.
12
13    Args:
14        surface_func: Function (u, v) -> (x, y, z)
15        u, v: Parameter values
16        h: Step size for numerical derivatives
17
18    Returns:
19        point: The point r(u, v) on the surface
20        r_u: Partial derivative ∂r/∂u
21        r_v: Partial derivative ∂r/∂v
22        normal: Unit normal vector n = r_u × r_v / |r_u × r_v|
23    """
24    # Get the point
25    point = np.array(surface_func(u, v))
26
27    # Compute partial derivatives numerically
28    r_u = (np.array(surface_func(u + h, v)) - np.array(surface_func(u - h, v))) / (2*h)
29    r_v = (np.array(surface_func(u, v + h)) - np.array(surface_func(u, v - h))) / (2*h)
30
31    # Normal = cross product of tangent vectors
32    normal = np.cross(r_u, r_v)
33    normal = normal / np.linalg.norm(normal)  # Normalize
34
35    return point, r_u, r_v, normal
36
37def visualize_tangent_plane():
38    """
39    Visualize a surface with its tangent plane and normal vector
40    at a specific point.
41    """
42    # Define a surface: z = sin(x) * cos(y)
43    def surface(u, v):
44        x = u
45        y = v
46        z = np.sin(u) * np.cos(v)
47        return (x, y, z)
48
49    # Create surface mesh
50    u = np.linspace(-2, 2, 40)
51    v = np.linspace(-2, 2, 40)
52    U, V = np.meshgrid(u, v)
53    X, Y, Z = surface(U, V)
54
55    # Choose a point to compute tangent plane
56    u0, v0 = 0.5, 0.3
57    point, r_u, r_v, normal = compute_tangent_and_normal(surface, u0, v0)
58
59    # Create tangent plane
60    s = np.linspace(-0.5, 0.5, 10)
61    t = np.linspace(-0.5, 0.5, 10)
62    S, T = np.meshgrid(s, t)
63
64    # Tangent plane: P = point + s*r_u + t*r_v
65    X_plane = point[0] + S*r_u[0] + T*r_v[0]
66    Y_plane = point[1] + S*r_u[1] + T*r_v[1]
67    Z_plane = point[2] + S*r_u[2] + T*r_v[2]
68
69    # Visualize
70    fig = plt.figure(figsize=(12, 10))
71    ax = fig.add_subplot(111, projection='3d')
72
73    # Plot surface
74    ax.plot_surface(X, Y, Z, cmap='Blues', alpha=0.6)
75
76    # Plot tangent plane
77    ax.plot_surface(X_plane, Y_plane, Z_plane, color='gold', alpha=0.7)
78
79    # Plot tangent vectors
80    scale = 0.4
81    ax.quiver(*point, *r_u*scale, color='red', linewidth=3,
82              arrow_length_ratio=0.2, label='r_u')
83    ax.quiver(*point, *r_v*scale, color='green', linewidth=3,
84              arrow_length_ratio=0.2, label='r_v')
85    ax.quiver(*point, *normal*scale, color='purple', linewidth=3,
86              arrow_length_ratio=0.2, label='n')
87
88    # Plot the point
89    ax.scatter(*point, color='black', s=100, zorder=5)
90
91    ax.set_xlabel('X')
92    ax.set_ylabel('Y')
93    ax.set_zlabel('Z')
94    ax.set_title('Tangent Plane and Normal Vector\n' +
95                 f'at (u, v) = ({u0}, {v0})\n' +
96                 f'n = r_u × r_v = ({normal[0]:.2f}, {normal[1]:.2f}, {normal[2]:.2f})')
97
98    plt.legend()
99    plt.tight_layout()
100    plt.show()
101
102visualize_tangent_plane()

Surface Area Calculation

Surface Area Approximation
🐍surface_area.py
4The Surface Area Formula

Surface area is the double integral of |r_u × r_v| over the parameter domain. This measures how much the parameterization stretches area.

15For Graph Surfaces

When z = f(x,y), we have r = (x, y, f(x,y)), so r_x = (1, 0, f_x) and r_y = (0, 1, f_y). The cross product gives |r_x × r_y| = √(1 + f_x² + f_y²).

37Riemann Sum Approximation

We divide the parameter domain into n×n cells, evaluate |r_u × r_v| at each cell center, and sum. This converges to the exact integral as n → ∞.

64Convergence Analysis

As n increases, the approximation converges. The relative change between successive estimates decreases, indicating convergence.

78 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3from mpl_toolkits.mplot3d import Axes3D
4
5def surface_area_approximation():
6    """
7    Compute surface area using the formula:
8
9        A = ∬_D |r_u × r_v| dA
10
11    This integrates the magnitude of the cross product over the
12    parameter domain. Each small patch dA in parameter space
13    maps to a parallelogram of area |r_u × r_v| du dv on the surface.
14
15    For a graph z = f(x, y):
16        |r_u × r_v| = √(1 + f_x² + f_y²)
17    """
18    # Define a paraboloid z = x² + y² over [-1, 1] × [-1, 1]
19    def surface(u, v):
20        return (u, v, u**2 + v**2)
21
22    def compute_area_element(u, v, h=1e-5):
23        """Compute |r_u × r_v| at (u, v)"""
24        r_u = np.array([
25            (surface(u+h, v)[0] - surface(u-h, v)[0]) / (2*h),
26            (surface(u+h, v)[1] - surface(u-h, v)[1]) / (2*h),
27            (surface(u+h, v)[2] - surface(u-h, v)[2]) / (2*h)
28        ])
29        r_v = np.array([
30            (surface(u, v+h)[0] - surface(u, v-h)[0]) / (2*h),
31            (surface(u, v+h)[1] - surface(u, v-h)[1]) / (2*h),
32            (surface(u, v+h)[2] - surface(u, v-h)[2]) / (2*h)
33        ])
34        cross = np.cross(r_u, r_v)
35        return np.linalg.norm(cross)
36
37    # Numerical integration using Riemann sum
38    def compute_surface_area(n_divisions):
39        """
40        Approximate surface area using n × n subdivisions.
41        """
42        u_vals = np.linspace(-1, 1, n_divisions + 1)
43        v_vals = np.linspace(-1, 1, n_divisions + 1)
44        du = 2 / n_divisions
45        dv = 2 / n_divisions
46
47        total_area = 0
48        for i in range(n_divisions):
49            for j in range(n_divisions):
50                u_mid = (u_vals[i] + u_vals[i+1]) / 2
51                v_mid = (v_vals[j] + v_vals[j+1]) / 2
52                area_element = compute_area_element(u_mid, v_mid)
53                total_area += area_element * du * dv
54
55        return total_area
56
57    # Compare different resolutions
58    print("Surface Area Approximation for z = x² + y² over [-1,1]×[-1,1]")
59    print("-" * 50)
60    print(f"{'n':>5} {'Area Estimate':>15} {'Rel. Change':>12}")
61    print("-" * 50)
62
63    prev_area = 0
64    for n in [5, 10, 20, 40, 80, 160]:
65        area = compute_surface_area(n)
66        change = abs(area - prev_area) / area * 100 if prev_area > 0 else 0
67        print(f"{n:5d} {area:15.8f} {change:11.4f}%")
68        prev_area = area
69
70    # Analytical result for comparison (computed via numerical integration)
71    # For z = x² + y², |r_u × r_v| = √(1 + 4x² + 4y²)
72    from scipy import integrate
73    def integrand(x, y):
74        return np.sqrt(1 + 4*x**2 + 4*y**2)
75
76    exact, _ = integrate.dblquad(integrand, -1, 1, -1, 1)
77    print("-" * 50)
78    print(f"High-precision estimate: {exact:.8f}")
79
80    return prev_area
81
82area = surface_area_approximation()

Machine Learning Connections

Parametric Surfaces in ML
🐍surfaces_in_ml.py
4Manifold Hypothesis

In ML, high-dimensional data often lies on a low-dimensional manifold - a parametric surface embedded in the observation space.

30VAE Decoder as Parameterization

A VAE decoder maps 2D latent codes (u, v) to 3D observations. This is exactly a parametric surface r(u, v)!

65Surface Normals in Rendering

Neural rendering (NeRF, etc.) needs surface normals for lighting. These come from n = r_u × r_v for parametric surfaces.

71Lambertian Shading

The dot product n · L determines brightness. Understanding surface geometry is essential for photorealistic neural rendering.

122 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3from mpl_toolkits.mplot3d import Axes3D
4
5def neural_surface_representation():
6    """
7    Demonstrate how parametric surfaces appear in ML:
8
9    1. **Latent Space Manifolds**: Data often lies on low-dimensional
10       surfaces embedded in high-dimensional space.
11
12    2. **3D Reconstruction**: Neural networks learn to output
13       surface parameterizations for 3D object generation.
14
15    3. **Neural Radiance Fields (NeRF)**: Learn surfaces implicitly
16       as level sets of density functions.
17
18    4. **Mesh Deformation**: Learn mappings that deform template
19       surfaces to match target shapes.
20    """
21    np.random.seed(42)
22
23    # Example 1: Data on a 2D manifold in 3D
24    # (simulating a VAE latent space mapped to observations)
25    print("=" * 60)
26    print("Example: Latent Space Manifold")
27    print("=" * 60)
28
29    # Latent codes (u, v) on a 2D grid
30    n_samples = 500
31    u = np.random.uniform(0, 2*np.pi, n_samples)
32    v = np.random.uniform(0, np.pi, n_samples)
33
34    # "Decoder" maps latent codes to 3D observations (a sphere + noise)
35    # This is analogous to a VAE decoder learning a manifold
36    x = np.cos(u) * np.sin(v) + 0.05 * np.random.randn(n_samples)
37    y = np.sin(u) * np.sin(v) + 0.05 * np.random.randn(n_samples)
38    z = np.cos(v) + 0.05 * np.random.randn(n_samples)
39
40    fig = plt.figure(figsize=(14, 5))
41
42    # Plot 1: Latent space (parameter domain)
43    ax1 = fig.add_subplot(1, 3, 1)
44    ax1.scatter(u, v, c=z, cmap='viridis', s=5)
45    ax1.set_xlabel('Latent dimension u')
46    ax1.set_ylabel('Latent dimension v')
47    ax1.set_title('Latent Space (2D)\nParameter Domain')
48
49    # Plot 2: Observed data (surface)
50    ax2 = fig.add_subplot(1, 3, 2, projection='3d')
51    ax2.scatter(x, y, z, c=z, cmap='viridis', s=5)
52    ax2.set_xlabel('X')
53    ax2.set_ylabel('Y')
54    ax2.set_zlabel('Z')
55    ax2.set_title('Observation Space (3D)\nParametric Surface')
56
57    # Plot 3: The "true" surface the data lives on
58    ax3 = fig.add_subplot(1, 3, 3, projection='3d')
59    u_grid = np.linspace(0, 2*np.pi, 50)
60    v_grid = np.linspace(0, np.pi, 50)
61    U, V = np.meshgrid(u_grid, v_grid)
62    X = np.cos(U) * np.sin(V)
63    Y = np.sin(U) * np.sin(V)
64    Z = np.cos(V)
65    ax3.plot_surface(X, Y, Z, cmap='viridis', alpha=0.7)
66    ax3.set_title('Underlying Manifold\n(Learned Surface)')
67
68    plt.tight_layout()
69    plt.show()
70
71    # Example 2: Surface normal for lighting in neural rendering
72    print("\n" + "=" * 60)
73    print("Example: Surface Normals in Neural Rendering")
74    print("=" * 60)
75
76    def compute_shading(normal, light_dir):
77        """
78        Lambertian shading: brightness = max(0, n · L)
79
80        This is used in neural rendering to compute how surfaces
81        interact with light. The normal n is computed from the
82        parametric surface via n = r_u × r_v.
83        """
84        light_dir = light_dir / np.linalg.norm(light_dir)
85        return np.maximum(0, np.sum(normal * light_dir, axis=-1))
86
87    # Create a surface and compute normals
88    u = np.linspace(0, 2*np.pi, 100)
89    v = np.linspace(0, np.pi, 100)
90    U, V = np.meshgrid(u, v)
91
92    X = np.cos(U) * np.sin(V)
93    Y = np.sin(U) * np.sin(V)
94    Z = np.cos(V)
95
96    # Compute normals analytically for sphere
97    normals = np.stack([X, Y, Z], axis=-1)
98    normals = normals / np.linalg.norm(normals, axis=-1, keepdims=True)
99
100    # Light from different directions
101    fig, axes = plt.subplots(1, 3, figsize=(14, 5))
102    light_dirs = [
103        np.array([1, 0, 0]),   # From right
104        np.array([0, 1, 0]),   # From top
105        np.array([1, 1, 1]),   # From corner
106    ]
107
108    for ax, light_dir in zip(axes, light_dirs):
109        shading = compute_shading(normals, light_dir)
110        ax.imshow(shading, cmap='gray', extent=[0, 2*np.pi, 0, np.pi])
111        ax.set_xlabel('u (azimuthal angle)')
112        ax.set_ylabel('v (polar angle)')
113        ax.set_title(f'Light direction: {light_dir}')
114
115    plt.suptitle('Surface Shading from Normal Vectors\n(Key in Neural Rendering)')
116    plt.tight_layout()
117    plt.show()
118
119    print("\nKey ML Applications of Parametric Surfaces:")
120    print("• VAE/GAN latent manifolds")
121    print("• 3D mesh generation and deformation")
122    print("• Neural Radiance Fields (NeRF)")
123    print("• Physics-informed neural networks (PINNs)")
124    print("• Geometric deep learning on surfaces")
125
126neural_surface_representation()

Test Your Understanding


Summary

Parametric surfaces extend the concept of parametric curves to two dimensions, providing a powerful tool for describing surfaces in 3D space.

Key Concepts

ConceptDescription
Parametric Surfacemathbfr(u,v)=(x(u,v),y(u,v),z(u,v))\\mathbf{r}(u, v) = (x(u,v), y(u,v), z(u,v)) maps a 2D domain to 3D
Tangent Vectorsmathbfru\\mathbf{r}_u and mathbfrv\\mathbf{r}_v are partial derivatives, tangent to parameter curves
Normal Vectormathbfn=mathbfrutimesmathbfrv\\mathbf{n} = \\mathbf{r}_u \\times \\mathbf{r}_v is perpendicular to the tangent plane
Surface AreaA=iintmathbfrutimesmathbfrv,dAA = \\iint |\\mathbf{r}_u \\times \\mathbf{r}_v| \\, dA integrates the area element
Smooth Surfacemathbfrutimesmathbfrvneqmathbf0\\mathbf{r}_u \\times \\mathbf{r}_v \\neq \\mathbf{0} everywhere (no singularities)
OrientableHas two sides; can define consistent normal direction

Key Takeaways

  1. Two parameters (u,v)(u, v) sweep out a 2D surface in 3D space, unlike one parameter for curves
  2. Tangent vectors mathbfru\\mathbf{r}_u and mathbfrv\\mathbf{r}_v span the tangent plane; their cross product gives the normal
  3. Surface area is computed by integrating mathbfrutimesmathbfrv|\\mathbf{r}_u \\times \\mathbf{r}_v|, which measures stretching from parameter space
  4. Smoothness requires mathbfrutimesmathbfrvneqmathbf0\\mathbf{r}_u \\times \\mathbf{r}_v \\neq \\mathbf{0}; singularities occur at points like cone apexes
  5. Orientability determines whether a surface has two sides (sphere) or one (Mobius strip)
  6. Applications span computer graphics, physics, medical imaging, and machine learning (3D generation, neural rendering)
The Essence of Parametric Surfaces:
"A parametric surface is a map from a flat world to a curved one - transforming the plane of parameters into the rich geometry of three-dimensional space."
Coming Next: In the next section, we will study surface integrals - the natural way to integrate functions over parametric surfaces. We will learn to compute flux through surfaces and see how these integrals connect to the powerful theorems of vector calculus: Stokes' Theorem and the Divergence Theorem.
Loading comments...