Define parametric surfaces using a two-parameter mapping mathbfr(u,v)=langlex(u,v),y(u,v),z(u,v)rangle
Construct parameterizations for common surfaces including spheres, cylinders, cones, tori, and surfaces of revolution
Compute tangent vectors mathbfru and mathbfrv, and derive the normal vector mathbfn=mathbfrutimesmathbfrv
Calculate surface area using the integral iintD∣mathbfrutimesmathbfrv∣,dA
Understand smooth, regular, and orientable surfaces, and recognize non-orientable surfaces like the Mobius strip
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 t can trace out a curve in space: mathbfr(t)=langlex(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
Each point (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): One parameter t sweeps out a 1D path (a wire in space)
Parametric Surface
mathbfr(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). 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. 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 where DsubseteqmathbbR2 is a region in the uv-plane. We write:
The set S=mathbfr(u,v):(u,v)inD 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)
Domain:uin[0,2pi], vin[0,pi]
Interpretation:u is the azimuthal angle (longitude), v is the polar angle (co-latitude).
2. The Cylinder
mathbfr(u,v)=(cosu,sinu,v)
Domain:uin[0,2pi], vin[−h,h]
Interpretation:u wraps around the cylinder, v goes up and down.
3. The Cone
mathbfr(u,v)=(vcosu,vsinu,v)
Domain:uin[0,2pi], vge0
Interpretation: The radius increases linearly with height.
4. The Torus
mathbfr(u,v)=((R+rcosv)cosu,(R+rcosv)sinu,rsinv)
Domain:u,vin[0,2pi]
Interpretation: A circle of radius r rotated around a circle of radius R.
5. Surface of Revolution
Rotating y=f(x) around the x-axis:
mathbfr(u,v)=(u,f(u)cosv,f(u)sinv)
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) give tangent vectors to the surface:
The normal vector is perpendicular to both tangent vectors:
mathbfn=mathbfrutimesmathbfrv
Why the Cross Product?
The vectors mathbfru and mathbfrv 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), the tangent plane consists of all points:
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,;zge0. The famous answer is 2piR2. We will reach it without using any shortcut formula — only A=iintD∣mathbfrutimesmathbfrv∣,du,dv.
Step 1. Pick a parameterization
Use spherical coordinates with u the azimuthal angle and v the angle from the north pole:
mathbfr(u,v)=(Rsinvcosu,;Rsinvsinu,;Rcosv)
For the upper hemisphere the parameter domain is D=[0,2pi]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 u first, treating v as a constant:
mathbfru=(−Rsinvsinu,;Rsinvcosu,;0)
Now differentiate with respect to v, treating u as a constant:
mathbfrv=(Rcosvcosu,;Rcosvsinu,;−Rsinv)
Sanity check. At the equator (v=pi/2): mathbfru points horizontally along the parallel, mathbfrv=(0,0,−R) points straight down — both tangent to the sphere, as expected.
Step 3. Take the cross product mathbfrutimesmathbfrv
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}
Notice the bracketed vector is exactly mathbfr(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∣
Square each component, sum, and take the square root:
The full sphere therefore has area 4piR2 (two hemispheres) — exactly the number on every geometry table. We never used a memorized formula; we built it from mathbfrutimesmathbfrv 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=1 into 2piR2: Aapprox6.283185ldots. The Python Riemann-sum demo further down converges to the same number — type R=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) is smooth (or regular) if:
mathbfru and mathbfrv exist and are continuous
mathbfrutimesmathbfrvneqmathbf0 at every point (the tangent vectors are never parallel)
When mathbfrutimesmathbfrv=mathbf0, the surface has a singularity - the normal is undefined and the tangent plane degenerates.
Examples of Singularities
Surface
Singularity
What Happens
Cone at apex
v=0
The tip is a point where all directions converge
Sphere at poles
v=0,pi
All longitude lines meet; direction undefined
Cusp on a surface
Point
Sharp 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 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:
The key is the u/2 term: as u goes from 0 to 2pi, 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)
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:mathbbR2tomathbbRn 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)
where mathbfn is the surface normal and mathbfL 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
Explanation(5)
Code(99)
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
45defparametric_surface_examples():6"""
7 Visualize classic parametric surfaces in 3D.
89 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))1314# 1. Sphere15 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)1920# 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)2425 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)')2728# 2. Torus29 ax2 = fig.add_subplot(2,3,2, projection='3d')30 R, r =2,0.5# Major and minor radii3132# Torus parameterization33 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)3637 ax2.plot_surface(X, Y, Z, cmap='plasma', alpha=0.8)38 ax2.set_title('Torus (R=2, r=0.5)')3940# 3. Paraboloid41 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)4546# Paraboloid: z = x² + y² in polar-like form47 X = V * np.cos(U)48 Y = V * np.sin(U)49 Z = V**25051 ax3.plot_surface(X, Y, Z, cmap='coolwarm', alpha=0.8)52 ax3.set_title('Paraboloid\nz = x² + y²')5354# 4. Helicoid55 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)5960# Helicoid parameterization61 X = V * np.cos(U)62 Y = V * np.sin(U)63 Z = U *0.36465 ax4.plot_surface(X, Y, Z, cmap='twilight', alpha=0.8)66 ax4.set_title('Helicoid\n(Minimal Surface)')6768# 5. Möbius Strip69 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)7374# Möbius strip parameterization75 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)7879 ax5.plot_surface(X, Y, Z, cmap='magma', alpha=0.9)80 ax5.set_title('Möbius Strip\n(Non-orientable)')8182# 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)8788# Simple rectangular parameterization89 X = U
90 Y = V
91 Z = U**2- V**29293 ax6.plot_surface(X, Y, Z, cmap='RdYlBu', alpha=0.8)94 ax6.set_title('Saddle\nz = x² - y²')9596 plt.tight_layout()97 plt.show()9899parametric_surface_examples()
Computing Tangent Planes and Normals
Tangent Plane Visualization
🐍tangent_plane.py
Explanation(4)
Code(102)
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
45defcompute_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.
910 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.
1213 Args:
14 surface_func: Function (u, v) -> (x, y, z)
15 u, v: Parameter values
16 h: Step size for numerical derivatives
1718 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 point25 point = np.array(surface_func(u, v))2627# Compute partial derivatives numerically28 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)3031# Normal = cross product of tangent vectors32 normal = np.cross(r_u, r_v)33 normal = normal / np.linalg.norm(normal)# Normalize3435return point, r_u, r_v, normal
3637defvisualize_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)43defsurface(u, v):44 x = u
45 y = v
46 z = np.sin(u)* np.cos(v)47return(x, y, z)4849# Create surface mesh50 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)5455# Choose a point to compute tangent plane56 u0, v0 =0.5,0.357 point, r_u, r_v, normal = compute_tangent_and_normal(surface, u0, v0)5859# Create tangent plane60 s = np.linspace(-0.5,0.5,10)61 t = np.linspace(-0.5,0.5,10)62 S, T = np.meshgrid(s, t)6364# Tangent plane: P = point + s*r_u + t*r_v65 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]6869# Visualize70 fig = plt.figure(figsize=(12,10))71 ax = fig.add_subplot(111, projection='3d')7273# Plot surface74 ax.plot_surface(X, Y, Z, cmap='Blues', alpha=0.6)7576# Plot tangent plane77 ax.plot_surface(X_plane, Y_plane, Z_plane, color='gold', alpha=0.7)7879# Plot tangent vectors80 scale =0.481 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')8788# Plot the point89 ax.scatter(*point, color='black', s=100, zorder=5)9091 ax.set_xlabel('X')92 ax.set_ylabel('Y')93 ax.set_zlabel('Z')94 ax.set_title('Tangent Plane and Normal Vector\n'+95f'at (u, v) = ({u0}, {v0})\n'+96f'n = r_u × r_v = ({normal[0]:.2f}, {normal[1]:.2f}, {normal[2]:.2f})')9798 plt.legend()99 plt.tight_layout()100 plt.show()101102visualize_tangent_plane()
Surface Area Calculation
Surface Area Approximation
🐍surface_area.py
Explanation(4)
Code(82)
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
45defsurface_area_approximation():6"""
7 Compute surface area using the formula:
89 A = ∬_D |r_u × r_v| dA
1011 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.
1415 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]19defsurface(u, v):20return(u, v, u**2+ v**2)2122defcompute_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)35return np.linalg.norm(cross)3637# Numerical integration using Riemann sum38defcompute_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
4647 total_area =048for i inrange(n_divisions):49for j inrange(n_divisions):50 u_mid =(u_vals[i]+ u_vals[i+1])/251 v_mid =(v_vals[j]+ v_vals[j+1])/252 area_element = compute_area_element(u_mid, v_mid)53 total_area += area_element * du * dv
5455return total_area
5657# Compare different resolutions58print("Surface Area Approximation for z = x² + y² over [-1,1]×[-1,1]")59print("-"*50)60print(f"{'n':>5}{'Area Estimate':>15}{'Rel. Change':>12}")61print("-"*50)6263 prev_area =064for n in[5,10,20,40,80,160]:65 area = compute_surface_area(n)66 change =abs(area - prev_area)/ area *100if prev_area >0else067print(f"{n:5d}{area:15.8f}{change:11.4f}%")68 prev_area = area
6970# Analytical result for comparison (computed via numerical integration)71# For z = x² + y², |r_u × r_v| = √(1 + 4x² + 4y²)72from scipy import integrate
73defintegrand(x, y):74return np.sqrt(1+4*x**2+4*y**2)7576 exact, _ = integrate.dblquad(integrand,-1,1,-1,1)77print("-"*50)78print(f"High-precision estimate: {exact:.8f}")7980return prev_area
8182area = surface_area_approximation()
Machine Learning Connections
Parametric Surfaces in ML
🐍surfaces_in_ml.py
Explanation(4)
Code(126)
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
45defneural_surface_representation():6"""
7 Demonstrate how parametric surfaces appear in ML:
89 1. **Latent Space Manifolds**: Data often lies on low-dimensional
10 surfaces embedded in high-dimensional space.
1112 2. **3D Reconstruction**: Neural networks learn to output
13 surface parameterizations for 3D object generation.
1415 3. **Neural Radiance Fields (NeRF)**: Learn surfaces implicitly
16 as level sets of density functions.
1718 4. **Mesh Deformation**: Learn mappings that deform template
19 surfaces to match target shapes.
20 """21 np.random.seed(42)2223# Example 1: Data on a 2D manifold in 3D24# (simulating a VAE latent space mapped to observations)25print("="*60)26print("Example: Latent Space Manifold")27print("="*60)2829# Latent codes (u, v) on a 2D grid30 n_samples =50031 u = np.random.uniform(0,2*np.pi, n_samples)32 v = np.random.uniform(0, np.pi, n_samples)3334# "Decoder" maps latent codes to 3D observations (a sphere + noise)35# This is analogous to a VAE decoder learning a manifold36 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)3940 fig = plt.figure(figsize=(14,5))4142# 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')4849# 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')5657# Plot 3: The "true" surface the data lives on58 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)')6768 plt.tight_layout()69 plt.show()7071# Example 2: Surface normal for lighting in neural rendering72print("\n"+"="*60)73print("Example: Surface Normals in Neural Rendering")74print("="*60)7576defcompute_shading(normal, light_dir):77"""
78 Lambertian shading: brightness = max(0, n · L)
7980 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)85return np.maximum(0, np.sum(normal * light_dir, axis=-1))8687# Create a surface and compute normals88 u = np.linspace(0,2*np.pi,100)89 v = np.linspace(0, np.pi,100)90 U, V = np.meshgrid(u, v)9192 X = np.cos(U)* np.sin(V)93 Y = np.sin(U)* np.sin(V)94 Z = np.cos(V)9596# Compute normals analytically for sphere97 normals = np.stack([X, Y, Z], axis=-1)98 normals = normals / np.linalg.norm(normals, axis=-1, keepdims=True)99100# Light from different directions101 fig, axes = plt.subplots(1,3, figsize=(14,5))102 light_dirs =[103 np.array([1,0,0]),# From right104 np.array([0,1,0]),# From top105 np.array([1,1,1]),# From corner106]107108for ax, light_dir inzip(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}')114115 plt.suptitle('Surface Shading from Normal Vectors\n(Key in Neural Rendering)')116 plt.tight_layout()117 plt.show()118119print("\nKey ML Applications of Parametric Surfaces:")120print("• VAE/GAN latent manifolds")121print("• 3D mesh generation and deformation")122print("• Neural Radiance Fields (NeRF)")123print("• Physics-informed neural networks (PINNs)")124print("• Geometric deep learning on surfaces")125126neural_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
Concept
Description
Parametric Surface
mathbfr(u,v)=(x(u,v),y(u,v),z(u,v)) maps a 2D domain to 3D
Tangent Vectors
mathbfru and mathbfrv are partial derivatives, tangent to parameter curves
Normal Vector
mathbfn=mathbfrutimesmathbfrv is perpendicular to the tangent plane
Surface Area
A=iint∣mathbfrutimesmathbfrv∣,dA integrates the area element
Smooth Surface
mathbfrutimesmathbfrvneqmathbf0 everywhere (no singularities)
Orientable
Has two sides; can define consistent normal direction
Key Takeaways
Two parameters(u,v) sweep out a 2D surface in 3D space, unlike one parameter for curves
Tangent vectorsmathbfru and mathbfrv span the tangent plane; their cross product gives the normal
Surface area is computed by integrating ∣mathbfrutimesmathbfrv∣, which measures stretching from parameter space
Smoothness requires mathbfrutimesmathbfrvneqmathbf0; singularities occur at points like cone apexes
Orientability determines whether a surface has two sides (sphere) or one (Mobius strip)
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.