blob: e3594f0e911130c5f2b5a50b4283d59acfb9dc4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
---
title: Java geometry kernel (2D)
date: 2022-07-31
layout: post
---
Written in 2026, backdated to 2022.
Firm decided to rewrite the building design system from C# to Java. Geometries
are small—mostly 2D. No frame budgets. Numerical parity with Rhino was
mandatory. Architects, 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.
Couldn't get straight skeletons working. Even Rhino mishandled
self-intersections Z and H-shaped floor plan offsets produced. Wrote a custom
solver that fixed invalid loops by backtracking.
Problem of finding the largest inscribed rectangle surprised me. No single
algorithm covered both convex and concave shapes. Brute-force grid search
yielded 12% more buildable area—but not the true optimum.
BSP library proved numerically incompatible with Rhino. Replaced BSP trees with
vector-based primitives and JBLAS instead. All tests passed.
|