-
Notifications
You must be signed in to change notification settings - Fork 0
BCRS
BCRS (Boundary-Coordinate Raster Solve) is an algorithm family in LIRiAP that combines containment certification with explicit boundary expansion (CABF). CABF (Coordinate-Ascent Boundary Fitting) was the earlier implementation approach for the "largest-area, non-axis-aligned, fully contained rectangle with expansion" target.
Note: CABF is now a historical earlier implementation. The Skeleton family provides a BCRS-free alternative using medial-axis skeleton decomposition for seed generation.
| Variant | Description | Best For |
|---|---|---|
| Standard | Full BCRS workflow with all optimization stages | Maximum accuracy |
| Fast | Trial ranking + limited expensive runs | Faster with minimal accuracy loss |
flowchart TD
A[Stage 1: Geometry preparation] --> B[Stage 2: Heuristic candidates]
B --> C[Stage 3: Angle refinement]
C --> D[Stage 4: BCRS boundary-coordinate solve]
D --> E[Stage 5: CABF expansion]
E --> F[Stage 6: Containment certification]
F --> G{Strict certification passes?}
G -- Yes --> H[Stage 7: Select best + output]
G -- No --> I{Fallback enabled?}
I -- Yes --> J[Best-effort fallback]
I -- No --> K[No rectangle]
J --> H
Traditional grid-based LIR solvers use uniform grid spacing. BCRS instead uses the polygon vertex coordinates themselves as grid lines. This is a key innovation because:
- The optimal rectangle's sides are naturally aligned with polygon edges
- At vertex coordinates, we have exact boundary positions
- No precision loss from approximating the boundary
Traditional Grid: BCRS Grid:
+------------------+ +----A----C----+
| | | | |
| (uniform) | | B---|---D |
| | | | |
+------------------+ +----E----F----+
(A,C,E,F are polygon vertices that become grid lines)
Instead of fixed-width histogram bins, BCRS adapts bin widths based on the spacing of boundary coordinates. This means:
- More resolution in complex polygon regions
- Less wasted computation in simple regions
- Exact results at vertex precision
After the initial BCRS solve, Coordinate-Ascent Boundary Fitting expands each side:
- For each rectangle side, compute the allowable expansion range
- Use binary search to find the maximum expansion
- Clamp to nearest vertex coordinate (not interpolate)
Clamping is critical—it prevents floating-point errors from pushing the rectangle outside containment.
- Validate geometry, normalize multipolygons
- Optional precision snapping
- Edge-orientation histogram generates candidate angles
- Convex-hull upper bound prunes weak candidates
- Coarse grid search keeps top-K candidates
- Brent optimization refines each candidate angle
- Finds local maximum near initial guess
- Rotate polygon to test angle
- Build boundary-coordinate grid from vertices
- Run variable-pitch LRH solver
- Coordinate-ascent binary search on each side
- Clamp to nearest boundary coordinate
- Iterate until convergence
- Verify full containment
- Controlled shrink if needed
- Best-effort fallback
- Return best certified rectangle
- Include diagnostic fields
BCRS is the only algorithm that combines:
- Containment certification - proven inside polygon
- Boundary expansion - rectangle touches polygon edges
This is the full target formulation for maximum-area inscribed rectangles.
See Parameters for full reference.
| Parameter | Purpose |
|---|---|
| GRID_COARSE | Initial grid resolution |
| GRID_FINE | Refinement grid resolution |
| TOP_K | Candidates for refinement |
| MAX_RATIO | Aspect ratio constraint |
| ALWAYS_RETURN | Allow fallback on failure |
| Variant | TOP_K | Time @290 | Time @5406 | Notes |
|---|---|---|---|---|
| Standard | 3 | 42.35s | TBD | Full BCRS workflow |
| Fast | 3 | 23.61s | 445.01s | Trial ranking, ~2x faster |
Best mode: Single worker (1w) — parallelization overhead exceeds per-feature computation time.
-
area: Rectangle area in CRS map units -
angle_deg: Rotation angle in degrees -
ratio: Aspect ratio (long:short) -
cand_rank: Rank of selected candidate -
s2_gain: Area gain from Stage 2 (angle polishing) -
s4_gain: Area gain from Stage 4 (BCRS solve) -
s5_gain: Area gain from Stage 5 (CABF expansion) -
best_effort: 1 if fallback used
- Daniels et al. (1997): Finding the largest axis-aligned rectangle in a polygon. Proc. 13th CCCG. — Core theorem for vertex-coordinate solving.
- Bentley, J.L. (1977): Programming Pearls: Fast Algorithms for Polygon Containment. — Foundational polygon algorithms.
- Preparata, F.P. & Shamos, M.I. (1985): Computational Geometry: An Introduction. Springer. — Standard reference.
Navigation
- Home | Installation | Algorithms | Approximation | Skeleton | Axis-Aligned | Performance | Complexity | Foundations | Parameters | Folder Layout | Usage