Open Source Projects

This first section lists the main larger programs on which I have worked, all built for the purpose of mathematical illustration. These projects are a combination of Javascript (primarily THREE.JS) and custom GLSL shaders, which perform the required calculations in parallel on the GPU.

Physically Based Path Tracer

A path tracing program produces images by shooting light rays into a virtual scene, computing their reflections, refractions and other physical interactions, and iterating. The eventual image is the sum of many such simulations, which converges to a solution to the rendering equation via monte-carlo integration. This path tracer attempts to be as physically accurate as possible, and is designed to produce images of mathematical objects.

Physically Based Ray-Marcher

Like the above, this program produces images by simulating light rays and their interaction with a virtual scene. Instead of slowly converging to a final image via monte carlo integration, here we attempt to approximate various integrals in the rendering equation in an efficient manner, which allows approximately realistic images to be rendered at real time rates.

Illustrating Functions on Parametric Surfaces

This program sets up a framework for being able to quickly (for real time animations) compute the mesh of a parametric surface, and color that surface by an arbitrary real valued function defined on it. This is built inside of THREE.JS starting from the CustomShaderMaterial designed by NAME, and reworked for this specific application.

Displaying the Results of Numerical Simulations

This program sets up a framework for doing GPU computation inside of THREE.JS. A makeshift version of compute shaders are constructed using CustomShaderMaterial for doing the numerics, and a second layer of shader programs then take the output of this computation and produce a visualization, using the setup of the parametric surface grapher described immediately above. This allows one for instance, to run real-time simulations of numerical PDEs, or other computationally heavy tasks.

Running Shadertoy Code in THREE.JS

This small program provides a means to copy a simple shader program written on into a javascript program, which can then be run locally on your computer or posted to a website. This was designed for teaching purposes, where students may write code to produce an image but wish to abstract away all of the other details of how to get that image actually rendered to the screen.

GLSL Shaders

Shaders compute images pixel by pixel, in parallel on the GPU. I was introduced to this style of programming for the purpose of raytracing in Riemannian 3-manifolds; for this collection of work see our page, and since have used it frequently in the projects above. The programs below are simpler stand-alone examples showing a couple of techniques for 3D graphics I find useful: mostly various use cases of raytracing, and volumetric rendering. All examples run live in the browser if you click "play" on the picture, and the source code is available (and editable!) via

Volumetric Raytracing

This shader illustrates a real valued function on the tangent space to various geometries, computing the distortion of the volume measure under the exponential map. The picture is rendered via volumetric rayrtracing, where the color of each pixel is determined by shooting a ray out into the scene and integrating the function over its length.

Volumetric Raytracing 2: Hydrogen Orbitals

A more involved example featuring the same techique of volumertric raytracing from above, applied to visualizing a probability distribution in $\mathbb{R}^3$: an atomic orbital.

Raytracing in Nil Geometry

Raytracing the $xy$ plane in $\mathbb{R}^3$ with the Nil metric. This code gives a simple example of tracing where the geodesics are explicitly known, but the distance to objects are not.

Raytracing the Schwarzschild Metric

This example raytraces the lightlike geodesics of the Schwarzschild metric around a black hole in front of a checkerboard wall. (Because this solution is static, the geodesic equations can be calculated via numerically solving a system of ODEs on $\mathbb{R}^3$, projecting off the time direction). This provides a simple example of raytracing where the explicit geodesics are not known.

Hyperbolic Reflection Groups

This example produces shows the basic technique of computing a tiling with a given reflection group as its symmetries. Each point in the hyperbolic plane is iteratively reflected until it lands in a chosen fundamental domain, and its eventual color then determined by its final position, and the number of reflections required.

Computing Hyperbolic Structures on the Genus 2 Surface

This example produces geometric structures on the genus 2 surface by reflecting in the sides of a right angled hexagon (this reflection group has the surface group of interest as an index 4 subgroup). Like the above, the code shows how to implement such hyperbolic reflections, but also how to single out an original choice of fundamental domain.

Computing Real Projective Structures

This example produces convex real projective structures on a triangle orbifold via the same reflection technique employed in the previous two programs, except circle inversions are replaced with affine reflections in RP2.

A Basic Pathtracer

