Skip to main content

Module snap_rounding

Module snap_rounding 

Source
Expand description

Hobby snap rounding for robust geometric operations.

Snap rounding is a technique to achieve robustness in computational geometry by snapping all coordinates (and intersection points) to a regular grid. This eliminates floating-point inconsistencies and ensures topological validity of noded segment arrangements.

§Algorithm

The iterative Hobby snap rounding algorithm proceeds as:

  1. Snap all input coordinates to the precision grid.
  2. Collect all pairwise segment-segment intersections (cross-line).
  3. Snap each intersection to the grid.
  4. Split every segment that an intersection point lies on.
  5. Repeat steps 2-4 until convergence or max_iterations is reached.
  6. Remove zero-length segments.

§References

  • J. Hobby, “Practical segment intersection with finite precision output”, Computational Geometry, 13(4):199-214, 1999.

Structs§

SnapRoundingOptions
Options controlling snap rounding behaviour.
SnapRoundingResult
Result returned by snap_round.
SnappedSegment
A single output segment after snap rounding.

Functions§

snap_coordinate
Snap a single coordinate to the precision grid.
snap_linestring
Snap all coordinates in a slice to the precision grid, removing consecutive duplicates that arise after snapping.
snap_round
Perform iterative Hobby snap rounding on a collection of polylines.