Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept other number types #4

Open
mourner opened this issue Sep 14, 2018 · 4 comments
Open

Accept other number types #4

mourner opened this issue Sep 14, 2018 · 4 comments
Labels
enhancement New feature or request

Comments

@mourner
Copy link
Owner

mourner commented Sep 14, 2018

Currently delaunator only works with f64. I need to learn how Rust generics and numeric traits work to enable using the library with other numeric types.

@mourner mourner added the enhancement New feature or request label Sep 14, 2018
@urschrei
Copy link

@mourner If you use the Point implementation from Geo-Types, it's generic over f32, f64, and various integer types via CoordinateType.

@mourner
Copy link
Owner Author

mourner commented Sep 17, 2018

@urschrei thanks and great work on the geo/geo-types crates — seen that! The difficulty for this task is not only about making point types generic, but also making sure the geometric operations all work without loosing precision / going out of bounds etc.

@Stoeoef
Copy link

Stoeoef commented Apr 22, 2019

Maybe I can share some of my experiences when developing Spade.

Support for f32

When investigating different number types for Spade, I started to riddle my code with debug_assert! calls that would check various preconditions, e.g. "Is the given point really on the right side of this edge?". Maybe that is applicable for you as well to detect precision loss as early as possible? Also, lots of randomized tests helped. These tests would usually triangulate some random points and, if no panic occurred during triangulation, perform a sanity check on the triangulation structure. This check would ensure that important invariants (e.g. are the points of triangles always sorted ccw?) or structural requirements (Has every half edge a twin?) are met.

I have had bad experiences with f32 and precision for spade, up to the point that I stopped using it even for very small point sets. However, delaunator seems to be more robust for f64, maybe this robustness is also true for f32.

One last note: I have not had any problems with overflowing f32 or f64 values, their range seems to be large enough for any realistic input set.

Support for integer types

If you decide to support integer coordinates, integer overflow is checked in debug configuration. Also, I noted some divisions ( / ) in your code, those may not work as intended for integer coordinates.

Support for custom number types (BigIntegers, arbitrary precision floats)

When I ran into precision problems back then, my first attempt to fix this was to use arbitrary precision floating point numbers. Besides being terribly slow, they are also very cumbersome to handle as there is no Copy bound on the number type.

@oovm
Copy link
Contributor

oovm commented Apr 17, 2023

Seems that robust does not support F: Float and arbitrary precision, it only supports f64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants