-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adopt type="module" * modernize tooling * change default branch to main * license ISC
- Loading branch information
Showing
10 changed files
with
821 additions
and
757 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: yarn --frozen-lockfile | ||
- run: | | ||
echo ::add-matcher::.github/eslint.json | ||
yarn run eslint src test --format=compact | ||
- run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2013-2021 Mike Bostock | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose | ||
with or without fee is hereby granted, provided that the above copyright notice | ||
and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
THIS SOFTWARE. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
{ | ||
"name": "versor", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Versor", | ||
"homepage": "https://github.com/Fil/versor", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Fil/versor.git" | ||
}, | ||
"keywords": [ | ||
"d3", | ||
"d3-module", | ||
"d3-geo", | ||
"versor" | ||
], | ||
"license": "GPL-3.0", | ||
"main": "dist/versor.js", | ||
"unpkg": "dist/versor.min.js", | ||
"jsdelivr": "dist/versor.min.js", | ||
"module": "src/index.js", | ||
"jsnext:main": "src/index.js", | ||
"homepage": "https://github.com/Fil/versor", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Fil/versor.git" | ||
}, | ||
"license": "ISC", | ||
"author": { | ||
"name": "Mike Bostock", | ||
"url": "https://github.com/mbostock" | ||
}, | ||
"scripts": { | ||
"pretest": "rollup -c", | ||
"test": "tape 'test/**/*-test.js' && eslint src", | ||
"prepublishOnly": "rm -rf dist && yarn test", | ||
"postpublish": "zip -j dist/versor.zip -- LICENSE.txt README.md dist/versor.js dist/versor.min.js" | ||
"type": "module", | ||
"module": "src/index.js", | ||
"main": "src/index.js", | ||
"jsdelivr": "dist/versor.min.js", | ||
"unpkg": "dist/versor.min.js", | ||
"exports": { | ||
"umd": "./dist/versor.min.js", | ||
"default": "./src/index.js" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"eslint": "6", | ||
"rollup": "1", | ||
"rollup-plugin-terser": "5", | ||
"tape": "4" | ||
} | ||
"eslint": "7", | ||
"mocha": "8", | ||
"rollup": "2", | ||
"rollup-plugin-terser": "5" | ||
}, | ||
"scripts": { | ||
"test": "mocha 'test/**/*-test.js' && eslint src test", | ||
"prepublishOnly": "rm -rf dist && yarn test && rollup -c" | ||
}, | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"jsnext:main": "src/index.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 8 | ||
}, | ||
"env": { | ||
"mocha": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,47 @@ | ||
var tape = require("tape"); | ||
var versor = require("../"); | ||
import assert from "assert"; | ||
import versor from "../src/index.js"; | ||
|
||
function distance2 (a,b) { | ||
return a | ||
.map(function(x,i) { return (x - b[i]) * (x - b[i]); }) | ||
.reduce(function(a,b) { return a + b; }, 0); | ||
} | ||
|
||
tape("versor offers functions", function(test) { | ||
test.equal(typeof versor, 'function'); | ||
test.equal(typeof versor.cartesian, 'function'); | ||
test.equal(typeof versor.rotation, 'function'); | ||
test.equal(typeof versor.delta, 'function'); | ||
test.end(); | ||
it("versor offers functions", () => { | ||
assert.strictEqual(typeof versor, 'function'); | ||
assert.strictEqual(typeof versor.cartesian, 'function'); | ||
assert.strictEqual(typeof versor.rotation, 'function'); | ||
assert.strictEqual(typeof versor.delta, 'function'); | ||
}); | ||
|
||
tape("90° versors", function(test) { | ||
test.ok(distance2(versor([ 90, 0, 0 ]), [ Math.sqrt(2)/2, Math.sqrt(2)/2, 0, 0 ]) < 1e-8); | ||
test.ok(distance2(versor([ -90, 0, 0 ]), [ Math.sqrt(2)/2, -Math.sqrt(2)/2, 0, 0 ]) < 1e-8); | ||
test.ok(distance2(versor([ 0, 90, 0 ]), [ Math.sqrt(2)/2, 0, Math.sqrt(2)/2, 0 ]) < 1e-8); | ||
test.ok(distance2(versor([ 0, -90, 0 ]), [ Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, 0 ]) < 1e-8); | ||
test.ok(distance2(versor([ 0, 0, 90 ]), [ Math.sqrt(2)/2, 0, 0, Math.sqrt(2)/2 ]) < 1e-8); | ||
test.ok(distance2(versor([ 0, 0, -90 ]), [ Math.sqrt(2)/2, 0, 0, -Math.sqrt(2)/2 ]) < 1e-8); | ||
test.end(); | ||
it("90° versors", () => { | ||
assert(distance2(versor([ 90, 0, 0 ]), [ Math.sqrt(2)/2, Math.sqrt(2)/2, 0, 0 ]) < 1e-8); | ||
assert(distance2(versor([ -90, 0, 0 ]), [ Math.sqrt(2)/2, -Math.sqrt(2)/2, 0, 0 ]) < 1e-8); | ||
assert(distance2(versor([ 0, 90, 0 ]), [ Math.sqrt(2)/2, 0, Math.sqrt(2)/2, 0 ]) < 1e-8); | ||
assert(distance2(versor([ 0, -90, 0 ]), [ Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, 0 ]) < 1e-8); | ||
assert(distance2(versor([ 0, 0, 90 ]), [ Math.sqrt(2)/2, 0, 0, Math.sqrt(2)/2 ]) < 1e-8); | ||
assert(distance2(versor([ 0, 0, -90 ]), [ Math.sqrt(2)/2, 0, 0, -Math.sqrt(2)/2 ]) < 1e-8); | ||
}); | ||
|
||
|
||
tape("delta for large angles https://github.com/Fil/versor/issues/8", function(test){ | ||
test.ok(distance2(versor.delta([0.5963903847916048, -0.48599667744373487, -0.6388471949079623], [0.2185627727412969, 0.8848373533648707, -0.4114525154399803]), [ 0.6939654197615048, | ||
it("delta for large angles https://github.com/Fil/versor/issues/8", function(){ | ||
assert(distance2(versor.delta([0.5963903847916048, -0.48599667744373487, -0.6388471949079623], [0.2185627727412969, 0.8848373533648707, -0.4114525154399803]), [ 0.6939654197615048, | ||
0.45674413520077356, | ||
-0.07619840032229953, | ||
0.551353421067883 ]) < 1e-8); | ||
test.end(); | ||
}); | ||
|
||
tape("delta", function(test) { | ||
var a = versor.cartesian([ 0, 0 ]), b = versor.cartesian([ 90, 0 ]); | ||
test.ok(distance2(versor.delta(a,b), [ 0.7071, 0.7071, 0, 0 ]) < 1e-8); | ||
it("delta", () => { | ||
let a = versor.cartesian([ 0, 0 ]), b = versor.cartesian([ 90, 0 ]); | ||
assert(distance2(versor.delta(a,b), [ 0.7071, 0.7071, 0, 0 ]) < 1e-8); | ||
b = versor.cartesian([ 0, 90 ]); | ||
test.ok(distance2(versor.delta(a,b), [ 0.7071, 0, 0.7071, 0 ]) < 1e-8); | ||
assert(distance2(versor.delta(a,b), [ 0.7071, 0, 0.7071, 0 ]) < 1e-8); | ||
|
||
a = versor.cartesian([ 0, 0 ]), b = versor.cartesian([ 180, 0 ]); | ||
test.ok(distance2(versor.delta(a,b), [ 0, 1, 0, 0 ]) < 1e-8); | ||
test.end(); | ||
assert(distance2(versor.delta(a,b), [ 0, 1, 0, 0 ]) < 1e-8); | ||
}); | ||
|
||
tape("delta tweening", function(test) { | ||
var a = versor.cartesian([ 0, 0 ]), b = versor.cartesian([ 90, 0 ]); | ||
test.ok(distance2(versor.delta(a,b,0.5), [ 0.9239, 0.3827, 0, 0 ]) < 1e-8); | ||
test.end(); | ||
it("delta tweening", () => { | ||
const a = versor.cartesian([ 0, 0 ]), b = versor.cartesian([ 90, 0 ]); | ||
assert(distance2(versor.delta(a,b,0.5), [ 0.9239, 0.3827, 0, 0 ]) < 1e-8); | ||
}); |
Oops, something went wrong.