Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,2 @@ | ||
// https://github.com/Fil/versor v0.1.1 Copyright 2020 Mike Bostock | ||
// https://github.com/Fil/versor v0.1.2 Copyright 2020 Mike Bostock | ||
(function (global, factory) { | ||
@@ -60,5 +60,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
let dot = Versor.dot([a1, b1, c1, d1], [a2, b2, c2, d2]); | ||
if (dot < 0) { | ||
console.warn({dot}), a2 = -a2, b2 = -b2, c2 = -c2, d2 = -d2, dot = -dot; | ||
} | ||
if (dot < 0) a2 = -a2, b2 = -b2, c2 = -c2, d2 = -d2, dot = -dot; | ||
if (dot > 0.9995) return Versor.interpolateLinear([a1, b1, c1, d1], [a2, b2, c2, d2]); | ||
@@ -65,0 +63,0 @@ const theta0 = acos(max(-1, min(1, dot))); |
@@ -1,2 +0,2 @@ | ||
// https://github.com/Fil/versor v0.1.1 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&&(console.warn({dot:d}),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.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})); |
{ | ||
"name": "versor", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Versor", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -53,5 +53,3 @@ var acos = Math.acos, | ||
let dot = Versor.dot([a1, b1, c1, d1], [a2, b2, c2, d2]); | ||
if (dot < 0) { | ||
console.warn({dot}), a2 = -a2, b2 = -b2, c2 = -c2, d2 = -d2, dot = -dot; | ||
} | ||
if (dot < 0) a2 = -a2, b2 = -b2, c2 = -c2, d2 = -d2, dot = -dot; | ||
if (dot > 0.9995) return Versor.interpolateLinear([a1, b1, c1, d1], [a2, b2, c2, d2]); | ||
@@ -58,0 +56,0 @@ const theta0 = acos(max(-1, min(1, dot))); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50240
293