Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mathematical Visualization: Surface Integrals of Scalar Fields

This project is an interactive 3D simulation designed to visualize the calculus of integrating scalar functions over curved 2D manifolds embedded in $\mathbb{R}^3$. The application is built using Rust, leveraging the Macroquad game engine for high-performance rendering and the egui framework for the dashboard controls.

image

Mathematical Formulation

1. Parametrization of 2D Manifolds

A curved surface $S \subset \mathbb{R}^3$ is defined mathematically by mapping a flat 2D parameter space domain $T \subset \mathbb{R}^2$ (with variables $s$ and $t$) to 3D space. This mapping is represented by the vector-valued position function:

$$\vec{r}(s, t) = \begin{pmatrix} x(s, t) \ y(s, t) \ z(s, t) \end{pmatrix}$$

2. Tangent Space and the Normal Vector

At any point on the surface, we can determine how the position changes with respect to the parameters $s$ and $t$. This is defined by the partial derivative tangent vectors:

$$\vec{t}_s = \frac{\partial \vec{r}}{\partial s}, \quad \vec{t}_t = \frac{\partial \vec{r}}{\partial t}$$

The cross product of these two tangent vectors yields the surface normal vector $\vec{n}(s, t)$, which is orthogonal to the local tangent plane:

$$\vec{n}(s, t) = \vec{t}_s \times \vec{t}_t$$

3. Local Area Distortion & Jacobian Scaling Factor

Because mapping a flat domain $T$ onto a curved surface $S$ stretches, compresses, and tilts space, the area of a differential patch $dS$ on the surface is not equal to the corresponding parameter area $ds,dt$ .

To correct for this geometric distortion, we calculate the magnitude of the normal vector, which represents the Jacobian area scale factor $J(s, t)$:

$$J(s, t) = |\vec{n}(s, t)| = \left| \frac{\partial \vec{r}}{\partial s} \times \frac{\partial \vec{r}}{\partial t} \right|$$

This scaling factor acts as a local multiplier: $dS = J(s, t) , ds , dt$.

4. Definition of the Surface Integral

Integrating a scalar field $f(x, y, z)$ over the surface $S$ accumulates the values of $f$ weighted by the actual physical area of each patch. Using the parametrization, the surface integral is defined as:

$$\iint_S f(x, y, z) , dS = \iint_T f\big(\vec{r}(s, t)\big) , \left| \frac{\partial \vec{r}}{\partial s} \times \frac{\partial \vec{r}}{\partial t} \right| , ds , dt$$


Simulation Features

  • Interactive 3D Engine: Drag with the left mouse button to orbit the camera, and use the scroll wheel to zoom. Includes reference coordinate axes.
  • Picture-in-Picture Parameter Grid: Displays the flat $(s, t)$ parameter region. Selecting a cell in this 2D grid highlights its corresponding 3D counterpart, connected by a dashed tracking projection line.
  • Dynamic Tangent & Normal Vectors: Renders the tangent vectors $\vec{t}_s$ (Red) and $\vec{t}_t$ (Blue), as well as the normal vector $\vec{n}$ (Violet) directly on the 3D surface.
  • Numerical Derivative Calculations: Computes partial derivatives dynamically using central differences ($\epsilon = 10^{-3}$), allowing seamless compatibility with any surface type.
  • Painter's Rendering Pipeline: Performs back-to-front depth sorting of all surface polygons to handle transparency and resolve overlay layering.
  • Step-by-Step Numerical Integration Scanner:
    • Automatically sweeps across the grid cell-by-cell.
    • Computes and displays the local scalar values, Jacobian factors, and accumulated area and integral totals in real time.

Visualized Geometries

  1. Paraboloid (Bowl): Stretching increases with distance from the origin.
  2. Hyperbolic Paraboloid (Saddle): Shows structural saddle points with symmetrical distortion patterns.
  3. Hemisphere (Dome): Illustrates classical spherical compression near the pole.
  4. Wavy Ripple: Shows complex local derivatives over periodic waves.
  5. Torus (Donut): Visualizes outer boundary stretching vs. inner boundary compression.

Visualized Scalar Fields

  • Area Density ($f = 1.0$): Integrating this field yields the exact geometric surface area.
  • Height Field ($f = z + 1.5$): Models properties that vary linearly with elevation.
  • Radial Field ($f = x^2 + y^2$): Models properties radiating from a central axis.
  • Moving Heat Source (Dynamic): A moving Gaussian thermal spot.
  • Spatio-Temporal Wave (Dynamic): Time-dependent waves propagating across the surface.

Build and Run

Ensure you have the Rust compiler and Cargo package manager installed:

  1. Clone or navigate to the repository directory.
  2. Execute the run command:
    cargo run --release

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages