Numbers & models

Geometry through Rust

Connect Python geometry work to native Rust operations.

Interactive study

Explore the example
From the example below.

Why I’m interested

Geometry becomes much easier to reason about when the calculation has a shape beside it. Raygeo adds another interesting boundary: a convenient Python interface backed by Rust operations. My work focuses on correct geometry and on moving NumPy data across that boundary without unnecessary copies.

Progress

My local branches contain zero-copy NumPy interface changes, a geometry correction, and a Rust/Python benchmark suite. The browser example calculates rectangle intersection and union directly in Rust. The next example connects a general polygon to Raygeo itself.

See the shared region

Move the second rectangle from overlap to edge contact and then separation. Follow the change in intersection and union area.

Choose an example

Two axis-aligned polygons

The dark region is the area both rectangles share. Their union adds the two areas and subtracts that overlap once. A shared edge contributes zero area.

Intersection area
4
Union area
17

Input

A: origin (1, 1), size (4, 3)
B: origin (3, 2), size (3, 3)

Two axis-aligned polygons

The dark region is the area both rectangles share. Their union adds the two areas and subtracts that overlap once. A shared edge contributes zero area.

Intersection area
0
Union area
21

Input

A: origin (1, 1), size (4, 3)
B: origin (5, 2), size (3, 3)

Two axis-aligned polygons

The dark region is the area both rectangles share. Their union adds the two areas and subtracts that overlap once. A shared edge contributes zero area.

Intersection area
0
Union area
21

Input

A: origin (1, 1), size (4, 3)
B: origin (7, 2), size (3, 3)

Rust calculates this independent example with axis-aligned rectangles. The next example connects a general polygon to Raygeo by Samuel Abels.

What comes next

Run a general polygon example through Raygeo and link each local contribution to its upstream review.

Implementation and credits

How do overlap, edge contact, and separation change the shared area?

An independent Rust calculation shows intersection and union for axis-aligned rectangles.

Compare overlapping rectangles, shared edges, and separated shapes.

Rust calculates rectangle intersection and union area for the browser example.

Samuel Abels authors Raygeo. My local work covers geometry corrections, interface performance, and benchmark infrastructure.

Back to the collection