Computational Geometry library written in Rust

Overview

RGeometry

Computational Geometry in Rust!

Crates.io API API codecov GitHub branch checks state dependency status Discord


What is RGeometry?

RGeometry is a collection of data types such as points, polygons, lines, and segments, and a variety of algorithms for manipulating them. This crate will be of use to you if you've ever wondered if a point is inside a polygon or if a bank is adequately covered by surveillance cameras.

Check out the API documentation for more details. Under each function, there is an interactive example (powered by rust->wasm).

Contribute

If you want to learn Rust or computational geometry or both, hit me up in discord and I'll (@lemmih) mentor you. There is a long list of algorithms (ranging from easy to difficult) yet to be implemented in Rust.

Resources:

Comments
  • Monotone polygon

    Monotone polygon

    Functionality Todo List:

    • [x] Add a function that checks whether entered points form a y-monotone polygon, return the paths if true
    • [x] Add a function that takes number of points and arrange them into a y-monotone polygon
    • [x] Make monotone generation generic for any axis or direction

    Before Merging Todo List:

    • [x] clean up code (extract large functions)
    • [x] Add proper documentation to the functions
    • [ ] Make sure all functionalities are covered by test cases
    opened by obayomy 4
  • Use of `claim` crate causes dependency conflicts

    Use of `claim` crate causes dependency conflicts

    See https://github.com/svartalf/rust-claim/issues/9

    This makes it impossible to use rgeometry together with nix, for example, which I want to do.

    A possible workaround for users is to patch the (seemingly unmaintained) dependency like this:

    [patch.crates-io]
    claim = { git = "https://github.com/Turbo87/rust-claim.git", rev = "23892a3" }
    
    opened by SludgePhD 2
  • Detect instability for floats and automatically switch to precise numbers.

    Detect instability for floats and automatically switch to precise numbers.

    CGAL has a kernel called Exact_predicates_inexact_constructions_kernel. This kernel uses f64 under the hood but switches to exact numbers when using f64 directly would give inaccurate results. This is slower than naively using f64 but guarantees correctness. RGeometry should do this by default and expose a separate type (maybe UnstableF64) for use when performance is more important than correctness.

    Note, fixed-precision numbers from the fixed crate are still to be preferred.

    This would force a dependency on num-rational.

    opened by lemmih 2
  • fix get_visibility_polygon with Point<f64>

    fix get_visibility_polygon with Point

    get_visibility_polygon sometimes crashes with Point<f64> due to floating point error. With Point<f64>, return value from get_intersaction might be a little closer or further than original vertex when intersection result is Crossing, which results in invalid polygon_points and crash.

    opened by yjh0502 1
  • Delaunay triangulation & constrained Delaunay triangulation

    Delaunay triangulation & constrained Delaunay triangulation

    references

    • DT: https://www.personal.psu.edu/cxc11/AERSP560/DELAUNEY/13_Two_algorithms_Delauney.pdf
    • CDT: https://people.eecs.berkeley.edu/~jrs/papers/inccdtj.pdf
    opened by yjh0502 1
  • $50 Bounty: Boolean Operations

    $50 Bounty: Boolean Operations

    Introduction

    Boolean operations on polygons are a set of Boolean operations (AND, OR, NOT, XOR, ...) operating on one or more sets of polygons in computer graphics. These sets of operations are widely used in computer graphics, CAD, and in EDA (in integrated circuit physical design and verification software).

    Paper abstract:

    In this paper a simple and efficient algorithm for computing Boolean operations on polygons is presented. The algorithm works with almost any kind of input polygons: concave polygons, polygons with holes, several contours and self-intersecting edges. Important topological information, as the holes of the result polygon, is computed.

    Paper: https://www.sciencedirect.com/science/article/abs/pii/S0965997813000379?via%3Dihub Paper: https://www.inf.usi.ch/hormann/papers/Foster.2019.CSP.pdf Wikipedia: https://en.wikipedia.org/wiki/Boolean_operations_on_polygons

    The algorithm from either paper is acceptable.

    Testable properties

    • For point P and polygons A and B,
      • If P is in A∪B then it must be in A or B.
      • If P is in A∩B then it must be in A and B.
      • If P is in A\B then it must be in A and not in B.
    • The area of A∪B is:
      • Greater or equal to the area of A.
      • Greater or equal to the area of B.
      • Less than or equal to the area of A + the area of B.
    • The area of A∩B is:
      • Less than or equal to the area of A.
      • Less than or equal to the area of B.
    • The area of A\B is:
      • Less than or equal to the area of A.
    • The output polygons may not be degenerate.
    • The output polygons may touch but may not overlap.

    Bounty

    50 USDC for algorithm that satisfies the above properties.

    opened by lemmih 0
  • $50 Bounty: Constrained Delaunay Triangulation

    $50 Bounty: Constrained Delaunay Triangulation

    Introduction

    A constrained Delaunay triangulation is a generalization of the Delaunay triangulation that forces certain required segments into the triangulation as edges, unlike the Delaunay triangulation itself which is based purely on the position of a given set of vertices without regard to how they should be connected by edges. It can be computed efficiently and has applications in geographic information systems and in mesh generation.

    Wikipedia: https://en.wikipedia.org/wiki/Constrained_Delaunay_triangulation Paper: https://dl.acm.org/doi/10.1080/13658810701492241

    Testable properties

    • The sum of the triangulated areas is equal to the area of the polygon.
    • No two triangles overlap.
    • All polygon vertices must appear at least once in triangulation.
    • All of the triangles obey the Delaunay condition.

    Bounty

    50 USDC for algorithm that satisfies the above properties.

    opened by lemmih 0
  • $50 Bounty: Randomized Triangulation in Linear Time

    $50 Bounty: Randomized Triangulation in Linear Time

    Introduction

    From the referenced paper:

    We describe a randomized algorithm for computing the trapezoidal decomposition of a simple polygon. Its expected running time is linear in the size of the polygon. By a well-known and simple linear time reduction, this implies a linear time algorithm for triangulating a simple polygon.

    Paper: https://www.ics.uci.edu/~goodrich/pubs/dcg-tri.pdf

    Testable properties

    • The sum of the triangulated areas is equal to the area of the polygon.
    • No two triangles overlap.
    • All polygon vertices must appear at least once in triangulation.

    Bounty

    50 USDC for algorithm that satisfies the above properties.

    opened by lemmih 0
  • $50 Bounty: Triangulation via Trapezoidal Decomposition

    $50 Bounty: Triangulation via Trapezoidal Decomposition

    Introduction

    Polygon triangulation is the partition of a polygon P into a set of triangles, i.e., finding a set of triangles with pairwise non-intersecting interiors whose union is P.

    A polygon can be decomposed into trapezoidal parts in O(n log* n) time. These trapezoidal parts can then be triangulated in linear time.

    Wikipedia: https://en.wikipedia.org/wiki/Polygon_triangulation#Computational_complexity Paper: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.472.6973&rep=rep1&type=pdf

    Testable properties

    • The sum of the triangulated areas is equal to the area of the polygon.
    • No two triangles overlap.
    • All polygon vertices must appear at least once in triangulation.

    Bounty

    50 USDC for algorithm that satisfies the above properties.

    opened by lemmih 0
  • $50 Bounty: Triangulation via Monotone Decomposition

    $50 Bounty: Triangulation via Monotone Decomposition

    Introduction

    Polygon triangulation is the partition of a polygon P into a set of triangles, i.e., finding a set of triangles with pairwise non-intersecting interiors whose union is P.

    Monotone polygons can be trivially triangulated and it is possible to decompose a polygon into monotone parts in O(n log n) time. Thus, one can triangulate a polygon by splitting it into monotone parts and then triangulating each part separately.

    Wikipedia: https://en.wikipedia.org/wiki/Polygon_triangulation#Monotone_polygon_triangulation Paper: https://www.ibr.cs.tu-bs.de/courses/ws2021/ag/Papers/Ch5/Garey-etal_Triangulating_1978.pdf

    Testable properties

    • The sum of the triangulated areas is equal to the area of the polygon.
    • No two triangles overlap.
    • All polygon vertices must appear at least once in triangulation.

    Bounty

    50 USDC for algorithm that satisfies the above properties.

    opened by lemmih 0
Optimized geometry primitives for Microsoft platforms with the same memory layout as DirectX and Direct2D and types.

geoms Geometry for Microsoft platforms - a set of geometry primitives with memory layouts optimized for native APIs (Win32, Direct2D, and Direct3D). T

Connor Power 2 Dec 11, 2022
A single-binary, GPU-accelerated LLM server (HTTP and WebSocket API) written in Rust

Poly Poly is a versatile LLM serving back-end. What it offers: High-performance, efficient and reliable serving of multiple local LLM models Optional

Tommy van der Vorst 13 Nov 5, 2023
Geocoding library for Rust.

geocoding Rust utilities to enrich addresses, cities, countries, and landmarks with geographic coordinates through third-party geocoding web services.

GeoRust 55 Dec 12, 2022
TIFF decoding and encoding library in pure Rust

image-tiff TIFF decoding and encoding library in pure Rust Supported Features Baseline spec (other than formats and tags listed below as not supported

image-rs 66 Dec 30, 2022
R*-tree library for the rust ecosystem

rstar A flexible, n-dimensional r*-tree implementation for the rust ecosystem. Please refer to the crate README for more information. Demo To run the

Stefan Altmayer 0 Dec 18, 2021
Geocoding library for Rust.

geocoding Rust utilities to enrich addresses, cities, countries, and landmarks with geographic coordinates through third-party geocoding web services.

GeoRust 55 Dec 12, 2022
Didactic implementation of the type checker described in "Complete and Easy Bidirectional Typechecking for Higher-Rank Polymorphism" written in OCaml

bidi-higher-rank-poly Didactic implementation of the type checker described in "Complete and Easy Bidirectional Typechecking for Higher-Rank Polymorph

Søren Nørbæk 23 Oct 18, 2022
Library for serializing the GeoJSON vector GIS file format

geojson Documentation Library for serializing the GeoJSON vector GIS file format Minimum Rust Version This library requires a minimum Rust version of

GeoRust 176 Dec 27, 2022
Library for serializing the GeoJSON vector GIS file format

geojson Documentation Library for serializing the GeoJSON vector GIS file format Minimum Rust Version This library requires a minimum Rust version of

GeoRust 176 Dec 27, 2022
A TinyVG vector graphics format parsing library.

tinyvg-rs A TinyVG vector graphics format parsing library. Testing This library uses the example files from the TinyVG/examples repo for integration t

null 2 Dec 31, 2021
Rust crate for performing coordinate transforms

Synopsis A Rust crate use for performing coordinate transformations. The crate relies on nalgebra vectors to perform the coordinate transformations. C

Dave 25 Aug 20, 2022
An fast, offline reverse geocoder (>1,000 HTTP requests per second) in Rust.

Rust Reverse Geocoder A fast reverse geocoder in Rust. Inspired by Python reverse-geocoder. Links Crate 2.0.0 Docs 1.0.1 Docs Description rrgeo takes

Grant Miner 91 Dec 29, 2022
Geospatial primitives and algorithms for Rust

geo Geospatial Primitives, Algorithms, and Utilities The geo crate provides geospatial primitive types such as Point, LineString, and Polygon, and pro

GeoRust 989 Dec 29, 2022
Rust bindings for GDAL

gdal [] GDAL bindings for Rust. So far, you can: open a raster dataset for reading/writing get size and number of bands get/set projection and geo-tra

GeoRust 211 Jan 4, 2023
Rust bindings for the latest stable release of PROJ

PROJ Coordinate transformation via bindings to the PROJ v7.2.1 API. Two coordinate transformation operations are currently provided: projection (and i

GeoRust 96 Dec 21, 2022
Geohash for Rust

Rust-Geohash Rust-Geohash is a Rust library for Geohash algorithm. Ported from node-geohash module. Documentation Docs Check the API doc at docs.rs Li

GeoRust 74 Sep 8, 2022
Rust read/write support for well-known text (WKT)

wkt Rust read/write support for well-known text (WKT). License Licensed under either of Apache License, Version 2.0 (LICENSE-APACHE or http://www.apac

GeoRust 40 Dec 11, 2022
Google Encoded Polyline encoding & decoding in Rust.

polyline Google Encoded Polyline encoding & decoding in Rust. A Note on Coordinate Order This crate uses Coordinate and LineString types from the geo-

GeoRust 14 Dec 11, 2022
Rust read/write support for GPS Exchange Format (GPX)

gpx gpx is a library for reading and writing GPX (GPS Exchange Format) files. It uses the primitives provided by geo-types to allow for storage of GPS

GeoRust 63 Dec 5, 2022