Gaudí's geometry in code: the Sagrada Família without booleans
An airport in Chronotopia is mostly extruded outlines: a terminal is an OpenStreetMap polygon pushed up to its height, with a roof and some windows. The Sagrada Família can’t be built that way. Its towers narrow along a curve, its windows are holes shaped like hourglasses, and its columns branch and twist. The next site in Chronotopia is the Sagrada Família, and most of the work so far has gone into a small geometry library, src/gaudi/, that builds those shapes from the surfaces Gaudí designed them with.
The site has been open in the app since 5 October 2026. This article describes the code as it was on the repository’s main branch at commit a73a57f, two days before it opened: what is built, how, and how much of it is our estimate. The model has grown a lot since, but the geometry library at its core works the same way.
One function for every surface
Gaudí’s late work uses a short list of surfaces: hyperboloids, hyperbolic paraboloids, helicoids, conoids, paraboloids. Most are ruled surfaces, made of straight lines, which is how they could be built in stone. They are also easy to write as a function of two parameters, which is what a computer needs.
So the library has one primitive. MeshBuilder.grid samples any parametric surface at(u, v) on a grid of u and v between 0 and 1 and joins the samples into quads. From src/gaudi/mesh.ts:
/**
* A surface sampled on an (nu + 1) × (nv + 1) grid of parameters u, v ∈ [0, 1]. With `closedU`
* the last column wraps onto the first (a surface of revolution). Quads where `hole(i, j)` are
* left out. The front face is the side where (∂p/∂u × ∂p/∂v) points, or the other with `flip`.
*/
grid(
nu: number,
nv: number,
at: (u: number, v: number, out: THREE.Vector3) => void,
opts: { closedU?: boolean; flip?: boolean; hole?: (i: number, j: number) => boolean; uv?: (u: number, v: number, p: THREE.Vector3) => [number, number] } = {},
)
The hole option is the important one. A modelling tool would cut a window out of a wall with a boolean subtraction, CSG, which is slow, fragile on curved surfaces and hard to get clean edges from. Here the openings are known in advance, so the wall is generated with those quads missing and the window’s own surface is generated to meet the gap. The research plan’s conclusion after the first prototype was that no booleans would be needed anywhere, and so far none have been.
A tower is a paraboloid
The Apostle towers, the twelve that will stand in threes on the three façades, are tall shafts that narrow towards the top along a parabola, then end in a mosaic pinnacle. In the model the shaft’s radius at height y follows a paraboloid of revolution with a virtual apex above the tower. From src/gaudi/tower.ts:
/** Virtual apex of the paraboloid the shaft follows: r(y) = radius √((apex − y) / (apex − free)). */
export function towerRadius(t: TowerSpec, y: number) {
const yy = Math.max(y, t.free);
return t.radius * Math.sqrt(Math.max(0, (t.apex - yy) / (t.apex - t.free)));
}
free is the height where the shaft comes away from the façade, and radius is its radius there. Everything else in the tower is laid out on that curve, in zones from the bottom up: tall round-headed slots, a solid band, the bell chamber of vertical ribs with stacked louvres between them, and the pinnacle.
There are two presets, one per façade type, in src/gaudi/temple.ts:
| Preset | Height | Radius at free | free | Apex | Ribs | Pinnacle from |
|---|---|---|---|---|---|---|
| Passion | 112.1 m | 4.2 m | 36 m | 111 m | 14 | 84.1 m |
| Nativity | 107.25 m | 4.2 m | 33 m | 104 m | 12 | 83 m |
The Passion figures come from published sources. The 112.1 m central height and the 28 m pinnacle, an 8 m drum and a 20 m top, are from Josep Gómez Ramió’s doctoral thesis at the UPC; 112.1 − 28 gives the 84.1 m where the pinnacle starts. The 14 ribs are in the Basilica’s own booklets. The Nativity towers have no such figures that we could find, so their preset was read off a single photograph from about 1935, scaled by the 107.25 m height of the inner towers. The comment on the preset records the readings: a radius of about 4.2 m at 33 m, 3.6 at 52 and 2.65 at 76, which a parabola fits with its apex at about 104 m.
The outer towers of each façade are lower: 101.9 m at the Passion and 98.25 m at the Nativity. scaleTower() rescales everything above free to the new height, so the same preset serves all four. Which outer height to use for the Passion towers was not obvious, because sources give either 101.9 or about 107 m. That was settled by comparing the model with photographs, which is the subject of the next article in this line.
A window is a hyperboloid
Gaudí’s windows in the nave walls are hyperboloids of one sheet: an elliptical opening on the wall’s face that narrows into the wall’s thickness to a throat, where the glass sits, like the waist of an hourglass. A hyperboloid of one sheet is a ruled surface, so the stonemasons could cut it with straight edges.
The function takes the opening’s centre and semi-axes on the wall, the wall’s depth, and k, the size of the throat as a fraction of the opening. From src/gaudi/parts.ts:
export function hyperWindow(p: Parts, m: THREE.Matrix4, cx: number, cy: number, rx: number, ry: number, depth: number, k = 0.55) {
// r(z) = r0·√(1 + ((z − depth)/c)²), r(0) = 1 (in units of the opening), r(depth) = k.
const c = depth / Math.sqrt(1 / (k * k) - 1);
const s = (z: number) => k * Math.sqrt(1 + ((z - depth) / c) ** 2);
const per = Math.PI * (rx + ry);
p.stone.grid(32, 4, (u, v, o) => {
const a = u * Math.PI * 2, z = v * depth, f = s(z);
o.set(cx + rx * f * Math.cos(a), cy + ry * f * Math.sin(a), z).applyMatrix4(m);
}, { closedU: true, uv: (u, v) => [u * per, v * depth] });
// … and a flat disc of glass at the throat.
}
Shortened from src/gaudi/parts.ts: the glass disc is left out. The constant c comes from asking the curve to pass through the opening’s edge at the wall face: setting s(0) = 1 gives k² (1 + depth²/c²) = 1, so c = depth / √(1/k² − 1). With the default k = 0.55, the glass is a little over half the size of the opening. The walls of the nave, transept and apse in src/gaudi/body.ts use it for every window, from small round ones under the roof to the large ellipses of the aisles.
A column twists both ways
The columns inside the Sagrada Família follow a rule Gaudí wrote down, and the Basilica publishes it: a column with an n-pointed star as its section has a base n decimetres high, then three stretches n, n/2 and n/4 metres high, with a knot whose centre is at 2n metres. In each stretch, two copies of the star turn in opposite directions, and the column’s section is their intersection. Where the two copies cross, sharp ridges appear, and the number of edges doubles at each stretch. The four sizes, with their diameters and stones, are in src/gaudi/column.ts:
export const GAUDI_COLUMNS = {
12: { d: 2.1, stone: 'porphyry', sides: 4, count: 3 },
10: { d: 1.75, stone: 'basalt', sides: 5, count: 2 },
8: { d: 1.4, stone: 'granite', sides: 4, count: 2 },
6: { d: 1.05, stone: 'sandstone', sides: 3, count: 2 },
} as const;
The base stars are unions of turned polygons: three squares give the 12 points, two pentagons 10, two squares 8 and two triangles 6. The section is stored as a radius for each of 4,096 angles, and the double twist is a minimum of two lookups. The heart of doubleTwistColumn:
b.grid(nu, nv, (u, v, out) => {
const phi = u * TAU;
const y = yBase + v * h;
const th = thetaTop * v;
const sc = 1 + (taper - 1) * (y / total);
const r = sc * Math.min(sec.at(phi - th), sec.at(phi + th));
out.set(Math.cos(phi) * r, y, -Math.sin(phi) * r);
}, { closedU: true, uv: (u, v) => [u * spec.radius * TAU, (yBase + v * h)] });
At height v through a stretch, one copy has turned by +th and the other by −th; Math.min of the two radii is their intersection. At the top of the stretch the turn is π / 2n, and the section there, already doubled in edges, becomes the starting section of the next.
The columns, tree-like branches and the hyperboloid “suns” of the vaults exist in code but are only used on a development workbench page. The site itself is exterior only, for now: the interior has no published dimensions for the vaults, and the workbench’s vault parameters are invented.
Growing a building course by course
An airport building in the model rises out of the ground in the year before it opens. A temple that took 140 years can’t: the Nativity façade’s towers took decades and were finished one by one. So each element of the temple has works, a start and end year, and while the works last the element is cut at a height that climbs in steps of 1.2 m, a construction course. From src/modules/monument.ts:
const apply = (year: number) => {
for (const { b, plane } of fronts) {
const { works, demolished } = b.el;
let visible = !(demolished !== undefined && year >= demolished);
let h = 1e6;
if (works) {
const [w0, w1] = works;
if (year < w0) visible = false;
else if (year < w1) {
const p = (year - w0) / Math.max(1e-3, w1 - w0);
h = b.base + Math.max(COURSE, Math.floor(((b.top - b.base) * p) / COURSE) * COURSE);
}
}
b.group.visible = visible;
plane.constant = h;
}
};
The cut is a clipping plane, one per element, on cloned materials, with clipped shadows, so nothing is rebuilt when the year changes. With St Barnabas’s works set to 1899-1925, the tower reaches about 54 m in 1912 and is the only finished tower in 1925, which is what the sources say: it was completed on 30 November 1925 and the other three in 1930. A course-by-course rise is a simplification, since real towers grow unevenly and sit inside scaffolding, but it gives the right silhouette for the right decade.
All of this lives in a site module. Airports and monuments now share the same core, the terrain, camera, timeline and interface, and each kind adds its own layer through a small interface in src/modules/module.ts. The airport module brings the aircraft and runway lights; the monument module brings the temple. The airports render as before: a comparison of frames before and after the split differed in 0.03% of pixels, from aircraft in motion.
What isn’t Gaudí yet
- Only part of the temple exists. The model has the apse, the nave and transept, the four Passion towers, the four Nativity towers with their portals and cypress, and the bridges between towers. The six central towers, including the 172.5 m Tower of Jesus Christ, the Passion portico, the sacristies, the Glory façade and the streets around are not built yet.
- Two “hyperbolic paraboloids” are approximations. The roof pyramids are a bilinear patch with a bow added towards the centre, and the vault “saddles” are a smooth bump. Both look right from a distance; neither is the exact surface.
- Many dimensions are ours. Every Nativity dimension is read off one photograph of about 1935. The apex of the nave’s roof pyramids, 64 m, the heights of the gables and the radius of the apse chapels are estimates. The research notes mark each as “L”, for “read”, against “H” for published.
- Detail is simplified. The sculptures are low-polygon masses, the “Sanctus” and “Hosanna” inscriptions are missing, and the Nativity pinnacles are scaled copies of the Passion ones.
- No helicoids or conoids yet. The spiral stairs inside the towers and the conoid roof of the Sagrada Família Schools are in the research, not in the code.
- Phones are untested. A full Passion tower is about 78,000 triangles, and on a desktop the four towers with the workbench’s nave run at about 63-66 frames per second. We haven’t measured a phone.
The library is about 2,400 lines, and each new element has meant one new function on top of grid. The question that decides how far it goes is not whether a shape can be written as a surface, but whether its dimensions have been published.