@thi.ng/geom-hull
Advanced tools
Comparing version 0.0.29 to 0.0.30
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.0.30](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.29...@thi.ng/geom-hull@0.0.30) (2019-11-30) | ||
**Note:** Version bump only for package @thi.ng/geom-hull | ||
## [0.0.29](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-hull@0.0.28...@thi.ng/geom-hull@0.0.29) (2019-11-09) | ||
@@ -8,0 +16,0 @@ |
@@ -17,3 +17,9 @@ import { EPS } from "@thi.ng/math"; | ||
return pts.slice(); | ||
let h = 1, i, p, q, r, rx, ry; | ||
let h = 1; | ||
let i; | ||
let p; | ||
let q; | ||
let r; | ||
let rx; | ||
let ry; | ||
// find min YX index | ||
@@ -69,3 +75,3 @@ const min = findMin(pts); | ||
let minID = n; | ||
let min = pts[n][1]; | ||
let [minX, minY] = pts[n]; | ||
let p, y; | ||
@@ -75,4 +81,5 @@ for (; --n >= 0;) { | ||
y = p[1]; | ||
if (y < min || (y === min && p[0] < pts[minID][0])) { | ||
min = y; | ||
if (y < minY || (y === minY && p[0] < minX)) { | ||
minX = p[0]; | ||
minY = y; | ||
minID = n; | ||
@@ -79,0 +86,0 @@ } |
@@ -12,3 +12,9 @@ 'use strict'; | ||
return pts.slice(); | ||
let h = 1, i, p, q, r, rx, ry; | ||
let h = 1; | ||
let i; | ||
let p; | ||
let q; | ||
let r; | ||
let rx; | ||
let ry; | ||
const min = findMin(pts); | ||
@@ -44,3 +50,3 @@ [rx, ry] = pts[min]; | ||
let minID = n; | ||
let min = pts[n][1]; | ||
let [minX, minY] = pts[n]; | ||
let p, y; | ||
@@ -50,4 +56,5 @@ for (; --n >= 0;) { | ||
y = p[1]; | ||
if (y < min || (y === min && p[0] < pts[minID][0])) { | ||
min = y; | ||
if (y < minY || (y === minY && p[0] < minX)) { | ||
minX = p[0]; | ||
minY = y; | ||
minID = n; | ||
@@ -54,0 +61,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/math")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/math"],e):e(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.geomHull={}),t.thi.ng.math)}(this,(function(t,e){"use strict";const n=Math.atan2,o=(t,e,n,o,i,r,f)=>(o-e)*(i-t)>=(n-t)*(r-e)-f,i=t=>{let e,n,o=t.length-1,i=o,r=t[o][1];for(;--o>=0;)((n=(e=t[o])[1])<r||n===r&&e[0]<t[i][0])&&(r=n,i=o);return i};t.grahamScan2=(t,r=e.EPS)=>{const f=t.length;if(f<=3)return t.slice();let h,s,c,u,l,p,a=1;const g=i(t);[l,p]=t[g];const d=[];for(h=0;h<f;h++)s=t[h],d[h]={p:s,t:n(s[1]-p,s[0]-l)};d.sort((t,e)=>t.t!==e.t?t.t-e.t:t.p[0]-e.p[0]);const m=[d[0].p];for(h=1;h<f;h++){for(s=m[a-2],c=m[a-1],l=(u=d[h].p)[0],p=u[1];a>1&&o(s[0],s[1],c[0],c[1],l,p,r)||1===a&&c[0]===l&&c[1]===p;)c=s,s=m[--a-2];m[a++]=u}return m.length=a,m},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/math")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/math"],e):e(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.geomHull={}),t.thi.ng.math)}(this,(function(t,e){"use strict";const n=Math.atan2,o=(t,e,n,o,i,r,f)=>(o-e)*(i-t)>=(n-t)*(r-e)-f,i=t=>{let e,n,o=t.length-1,i=o,[r,f]=t[o];for(;--o>=0;)((n=(e=t[o])[1])<f||n===f&&e[0]<r)&&(r=e[0],f=n,i=o);return i};t.grahamScan2=(t,r=e.EPS)=>{const f=t.length;if(f<=3)return t.slice();let h,s,c,u,l,p,a=1;const g=i(t);[l,p]=t[g];const d=[];for(h=0;h<f;h++)s=t[h],d[h]={p:s,t:n(s[1]-p,s[0]-l)};d.sort((t,e)=>t.t!==e.t?t.t-e.t:t.p[0]-e.p[0]);const m=[d[0].p];for(h=1;h<f;h++){for(s=m[a-2],c=m[a-1],l=(u=d[h].p)[0],p=u[1];a>1&&o(s[0],s[1],c[0],c[1],l,p,r)||1===a&&c[0]===l&&c[1]===p;)c=s,s=m[--a-2];m[a++]=u}return m.length=a,m},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@thi.ng/geom-hull", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "Fast 2D convex hull (Graham Scan)", | ||
@@ -21,19 +21,22 @@ "module": "./index.js", | ||
"build:test": "rimraf build && tsc -p test/tsconfig.json", | ||
"test": "yarn build:test && mocha build/test/*.js", | ||
"cover": "yarn build:test && nyc mocha build/test/*.js && nyc report --reporter=lcov", | ||
"test": "mocha test", | ||
"cover": "nyc mocha test && nyc report --reporter=lcov", | ||
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", | ||
"doc": "node_modules/.bin/typedoc --mode modules --out doc --ignoreCompilerErrors src", | ||
"doc:readme": "../../scripts/generate-readme", | ||
"doc": "node_modules/.bin/typedoc --mode modules --out doc src", | ||
"pub": "yarn build:release && yarn publish --access public" | ||
}, | ||
"devDependencies": { | ||
"@istanbuljs/nyc-config-typescript": "^0.1.3", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^12.6.3", | ||
"mocha": "^6.1.4", | ||
"@types/node": "^12.12.11", | ||
"mocha": "^6.2.2", | ||
"nyc": "^14.0.0", | ||
"typedoc": "^0.15.0", | ||
"typescript": "^3.6.4" | ||
"ts-node": "^8.5.2", | ||
"typedoc": "^0.15.2", | ||
"typescript": "^3.7.2" | ||
}, | ||
"dependencies": { | ||
"@thi.ng/math": "^1.5.0", | ||
"@thi.ng/vectors": "^4.0.0" | ||
"@thi.ng/math": "^1.5.1", | ||
"@thi.ng/vectors": "^4.0.1" | ||
}, | ||
@@ -52,3 +55,6 @@ "keywords": [ | ||
"sideEffects": false, | ||
"gitHead": "97add769f24aa32a1a5e13c5c941605e1b9eb569" | ||
"thi.ng": { | ||
"year": 2013 | ||
}, | ||
"gitHead": "36c4d9e967bd80ccdbfa0f4a42f594080f95f105" | ||
} |
@@ -0,4 +1,6 @@ | ||
<!-- This file is generated - DO NOT EDIT! --> | ||
# @thi.ng/geom-hull | ||
[](https://www.npmjs.com/package/@thi.ng/geom-hull) | ||
[](https://www.npmjs.com/package/@thi.ng/geom-hull) | ||
 | ||
@@ -10,19 +12,22 @@ [](https://twitter.com/thing_umbrella) | ||
<!-- TOC depthFrom:2 depthTo:3 --> | ||
- [About](#about) | ||
- [Status](#status) | ||
- [Installation](#installation) | ||
- [Dependencies](#dependencies) | ||
- [Usage examples](#usage-examples) | ||
- [API](#api) | ||
- [Authors](#authors) | ||
- [License](#license) | ||
<!-- /TOC --> | ||
## About | ||
Geometric hull computations, currently only: | ||
Fast 2D convex hull (Graham Scan). | ||
- Graham Scan (2D convex hull) | ||
Current implementation is partially based on Clojure version of | ||
[thi.ng/geom](http://thi.ng/geom). | ||
### Status | ||
**STABLE** - used in production | ||
## Installation | ||
@@ -41,6 +46,22 @@ | ||
Several demos in this repo's | ||
[/examples](https://github.com/thi-ng/umbrella/tree/master/examples) | ||
directory are using this package. | ||
A selection: | ||
### geom-convex-hull <!-- NOTOC --> | ||
 | ||
[Live demo](https://demo.thi.ng/umbrella/geom-convex-hull/) | [Source](https://github.com/thi-ng/umbrella/tree/master/examples/geom-convex-hull) | ||
## API | ||
[Generated API docs](https://docs.thi.ng/umbrella/geom-hull/) | ||
```ts | ||
import { grahamScan2 } from "@thi.ng/geom-hull"; | ||
grahamScan2([[0,0],[50,10],[100,0],[80,50],[100,100],[50,90],[0,100]]); | ||
grahamScan2([[0, 0], [50, 10], [100, 0], [80, 50], [100, 100], [50, 90], [0, 100]]); | ||
// [ [ 0, 0 ], [ 100, 0 ], [ 100, 100 ], [ 0, 100 ] ] | ||
@@ -51,6 +72,6 @@ ``` | ||
- Karsten Schmidt | ||
Karsten Schmidt | ||
## License | ||
© 2018 Karsten Schmidt // Apache Software License 2.0 | ||
© 2013 - 2019 Karsten Schmidt // Apache Software License 2.0 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
30843
15
158
75
8
Updated@thi.ng/math@^1.5.1
Updated@thi.ng/vectors@^4.0.1