Skip to content

Commit

Permalink
add umd builds & API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Sep 1, 2019
1 parent 2237beb commit d9a5be3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
yarn.lock
esm/
umd/
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@ Fast robust predicates for computational geometry in JavaScript. A modern port o
- [ ] `orient3d`
- [x] `incircle`
- [ ] `insphere`
- [ ] API docs & demo
- [ ] minified UMD builds

[![Build Status](https://travis-ci.com/mourner/robust-predicates.svg?branch=master)](https://travis-ci.com/mourner/robust-predicates)
[![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)

## API

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

Return a positive value if the points `a`, `b`, and `c` occur in counterclockwise order;
a negative value if they occur in clockwise order; and zero if they are collinear.
The result is also a rough approximation of twice the signed area of the triangle defined by the three points.

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

Return a positive value if the point `d` lies inside the circle passing through `a`, `b`, and `c`;
a negative value if it lies outside; and 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.

## License

Since the original code by J. Shewchuk is in the public domain, this port follows the same choice. See [Unlicense](https://unlicense.org)
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
],
"author": "Vladimir Agafonkin",
"license": "Unlicense",
"main": "umd/predicates.js",
"unpkg": "umd/predicates.min.js",
"module": "index.js",
"scripts": {
"build": "mkdirp esm && node compile.js",
"lint": "eslint *.js esm src",
"test": "npm run build && npm run lint && node -r esm test.js",
"bench": "node -r esm bench.js"
"bench": "node -r esm bench.js",
"prepublishOnly": "rollup -c"
},
"devDependencies": {
"eslint": "^6.3.0",
Expand All @@ -22,6 +25,8 @@
"mkdirp": "^0.5.1",
"nextafter": "^1.0.0",
"robust-orientation": "^1.1.3",
"rollup": "^1.20.3",
"rollup-plugin-terser": "^5.1.1",
"tape": "^4.11.0",
"terser": "^4.2.1"
},
Expand Down
7 changes: 1 addition & 6 deletions predicates.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,6 @@ REAL *pd;
/*****************************************************************************/
/* */
/* incirclefast() Approximate 2D incircle test. Nonrobust. */
/* incircleexact() Exact 2D incircle test. Robust. */
/* incircleslow() Another exact 2D incircle test. Robust. */
/* incircle() Adaptive exact 2D incircle test. Robust. */
/* */
/* Return a positive value if the point pd lies inside the */
Expand All @@ -1113,10 +1111,7 @@ REAL *pd;
/* The points pa, pb, and pc must be in counterclockwise */
/* order, or the sign of the result will be reversed. */
/* */
/* Only the first and last routine should be used; the middle two are for */
/* timings. */
/* */
/* The last three use exact arithmetic to ensure a correct answer. The */
/* The second one uses exact arithmetic to ensure a correct answer. The */
/* result returned is the determinant of a matrix. In incircle() only, */
/* this determinant is computed adaptively, in the sense that exact */
/* arithmetic is used only to the degree it is needed to ensure that the */
Expand Down
23 changes: 23 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {terser} from 'rollup-plugin-terser';

const output = (input, file, plugins) => ({
input,
output: {
name: 'predicates',
format: 'umd',
indent: false,
file,
},
plugins
});

const builds = (input, name) => [
output(input, `umd/${name}.js`, []),
output(input, `umd/${name}.min.js`, [terser()])
];

export default [
...builds('index.js', 'predicates'),
...builds('esm/orient2d.js', 'orient2d'),
...builds('esm/incircle.js', 'incircle')
];

0 comments on commit d9a5be3

Please sign in to comment.