Expand description
Robust geometric predicates for numerical stability.
This module provides numerically robust implementations of geometric predicates using Shewchuk’s adaptive precision floating-point arithmetic.
§Background
Standard floating-point arithmetic can produce incorrect results for geometric predicates when points are nearly collinear or cocircular. This module provides robust alternatives that guarantee correct results.
§References
- Shewchuk, J.R. (1997). “Adaptive Precision Floating-Point Arithmetic and Fast Robust Predicates for Computational Geometry”
- https://www.cs.cmu.edu/~quake/robust.html
§Example
use u_nesting_core::robust::{orient2d, Orientation};
// Check orientation of three points
let a = (0.0, 0.0);
let b = (1.0, 0.0);
let c = (0.5, 1.0);
match orient2d(a, b, c) {
Orientation::CounterClockwise => println!("Left turn"),
Orientation::Clockwise => println!("Right turn"),
Orientation::Collinear => println!("Straight"),
}Structs§
- Scaling
Config - Configuration for coordinate scaling.
Enums§
- Orientation
- Result of an orientation test.
Functions§
- is_
ccw_ robust - Checks if a polygon has counter-clockwise winding order.
- is_
convex_ robust - Checks if a polygon is convex using robust orientation tests.
- orient2d
- Determines the orientation of three 2D points.
- orient2d_
filtered - Fast orientation test with exact fallback.
- orient2d_
raw - Returns the raw orientation determinant value.
- point_
in_ triangle_ inclusive_ robust - Checks if a point lies inside or on the boundary of a triangle.
- point_
in_ triangle_ robust - Checks if a point lies strictly inside a triangle.
- signed_
area_ robust - Computes the signed area of a polygon using robust arithmetic.
- snap_
polygon_ to_ grid - Snaps an entire polygon to a grid.
- snap_
to_ grid - Snaps coordinates to a grid of the given resolution.