All Projects → mourner → Robust Predicates

mourner / Robust Predicates

Licence: unlicense
Fast robust predicates for computational geometry in JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Robust Predicates

Euclid
Exact Computation Geometry Framework Based on 'CGAL'
Stars: ✭ 52 (-69.41%)
Mutual labels:  computational-geometry
Delaunator
An incredibly fast JavaScript library for Delaunay triangulation of 2D points
Stars: ✭ 1,641 (+865.29%)
Mutual labels:  computational-geometry
Data structure and algorithms library
A collection of classical algorithms and data-structures implementation in C++ for coding interview and competitive programming
Stars: ✭ 133 (-21.76%)
Mutual labels:  computational-geometry
Bru 9
Aesthetic Engine 2
Stars: ✭ 74 (-56.47%)
Mutual labels:  computational-geometry
Earcut
The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
Stars: ✭ 1,359 (+699.41%)
Mutual labels:  computational-geometry
Wykobi
Wykobi C++ Computational Geometry Library
Stars: ✭ 115 (-32.35%)
Mutual labels:  computational-geometry
Polytri
🔺 Fast and simple polygon triangulation library.
Stars: ✭ 37 (-78.24%)
Mutual labels:  computational-geometry
Rbush
RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles
Stars: ✭ 1,881 (+1006.47%)
Mutual labels:  computational-geometry
Melt
Automatic conservative mesh occluder generation by box filling
Stars: ✭ 105 (-38.24%)
Mutual labels:  computational-geometry
Turf Swift
A Swift language port of Turf.js.
Stars: ✭ 123 (-27.65%)
Mutual labels:  computational-geometry
Simplification
Very fast LineString simplification using RDP or Visvalingam-Whyatt and a Rust binary
Stars: ✭ 78 (-54.12%)
Mutual labels:  computational-geometry
Hgeometry
HGeometry
Stars: ✭ 98 (-42.35%)
Mutual labels:  computational-geometry
Wagyu
A general library for geometry operations of union, intersections, difference, and xor
Stars: ✭ 116 (-31.76%)
Mutual labels:  computational-geometry
Visibility
Simple sweep line visibility polygon algorithm implementation
Stars: ✭ 62 (-63.53%)
Mutual labels:  computational-geometry
Hxgeomalgo
Small collection of computational geometry algorithms in Haxe.
Stars: ✭ 133 (-21.76%)
Mutual labels:  computational-geometry
Flatbush
A very fast static spatial index for 2D points and rectangles in JavaScript
Stars: ✭ 1,031 (+506.47%)
Mutual labels:  computational-geometry
Lazysets.jl
A Julia package for calculus with convex sets
Stars: ✭ 107 (-37.06%)
Mutual labels:  computational-geometry
Cdt
C++ library for constrained Delaunay triangulation (CDT)
Stars: ✭ 165 (-2.94%)
Mutual labels:  computational-geometry
Cavaliercontours
2D polyline library for offsetting, combining, etc.
Stars: ✭ 135 (-20.59%)
Mutual labels:  computational-geometry
Gosl
Linear algebra, eigenvalues, FFT, Bessel, elliptic, orthogonal polys, geometry, NURBS, numerical quadrature, 3D transfinite interpolation, random numbers, Mersenne twister, probability distributions, optimisation, differential equations.
Stars: ✭ 1,629 (+858.24%)
Mutual labels:  computational-geometry

robust-predicates

Fast robust predicates for computational geometry in JavaScript. Provides reliable 2D and 3D point orientation tests (orient2d, orient3d, incircle, insphere) that are not susceptible to floating point errors (without sacrificing performance). A modern port of Jonathan R Shewchuk's C code, an industry standard since 1996.

Figure: non-robust vs robust orient2d test for points within a tiny range (2-42).

Build Status Simply Awesome Browser Build

Demo

API

Note: unlike J. Shewchuk's original code, all the functions in this library assume y axis is oriented downwards ↓, so the semantics are different.

orient2d(ax,ay, bx,by, cx,cy)

  • Returns a positive value if the points a, b, and c occur in counterclockwise order (c lies to the left of the directed line defined by points a and b).
  • Returns a negative value if they occur in clockwise order (c lies to the right of the directed line ab).
  • Returns zero if they are collinear.

The result is also an approximation of twice the signed area of the triangle defined by the three points.

incircle(ax,ay, bx,by, cx,cy, dx,dy)

  • Returns a positive value if the point d lies outside the circle passing through a, b, and c.
  • Returns a negative value if it lies inside.
  • Returns zero if the four points are cocircular.

The points a, b, and c must be in counterclockwise order, or the sign of the result will be reversed.

orient3d(ax,ay,az, bx,by,bz, cx,cy,cz, dx,dy,dz)

  • Returns a positive value if the point d lies above the plane passing through a, b, and c, meaning that a, b, and c appear in counterclockwise order when viewed from d.
  • Returns a negative value if d lies below the plane.
  • Returns zero if the points are coplanar.

The result is also an approximation of six times the signed volume of the tetrahedron defined by the four points.

insphere(ax,ay,az, bx,by,bz, cx,cy,cz, dx,dy,dz, ex,ey,ez)

  • Returns a positive value if the point e lies outside the sphere passing through a, b, c, and d.
  • Returns a negative value if it lies inside.
  • Returns zero if the five points are cospherical.

The points a, b, c, and d must be ordered so that they have a positive orientation (as defined by orient3d), or the sign of the result will be reversed.

orient2dfast, orient3dfast, incirclefast, inspherefast

Simple, approximate, non-robust versions of predicates above. Use when robustness isn't needed.

Example

import {orient2d} from 'robust-predicates';

const ccw = orient2d(ax, ay, bx, by, cx, cy) > 0;

Install

Install with npm install robust-predicates or yarn add robust-predicates, or use one of the browser builds:

Thanks

This project is just a port — all the brilliant, hard work was done by Jonathan Richard Shewchuk.

The port was also inspired by Mikola Lysenko's excellent Robust Arithmetic Notes and related projects like robust-orientation and robust-in-sphere.

License

Since the original code is in the public domain, this project follows the same choice. See Unlicense.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].