Crates.io | geogram_predicates |
lib.rs | geogram_predicates |
version | 0.2.1 |
source | src |
created_at | 2024-04-13 13:03:09.586894 |
updated_at | 2024-07-19 11:24:19.251248 |
description | Rust bindings to the Geogram library's predicates module |
homepage | |
repository | https://github.com/glennDittmann/geogram_predicates |
max_upload_size | |
id | 1207577 |
size | 483,614 |
A crate for rust interoperability with geogram
s robust predicates; via cxx
.
Geogram is a scientifically proven, well-documented, feature-rich geometry processing library, which leverages "[...] arithmetic filters (Meyer and Pion), expansion arithmetics (Shewchuk) and simulation of simplicity (Edelsbrunner)."
Be sure to check it out here.
It yields easy access to dependecy-free parts of its code base, as so called Pluggable Software Modules (PSM), which in turn make it easy to write cxx_bridges
for these.
With that, you can add geometry predicates to your rust project, without the need to re-implement existing state-of-the-art software.
E.g. using geograms incircle predicate for triangles in rust
looks like this:
use geogram_predicates as gp
// Define three points that form a triangle
let a = [0.0, 0.0];
let b = [2.0, 0.0];
let c = [1.0, 1.0];
// Define two points, to test against the triangles circum-circle
let p_in = [1.0, -0.4];
let p_out = [1.0, -1.2];
let is_in_circle_p_in = gp::in_circle_2d_SOS(&a, &b, &c, &p_in);
assert_eq!(1, is_in_circle_p_in);
let is_in_circle_p_out = gp::in_circle_2d_SOS(&a, &b, &c, &p_out);
assert_eq!(-1, is_in_circle_p_out);
// Do something fancy based on the result
// ...
Below are visualizations comparing naive and robust orient_2d
& in_circle_2d
implementations. You can generate these images yourself by running the examples for orient_2d
or in_circle_2d
.
Naive | Robust | |
---|---|---|
orient_2d |
||
in_circle_2d |
in_circle_2D_SOS()
orient_2d()
orient_2dlifted_SOS()
points_are_identical_2d()
There are a lot of predictes still to be implemented. If you are in need for a specific one have a look at the geograms predicate list. The bridge for any one predicate is implemented pretty quickly, so this crate is easily extendable.
The API to the geogram predicates
is designed with the following design principles in mind:
If you see something as
feel free to open a PR to address this.
Credits go to geogram and cxx, which make this project possible.
Also georust/robust should be mentioned, for helping set up the examples and their visualizations.
The files in include/geogram_predicates_psm
are licensed w.r.t.
Copyright (c) 2000-2022 Inria All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the ALICE Project-Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The rest of this software is licensed under Apache License, Version 2.0 (similar to cxx's license).