Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

versor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

versor - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

.eslintrc.json

24

package.json
{
"name": "versor",
"version": "0.0.4",
"version": "0.1.0",
"description": "Versor",

@@ -12,5 +12,5 @@ "keywords": [

"license": "GPL-3.0",
"main": "build/versor.js",
"unpkg": "build/versor.min.js",
"jsdelivr": "build/versor.min.js",
"main": "dist/versor.js",
"unpkg": "dist/versor.min.js",
"jsdelivr": "dist/versor.min.js",
"module": "src/versor.js",

@@ -28,14 +28,14 @@ "jsnext:main": "src/versor.js",

"scripts": {
"pretest": "rm -rf build && mkdir build && rollup --banner \"$(preamble)\" -f umd -n versor -o build/versor.js -- src/versor.js",
"test": "tape 'test/**/*-test.js'",
"prepublishOnly": "npm run test && uglifyjs --preamble \"$(preamble)\" build/versor.js -c negate_iife=false -m -o build/versor.min.js",
"postpublish": "zip -j build/versor.zip -- LICENSE.txt README.md build/versor.js build/versor.min.js"
"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"
},
"dependencies": {},
"devDependencies": {
"package-preamble": "0.1.0",
"rollup": "0.66.6",
"tape": "4.9.1",
"uglify-js": "3.4.9"
"eslint": "6",
"rollup": "1",
"rollup-plugin-terser": "5",
"tape": "4"
}
}

@@ -9,3 +9,3 @@ # Versor

This method, introduced by [Jason Davies](https://www.jasondavies.com/maps/rotate/) and Mike Bostock, is called [versor dragging](https://bl.ocks.org/mbostock/7ea1dde508cec6d2d95306f92642bc42).
This method, introduced by [Jason Davies](https://www.jasondavies.com/maps/rotate/) and Mike Bostock, is called [versor dragging](https://gist.github.com/mbostock/7ea1dde508cec6d2d95306f92642bc42).

@@ -18,15 +18,38 @@ This module contains the quaternion & versor functions. For a directly usable package, see [d3-inertia](https://github.com/Fil/d3-inertia).

```js
var versor = require("versor");
const versor = require("versor");
versor([90,0,0]); // [0.7071068, 0.7071068, 0, 0]
// interpolate angles (slerp), see https://observablehq.com/@d3/world-tour
versor.interpolate(rotation0, rotation1); // function of (t)
var v0 = versor([ 0, 0, 0 ]), v1 = versor([ 90, 0, 0 ]);
// quaternion to rotate between p0 and p1, see d3-inertia
const p0 = [0, 0],
p1 = [90, 0],
c0 = versor.cartesian(p0),
c1 = versor.cartesian(p1);
versor.delta(c0, c1); // [0.7071, 0.7071, 0, 0]
// quaternion to rotate between v0 and v1
versor.delta(v0, v1); // [0.923879, 0.3826834, 0, 0]
// tweening: quaternion to rotate halfway between p0 and p1
versor.delta(c0, c1, 0.5); // [0.9239, 0.3827, 0, 0]
// tweening: quaternion to rotate halfway between v0 and v1
versor.delta(v0, v1, 0.5); // [0.980785, 0.19509, 0, 0]
// utilities
// get cartesian coordinates [x, y, z] given spherical coordinates [λ, φ].
versor.cartesian = function(e) {
var l = e[0] * radians, p = e[1] * radians, cp = cos(p);
return [cp * cos(l), cp * sin(l), sin(p)];
};
// create a quaternion from Euler angles
const q0 = versor([90,0,0]); // [0.7071068, 0.7071068, 0, 0]
const q1 = versor([0,90,0]); // [0.7071068, 0, 0.7071068, 0]
// the quaternion that represents q0 * q1.
q01 = versor.multiply(q0, q1); // [0.5, 0.5, 0.5, 0.5]
// Euler rotation angles [λ, φ, γ] for the given quaternion.
versor.rotation(q01); // [90, 0, 90]
```

@@ -33,0 +56,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc