Expand description
§Adaptive Precision Floating-Point Arithmetic and Fast Robust Predicates for Computational Geometry
This is a direct transcript of the source code and algorithms provided by Jonathan Richard Shewchuk (https://www.cs.cmu.edu/~quake/robust.html) See the paper and the source code for more information.
The module offers adaptive and precise calculations for orientation queries
– “on which side of a line (2d) or plane (3d) does a point lie?” – and in-circle / in-sphere queries
– “is a given point contained in the circumference of a triangle?”.
The “adaptive” nature will increase performance only if a simpler calculation
cannot be guaranteed to be accurate enough, yielding higher performance on
average.
The public API will accept both f32 and f64 input points for predicate checking, with input being converted to
f64 values for internal use.
This has no effect on precision, as the IEEE-754 standard (section 5.3)
guarantees that conversion from f32 to f64 must be exact.
§Features
no_std: Build without the Rust standard library
Structs§
Functions§
- incircle
- Returns a positive value if the coordinate
pdlies inside the circle passing throughpa,pb, andpc.
Returns a negative value if it lies outside the circle.
Returns0if the four points are cocircular.
Note: The pointspa,pb, andpcmust be in counterclockwise order, or the sign of the result will be reversed. - insphere
- Returns a positive value if the point
pelies inside the sphere passing throughpa,pb,pc, andpd.
Returns a negative value if it lies outside.
Returns0if the five points are cospherical.
NOTE: The pointspa,pb,pc, andpdmust be ordered so that they have a positive orientation. - orient2d
- Returns a positive value if the coordinates
pa,pb, andpcoccur in counterclockwise order (pclies to the left of the directed line defined by coordinatespaandpb).
Returns a negative value if they occur in clockwise order (pclies to the right of the directed linepa, pb).
Returns0if they are collinear. - orient3d
- Returns a positive value if the point
pdlies below the plane passing throughpa,pb, andpc(“below” is defined so thatpa,pb, andpcappear in counterclockwise order when viewed from above the plane).
Returns a negative value ifpdlies above the plane.
Returns0if they are coplanar.