--- title: Geometry kernel for building design date: 2022-07-31 layout: post --- Written in 2026, backdated to 2022. Real estate firm decided to rewrite the building design system from C# to Java. Building geometries are small—mostly 2D. No frame budgets or low-latency constraints. Numerical parity with Rhino was mandatory. Architects and structural engineers supplied test cases and floating-point tolerances. Implemented polygon clipping with Sutherland–Hodgman. No drama. Fortune's algorithm was a missed opportunity. Implemented the beach line using a linear list instead of the balanced binary tree. Planned to return to this; never had the chance. Z and H-shaped floor plan offsets produced self-intersections that even Rhino mishandled. Could not get straight skeletons working under time pressure. Wrote a custom solver that fixed invalid loops by backtracking instead. Problem of finding the largest inscribed rectangle was surprisingly difficult. No single algorithm covered both convex and concave shapes. Brute-force grid search yielded 12% more buildable area—but not the true optimum. Java BSP library proved numerically incompatible with Rhino. Replaced BSP trees with vector-based primitives and JBLAS instead.