A bare-bones path tracer illustrating the technique of shooting rays into a scene, reflecting off surfaces following a specified probability distribution, and accumulating the results to produce an image via monte-carlo integration.


During my time in graduate school, I learned to make mathematical illustrations in Mathematica mostly by trial, error, and incremental improvement. Here is a selection of programs I wrote showcasing different features (tweaking surface properties so things look nice, setting up animation timing, computing group elements from generating sets, etc) that others may find useful. Every notebook has (unexecuted) examples spread throughout: execute all commands sequentially when reading through, and test images will appear.

Cubic Surfaces: ContourPlot3D

Mathematica programs written to draw the real lines on a cubic surface, and more generally algebraic hypersurfaces of $\mathbb{P}^3$. Code originally developed to help Stephen McKean, Daniel Minahan, Tianyi Zhang illustrate the paper This file illustrates a bunch of useful options for ContourPlot3D to make graphics look more professional.

Elliptic Fibrations: Rendering Videos

This program shares a beginning with the above (all images are based on ContourPlot3D) - but is included for anyone who wants an example of creating a video in mathematica. It has sections for moving the camera, makign smooth animation timing functions, updating the frame, rendering in parallel, and outputting a sequence of frames to a folder.

Fibrations of S3: Parametric Curves & Tubes

The Hopf and Seifert fibrations of $\mathbb{S}^3$ fill the sphere with linked circles and torus knots. This program visualizes these through stereographic projection. Some useful tricks are drawing tubes around curves (without parameterizing the tube as a surface), and controlling the width of these tubes.

Flat Tori in the 3-Sphere: Parametric Surfaces

This program takes as input a curve on $\mathbb{S}^2$ and draws the surface in $\mathbb{S}^3$ which is its preimage under the Hopf map. This generalizes easily to drawing surfaces in ruled by the fibers of the Seifert fibrations as well, and is useful in constructing flat tori. This program illustrates the ParametricPlot3D commands needed to make nice looking graphics.


In four dimensions, there are six regular polytopes: five higher-dimensional analogs of the platonic solids, and the 24 cell. Interpreted as regular tilings of the three-sphere, this program allows the visualization of these through both stereographic and perspective projection into $\mathbb{R}^3$.

Klein Model of $\mathbb{H}^2$: Graphics[]

The hyperboloid of two sheets, realized as the sphere of radius -1 in Minkowski space, inherits a metric of constant curvature -1. This program utilizes this to draw hyperbolic tilings in the Klein model, the projectivization of the hyperboloid onto an affine patch in $\mathbb{R}\mathsf{P}^2$. This program illustrates techniques for making 2D graphics in mathematica using the Graphics[] commands, as well as some computational stuff (how to compute many elements of a group given its generators, for instance).

Poincare Model of $\mathbb{H}^2$: Graphics[]

The Poincare disk is a model of hyperbolic geometry built within the complex projective space $\mathbb{C}\mathsf{P}^1$. This program draws hyperbolic tilings in the Poincare disk, computing geodesics from their endpoints on the boundary by finding the unique orthogonal circle. This illustrates many of the same techniques as the previous program, but is more complex due to the semicircular nature of Poincare disk geodesics.

Convex Real Projective Triangle Groups

Tilings of $\mathbb{H}^2$ by triangles are rigid, but deform nontrivially into real projective geometry. This program animates the 1-parameter family of deformations of the $(p,q,r)$ reflection group, following Anton Lukyanenko's master's thesis, available here. This again illustrates working with Graphics[], in a setting maybe not as familiar as hyperbolic geometry.

Complex Function Plots

The graph of a complex function is a subset of $\mathbb{C}^2$, and so it is often easier to think about these objects via domain coloring, or coloring a point $z\in\mathbb{C}$ using its image data $f(z)$. This program takes as input arbitrarly complex functions and draws the associated domain coloring of a pre-specified region in $\mathbb{C}$.

Boundary Slopes Knot Complements

This program takes a paramreterized knot in $\mathbb{R}^3$ and does the curves-and-surfaces differential geometry to parameterize a normal tube about it, for the purpose of drawing boundary slopes $p\mathsf{meridian}+q\mathsf{longitude}$. This parameterization is then placed in the 3-sphere via inverse stereographic projection and rotated, to embed the knot complement in $\mathbb{R}^3$.