Socket
Socket
Sign inDemoInstall

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.1.2 to 0.2.0

.github/workflows/node.js.yml

9

.eslintrc.json

@@ -6,12 +6,3 @@ {

"ecmaVersion": 8
},
"env": {
"es6": true,
"node": true,
"browser": true
},
"rules": {
"no-cond-assign": 0,
"no-constant-condition": 0
}
}

14

dist/versor.js

@@ -1,9 +0,9 @@

// https://github.com/Fil/versor v0.1.2 Copyright 2020 Mike Bostock
// https://github.com/Fil/versor v0.2.0 Copyright 2021 Mike Bostock
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.versor = factory());
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.versor = factory());
}(this, (function () { 'use strict';
var acos = Math.acos,
const acos = Math.acos,
asin = Math.asin,

@@ -95,3 +95,3 @@ atan2 = Math.atan2,

// Returns the unit quaternion for the given Euler rotation angles [λ, φ, γ].
var versor = Versor.fromAngles;
const versor = Versor.fromAngles;

@@ -109,3 +109,3 @@ // Returns the quaternion that represents q0 * q1.

versor.cartesian = function(e) {
var l = e[0] * radians, p = e[1] * radians, cp = cos(p);
const l = e[0] * radians, p = e[1] * radians, cp = cos(p);
return [cp * cos(l), cp * sin(l), sin(p)];

@@ -128,5 +128,5 @@ };

var w = cross(v0, v1), l = sqrt(dot(w, w));
const w = cross(v0, v1), l = sqrt(dot(w, w));
if (!l) return [1, 0, 0, 0];
var t = alpha * acos(max(-1, min(1, dot(v0, v1)))) / 2, s = sin(t); // t = θ / 2
const t = alpha * acos(max(-1, min(1, dot(v0, v1)))) / 2, s = sin(t); // t = θ / 2
return [cos(t), w[2] / l * s, -w[1] / l * s, w[0] / l * s];

@@ -133,0 +133,0 @@ };

@@ -1,2 +0,2 @@

// https://github.com/Fil/versor v0.1.2 Copyright 2020 Mike Bostock
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).versor=n()}(this,(function(){"use strict";var t=Math.acos,n=Math.asin,e=Math.atan2,r=Math.cos,a=Math.hypot,o=Math.max,i=Math.min,s=Math.PI,u=Math.sin,l=s/180,c=180/s;class f{static fromCartesian([t,n,e]){return[0,e,-n,t]}static fromAngles([t,n,e]){n*=l/2,e=(e||0)*l/2;const a=u(t*=l/2),o=r(t),i=u(n),s=r(n),c=u(e),f=r(e);return[o*s*f+a*i*c,a*s*f-o*i*c,o*i*f+a*s*c,o*s*c-a*i*f]}static toAngles([t,r,a,s]){return[e(2*(t*r+a*s),1-2*(r*r+a*a))*c,n(o(-1,i(1,2*(t*a-s*r))))*c,e(2*(t*s+r*a),1-2*(a*a+s*s))*c]}static interpolateAngles(t,n){const e=f.interpolate(f.fromAngles(t),f.fromAngles(n));return t=>f.toAngles(e(t))}static interpolateLinear([t,n,e,r],[o,i,s,u]){o-=t,i-=n,s-=e,u-=r;const l=new Array(4);return c=>{const f=a(l[0]=t+o*c,l[1]=n+i*c,l[2]=e+s*c,l[3]=r+u*c);return l[0]/=f,l[1]/=f,l[2]/=f,l[3]/=f,l}}static interpolate([n,e,s,l],[c,p,h,m]){let d=f.dot([n,e,s,l],[c,p,h,m]);if(d<0&&(c=-c,p=-p,h=-h,m=-m,d=-d),d>.9995)return f.interpolateLinear([n,e,s,l],[c,p,h,m]);const A=t(o(-1,i(1,d))),g=new Array(4),M=a(c-=n*d,p-=e*d,h-=s*d,m-=l*d);return c/=M,p/=M,h/=M,m/=M,t=>{const a=A*t,o=u(a),i=r(a);return g[0]=n*i+c*o,g[1]=e*i+p*o,g[2]=s*i+h*o,g[3]=l*i+m*o,g}}static dot([t,n,e,r],[a,o,i,s]){return t*a+n*o+e*i+r*s}static multiply([t,n,e,r],[a,o,i,s]){return[t*a-n*o-e*i-r*s,t*o+n*a+e*s-r*i,t*i-n*s+e*a+r*o,t*s+n*i-e*o+r*a]}}var p=f.fromAngles;return p.multiply=f.multiply,p.rotation=f.toAngles,p.interpolate=f.interpolateAngles,p.cartesian=function(t){var n=t[0]*l,e=t[1]*l,a=r(e);return[a*r(n),a*u(n),u(e)]},p.delta=function(n,e,a){2==arguments.length&&(a=1);const s=Math.sqrt;function l(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function c(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}var f=l(n,e),p=s(c(f,f));if(!p)return[1,0,0,0];var h=a*t(o(-1,i(1,c(n,e))))/2,m=u(h);return[r(h),f[2]/p*m,-f[1]/p*m,f[0]/p*m]},p}));
// https://github.com/Fil/versor v0.2.0 Copyright 2021 Mike Bostock
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).versor=n()}(this,(function(){"use strict";const t=Math.acos,n=Math.asin,e=Math.atan2,r=Math.cos,o=Math.hypot,s=Math.max,a=Math.min,i=Math.PI,c=Math.sin,l=i/180,u=180/i;class f{static fromCartesian([t,n,e]){return[0,e,-n,t]}static fromAngles([t,n,e]){n*=l/2,e=(e||0)*l/2;const o=c(t*=l/2),s=r(t),a=c(n),i=r(n),u=c(e),f=r(e);return[s*i*f+o*a*u,o*i*f-s*a*u,s*a*f+o*i*u,s*i*u-o*a*f]}static toAngles([t,r,o,i]){return[e(2*(t*r+o*i),1-2*(r*r+o*o))*u,n(s(-1,a(1,2*(t*o-i*r))))*u,e(2*(t*i+r*o),1-2*(o*o+i*i))*u]}static interpolateAngles(t,n){const e=f.interpolate(f.fromAngles(t),f.fromAngles(n));return t=>f.toAngles(e(t))}static interpolateLinear([t,n,e,r],[s,a,i,c]){s-=t,a-=n,i-=e,c-=r;const l=new Array(4);return u=>{const f=o(l[0]=t+s*u,l[1]=n+a*u,l[2]=e+i*u,l[3]=r+c*u);return l[0]/=f,l[1]/=f,l[2]/=f,l[3]/=f,l}}static interpolate([n,e,i,l],[u,p,h,d]){let m=f.dot([n,e,i,l],[u,p,h,d]);if(m<0&&(u=-u,p=-p,h=-h,d=-d,m=-m),m>.9995)return f.interpolateLinear([n,e,i,l],[u,p,h,d]);const g=t(s(-1,a(1,m))),A=new Array(4),y=o(u-=n*m,p-=e*m,h-=i*m,d-=l*m);return u/=y,p/=y,h/=y,d/=y,t=>{const o=g*t,s=c(o),a=r(o);return A[0]=n*a+u*s,A[1]=e*a+p*s,A[2]=i*a+h*s,A[3]=l*a+d*s,A}}static dot([t,n,e,r],[o,s,a,i]){return t*o+n*s+e*a+r*i}static multiply([t,n,e,r],[o,s,a,i]){return[t*o-n*s-e*a-r*i,t*s+n*o+e*i-r*a,t*a-n*i+e*o+r*s,t*i+n*a-e*s+r*o]}}const p=f.fromAngles;return p.multiply=f.multiply,p.rotation=f.toAngles,p.interpolate=f.interpolateAngles,p.cartesian=function(t){const n=t[0]*l,e=t[1]*l,o=r(e);return[o*r(n),o*c(n),c(e)]},p.delta=function(n,e,o){2==arguments.length&&(o=1);const i=Math.sqrt;function l(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function u(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}const f=l(n,e),p=i(u(f,f));if(!p)return[1,0,0,0];const h=o*t(s(-1,a(1,u(n,e))))/2,d=c(h);return[r(h),f[2]/p*d,-f[1]/p*d,f[0]/p*d]},p}));
{
"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": [

@@ -11,13 +16,3 @@ "d3",

],
"license": "GPL-3.0",
"main": "dist/versor.js",
"unpkg": "dist/versor.min.js",
"jsdelivr": "dist/versor.min.js",
"module": "src/versor.js",
"jsnext:main": "src/versor.js",
"homepage": "https://github.com/Fil/versor",
"repository": {
"type": "git",
"url": "https://github.com/Fil/versor.git"
},
"license": "ISC",
"author": {

@@ -27,15 +22,26 @@ "name": "Mike Bostock",

},
"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"
}

@@ -55,9 +55,17 @@ # Versor

In a browser:
If you use npm, `npm install versor`. You can also download the [latest release on GitHub](https://github.com/d3/versor/releases/latest). For vanilla HTML in modern browsers, import versor from Skypack:
```html
<!DOCTYPE html>
<script src="https://unpkg.com/versor"></script>
<script type="module">
import versor from "https://cdn.skypack.dev/versor@0.2";
const t = versor([90,0,0]);
</script>
```
For legacy environments, you can load versor’s UMD bundle from an npm-based CDN such as jsDelivr; a `versor` global is exported:
```html
<script src="https://cdn.jsdelivr.net/npm/versor@0.2"></script>
<script>
versor([90,0,0]);

@@ -64,0 +72,0 @@

@@ -1,2 +0,2 @@

var acos = Math.acos,
const acos = Math.acos,
asin = Math.asin,

@@ -88,3 +88,3 @@ atan2 = Math.atan2,

// Returns the unit quaternion for the given Euler rotation angles [λ, φ, γ].
var versor = Versor.fromAngles;
const versor = Versor.fromAngles;

@@ -102,3 +102,3 @@ // Returns the quaternion that represents q0 * q1.

versor.cartesian = function(e) {
var l = e[0] * radians, p = e[1] * radians, cp = cos(p);
const l = e[0] * radians, p = e[1] * radians, cp = cos(p);
return [cp * cos(l), cp * sin(l), sin(p)];

@@ -121,5 +121,5 @@ };

var w = cross(v0, v1), l = sqrt(dot(w, w));
const w = cross(v0, v1), l = sqrt(dot(w, w));
if (!l) return [1, 0, 0, 0];
var t = alpha * acos(max(-1, min(1, dot(v0, v1)))) / 2, s = sin(t); // t = θ / 2
const t = alpha * acos(max(-1, min(1, dot(v0, v1)))) / 2, s = sin(t); // t = θ / 2
return [cos(t), w[2] / l * s, -w[1] / l * s, w[0] / l * s];

@@ -126,0 +126,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