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

@thi.ng/math

Package Overview
Dependencies
Maintainers
1
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/math - npm Package Compare versions

Comparing version 1.7.13 to 2.0.0

19

CHANGELOG.md

@@ -6,2 +6,21 @@ # Change Log

# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@1.7.13...@thi.ng/math@2.0.0) (2020-07-17)
### Code Refactoring
* **math:** swap `eqDelta()` impls, rename ([5404a56](https://github.com/thi-ng/umbrella/commit/5404a5699a44d7ef6c2ccb5804f2b099a4358eb1))
### BREAKING CHANGES
* **math:** Revert/rename `eqDeltaFixed()` => `eqDelta()`. Rename curr `eqDelta()` => `eqDeltaScaled()`
- this is essentially a revert to 5018009
- also keep, but deprecate `eqDeltaFixed()` (synonym for `eqDelta` now)
## [1.7.13](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@1.7.12...@thi.ng/math@1.7.13) (2020-07-02)

@@ -8,0 +27,0 @@

22

eqdelta.d.ts
/**
* Similar to {@link eqDelta}, but used given `eps` as is.
*
* @param a - left value
* @param b - right value
* @param eps - epsilon / tolerance, default `1e-6`
*/
export declare const eqDelta: (a: number, b: number, eps?: number) => boolean;
/**
* @deprecated
*/
export declare const eqDeltaFixed: (a: number, b: number, eps?: number) => boolean;
/**
* Checks if `|a - b| <= ε` and adapts given epsilon value to the given

@@ -14,11 +26,3 @@ * arguments:

*/
export declare const eqDelta: (a: number, b: number, eps?: number) => boolean;
/**
* Similar to {@link eqDelta}, but used given `eps` as is.
*
* @param a - left value
* @param b - right value
* @param eps - epsilon / tolerance, default `1e-6`
*/
export declare const eqDeltaFixed: (a: number, b: number, eps?: number) => boolean;
export declare const eqDeltaScaled: (a: number, b: number, eps?: number) => boolean;
//# sourceMappingURL=eqdelta.d.ts.map

@@ -5,2 +5,14 @@ import { EPS } from "./api";

/**
* Similar to {@link eqDelta}, but used given `eps` as is.
*
* @param a - left value
* @param b - right value
* @param eps - epsilon / tolerance, default `1e-6`
*/
export const eqDelta = (a, b, eps = EPS) => abs(a - b) <= eps;
/**
* @deprecated
*/
export const eqDeltaFixed = eqDelta;
/**
* Checks if `|a - b| <= ε` and adapts given epsilon value to the given

@@ -18,10 +30,2 @@ * arguments:

*/
export const eqDelta = (a, b, eps = EPS) => abs(a - b) <= eps * max(1, abs(a), abs(b));
/**
* Similar to {@link eqDelta}, but used given `eps` as is.
*
* @param a - left value
* @param b - right value
* @param eps - epsilon / tolerance, default `1e-6`
*/
export const eqDeltaFixed = (a, b, eps = EPS) => abs(a - b) <= eps;
export const eqDeltaScaled = (a, b, eps = EPS) => abs(a - b) <= eps * max(1, abs(a), abs(b));

@@ -81,4 +81,5 @@ 'use strict';

const max = Math.max;
const eqDelta = (a, b, eps = EPS) => abs(a - b) <= eps * max(1, abs(a), abs(b));
const eqDeltaFixed = (a, b, eps = EPS) => abs(a - b) <= eps;
const eqDelta = (a, b, eps = EPS) => abs(a - b) <= eps;
const eqDeltaFixed = eqDelta;
const eqDeltaScaled = (a, b, eps = EPS) => abs(a - b) <= eps * max(1, abs(a), abs(b));

@@ -498,2 +499,3 @@ const isCrossOver = (a1, a2, b1, b2) => a1 < b1 && a2 > b2;

exports.eqDeltaFixed = eqDeltaFixed;
exports.eqDeltaScaled = eqDeltaScaled;
exports.expFactor = expFactor;

@@ -500,0 +502,0 @@ exports.expStep = expStep;

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

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.math={}))}(this,(function(t){"use strict";const i=Math.PI,a=2*i,n=i/2,s=i/3,r=i/4,e=i/6,o=1/i,h=1/a,u=1/n,c=i/180,M=180/i,d=(1+Math.sqrt(5))/2,f=Math.SQRT2,l=Math.sqrt(3),m=f/2,p=l/2;let b=1e-6;var x;(x=t.Crossing||(t.Crossing={}))[x.EQUAL=0]="EQUAL",x[x.FLAT=1]="FLAT",x[x.UNDER=2]="UNDER",x[x.OVER=3]="OVER",x[x.OTHER=4]="OTHER";const g=t=>(t%=a)<0?a+t:t,R=t=>(t=Math.abs(t))>i?a-t:t,I=t=>{const i=t*t;return.99940307+i*(.03679168*i-.49558072)},T=t=>{switch((t%=a)<0&&(t=-t),t*u|0){case 0:return I(t);case 1:return-I(i-t);case 2:return-I(t-i);default:return I(a-t)}},E=Math.abs,C=Math.max,D=(t,i,a=b)=>E(t-i)<=a*C(1,E(t),E(i)),v=(t,i,a,n)=>t<a&&i>n,A=(t,i,a,n)=>t>a&&i<n,H=(t,i,a)=>t>i&&i<a,P=(t,i,a)=>t<i&&i>a,_=(t,i,a=0,n=i.length)=>{n--;for(let s=a+1;s<n;s++)if(t(i[s-1],i[s],i[s+1]))return s;return-1},q=(t,i=0,a=t.length)=>_(H,t,i,a);function*S(t,i,a=0,n=i.length){for(;a<n;){const s=t(i,a,n);if(s<0)return;yield s,a=s+1}}const w=t=>t<0?0:t>1?1:t,O=t=>t<-1?-1:t>1?1:t,Q=(t,i)=>0!==t?0!==i?Math.min(t,i):t:i,U=(t,i,a)=>L(t,i,-a),L=(t,i,a)=>{const n=Math.exp(t*a),s=Math.exp(i*a);return(t*n+i*s)/(n+s)},N=(t,i,a)=>a!==i?(t-i)/(a-i):0,y=255,F=65535,V=t=>128&(t&=y)?t|~y:t,j=t=>32768&(t&=F)?t|~F:t,G=(t,i,a,n=16,s=8,r=0,e=1,o=b)=>{if(s<=0)return(r+e)/2;const h=(e-r)/n;let u=r,c=1/0;for(let s=0;s<=n;s++){const n=r+s*h,e=i(a,t(n));if(e<c){if(e<=o)return n;c=e,u=n}}return G(t,i,a,n,s-1,Math.max(u-h,0),Math.min(u+h,1))},X=(t,i,a)=>t+(i-t)*a,Z=t=>t-Math.floor(t);t.DEG2RAD=c,t.EPS=b,t.HALF_PI=n,t.INV_HALF_PI=u,t.INV_PI=o,t.INV_TAU=h,t.PHI=d,t.PI=i,t.QUARTER_PI=r,t.RAD2DEG=M,t.SIXTH=1/6,t.SIXTH_PI=e,t.SQRT2=f,t.SQRT2_2=m,t.SQRT2_3=p,t.SQRT3=l,t.TAU=a,t.THIRD=1/3,t.THIRD_PI=s,t.TWO_THIRD=2/3,t.absDiff=(t,i)=>Math.abs(t-i),t.absInnerAngle=R,t.absMax=(t,i)=>Math.abs(t)>Math.abs(i)?t:i,t.absMin=(t,i)=>Math.abs(t)<Math.abs(i)?t:i,t.absTheta=g,t.addi16=(t,i)=>j((0|t)+(0|i)),t.addi32=(t,i)=>(0|t)+(0|i)|0,t.addi8=(t,i)=>V((0|t)+(0|i)),t.addu16=(t,i)=>(t&F)+(i&F)&F,t.addu32=(t,i)=>(t>>>0)+(i>>>0)>>>0,t.addu8=(t,i)=>(t&y)+(i&y)&y,t.andi16=(t,i)=>j((0|t)&(0|i)),t.andi32=(t,i)=>(0|t)&(0|i),t.andi8=(t,i)=>V((0|t)&(0|i)),t.andu16=(t,i)=>t&F&i&F&F,t.andu32=(t,i)=>(t>>>0&i>>>0)>>>0,t.andu8=(t,i)=>t&y&i&y&y,t.angleDist=(t,i)=>R(g(i%a-t%a)),t.atan2Abs=(t,i)=>g(Math.atan2(t,i)),t.bounce=(t,i,a)=>{const s=a*t;return 1-i*Math.sin(s)/s*Math.cos(a*n)},t.circular=t=>(t=1-t,Math.sqrt(1-t*t)),t.clamp=(t,i,a)=>t<i?i:t>a?a:t,t.clamp01=w,t.clamp05=t=>t<0?0:t>.5?.5:t,t.clamp11=O,t.classifyCrossing=(i,a,n,s,r=b)=>v(i,a,n,s)?t.Crossing.OVER:A(i,a,n,s)?t.Crossing.UNDER:D(i,n,r)&&D(a,s,r)?D(i,s,r)?t.Crossing.FLAT:t.Crossing.EQUAL:t.Crossing.OTHER,t.cosine=t=>1-(.5*Math.cos(t*i)+.5),t.cossin=(t,i=1)=>[Math.cos(t)*i,Math.sin(t)*i],t.cot=t=>1/Math.tan(t),t.csc=t=>1/Math.sin(t),t.cubicPulse=(t,i,a)=>(a=Math.abs(a-i))>t?0:1-(a/=t)*a*(3-2*a),t.decimated=(t,i)=>Math.floor(i*t)/t,t.deg=t=>t*M,t.derivative=(t,i=b)=>a=>(t(a+i)-t(a))/i,t.divi16=(t,i)=>j((0|t)/(0|i)),t.divi32=(t,i)=>(0|t)/(0|i)|0,t.divi8=(t,i)=>V((0|t)/(0|i)),t.divu16=(t,i)=>(t&F)/(i&F)&F,t.divu32=(t,i)=>(t>>>0)/(i>>>0)>>>0,t.divu8=(t,i)=>(t&y)/(i&y)&y,t.ease=(t,i)=>Math.pow(i,t),t.eqDelta=D,t.eqDeltaFixed=(t,i,a=b)=>E(t-i)<=a,t.expFactor=(t,i,a)=>(i/t)**(1/a),t.expStep=(t,i,a)=>1-Math.exp(-t*Math.pow(a,i)),t.fastCos=T,t.fastSin=t=>T(n-t),t.fit=(t,i,a,n,s)=>n+(s-n)*N(t,i,a),t.fit01=(t,i,a)=>i+(a-i)*w(t),t.fit10=(t,i,a)=>a+(i-a)*w(t),t.fit11=(t,i,a)=>i+(a-i)*(.5+.5*O(t)),t.fitClamped=(t,i,a,n,s)=>n+(s-n)*w(N(t,i,a)),t.fmod=(t,i)=>t-i*Math.floor(t/i),t.foldback=(t,i)=>i<-t||i>t?Math.abs(Math.abs((i-t)%(4*t))-2*t)-t:i,t.fract=Z,t.gain=(t,i)=>i<.5?.5*Math.pow(2*i,t):1-.5*Math.pow(2-2*i,t),t.impulse=(t,i)=>{const a=t*i;return a*Math.exp(1-a)},t.inOpenRange=(t,i,a)=>t>i&&t<a,t.inRange=(t,i,a)=>t>=i&&t<=a,t.isCrossOver=v,t.isCrossUnder=A,t.isMaxima=P,t.isMinima=H,t.loc=(t,i,a)=>Math.sqrt(t*t+i*i-2*t*i*Math.cos(a)),t.lshifti16=(t,i)=>j((0|t)<<(0|i)),t.lshifti32=(t,i)=>(0|t)<<(0|i),t.lshifti8=(t,i)=>V((0|t)<<(0|i)),t.lshiftu16=(t,i)=>(t&F)<<(i&F)&F,t.lshiftu32=(t,i)=>t>>>0<<(i>>>0)>>>0,t.lshiftu8=(t,i)=>(t&y)<<(i&y)&y,t.max2id=(t,i)=>t>=i?0:1,t.max3id=(t,i,a)=>t>=i?t>=a?0:2:i>=a?1:2,t.max4id=(t,i,a,n)=>t>=i?t>=a?t>=n?0:3:a>=n?2:3:i>=a?i>=n?1:3:a>=n?2:3,t.maximaIndex=(t,i=0,a=t.length)=>_(P,t,i,a),t.maximaIndices=(t,i=0,a=t.length)=>S(q,t,i,a),t.min2id=(t,i)=>t<=i?0:1,t.min3id=(t,i,a)=>t<=i?t<=a?0:2:i<=a?1:2,t.min4id=(t,i,a,n)=>t<=i?t<=a?t<=n?0:3:a<=n?2:3:i<=a?i<=n?1:3:a<=n?2:3,t.minError=G,t.minNonZero2=Q,t.minNonZero3=(t,i,a)=>Q(Q(t,i),a),t.minimaIndex=q,t.minimaIndices=(t,i=0,a=t.length)=>S(q,t,i,a),t.mix=X,t.mixBilinear=(t,i,a,n,s,r)=>X(X(t,i,s),X(a,n,s),r),t.mixCubic=(t,i,a,n,s)=>{const r=s*s,e=1-s,o=e*e;return t*o*e+3*i*o*s+3*a*r*e+n*r*s},t.mixCubicHermite=(t,i,a,n,s)=>{const r=s-1,e=s*s,o=r*r;return(1+2*s)*o*t+s*o*i+e*(3-2*s)*a+e*r*n},t.mixHermite=(t,i,a,n,s)=>{const r=.5*(a-t),e=1.5*(i-a)+.5*(n-t);return((e*s+t-i+r-e)*s+r)*s+i},t.mixQuadratic=(t,i,a,n)=>{const s=1-n;return t*s*s+2*i*s*n+a*n*n},t.muli16=(t,i)=>j((0|t)*(0|i)),t.muli32=(t,i)=>(0|t)*(0|i)|0,t.muli8=(t,i)=>V((0|t)*(0|i)),t.mulu16=(t,i)=>(t&F)*(i&F)&F,t.mulu32=(t,i)=>(t>>>0)*(i>>>0)>>>0,t.mulu8=(t,i)=>(t&y)*(i&y)&y,t.norm=N,t.normCos=t=>{const i=t*t;return 1+i*(2*i-4)},t.noti16=t=>j(~t),t.noti32=t=>~t,t.noti8=t=>V(~t),t.notu16=t=>~t&F,t.notu32=t=>~t>>>0,t.notu8=t=>~t&y,t.ori16=(t,i)=>j(0|t|i),t.ori32=(t,i)=>0|t|i,t.ori8=(t,i)=>V(0|t|i),t.oru16=(t,i)=>(t&F|i&F)&F,t.oru32=(t,i)=>(t>>>0|i>>>0)>>>0,t.oru8=(t,i)=>(t&y|i&y)&y,t.parabola=(t,i)=>Math.pow(4*i*(1-i),t),t.quadrant=t=>g(t)*u|0,t.rad=t=>t*c,t.roundEps=(t,i=b)=>{const a=Z(t);return a<=i||a>=1-i?Math.round(t):t},t.roundTo=(t,i=1)=>Math.round(t/i)*i,t.rshifti16=(t,i)=>j((0|t)>>(0|i)),t.rshifti32=(t,i)=>(0|t)>>(0|i),t.rshifti8=(t,i)=>V((0|t)>>(0|i)),t.rshiftu16=(t,i)=>(t&F)>>>(i&F)&F,t.rshiftu32=(t,i)=>t>>>0>>>(i>>>0)>>>0,t.rshiftu8=(t,i)=>(t&y)>>>(i&y)&y,t.safeDiv=(t,i)=>0!==i?t/i:0,t.sclamp=(t,i,a,n)=>U(L(t,i,n),a,n),t.sec=t=>1/Math.cos(t),t.sigmoid=(t,i)=>1/(1+Math.exp(-t*(2*i-1))),t.sigmoid11=(t,i)=>1/(1+Math.exp(-t*i)),t.sign=(t,i=b)=>t>i?1:t<-i?-1:0,t.signExtend16=j,t.signExtend8=V,t.simplifyRatio=(t,i)=>{let a=Math.abs(t),n=Math.abs(i);for(;;){if(a<n){const t=a;a=n,n=t}const s=a%n;if(!s)return[t/n,i/n];a=s}},t.sinc=(t,a)=>(a=i*(t*a-1),Math.sin(a)/a),t.sincos=(t,i=1)=>[Math.sin(t)*i,Math.cos(t)*i],t.smax=L,t.smin=U,t.smoothStep=(t,i,a)=>(3-2*(a=w((a-t)/(i-t))))*a*a,t.smootherStep=(t,i,a)=>(a=w((a-t)/(i-t)))*a*a*(a*(6*a-15)+10),t.solveCubic=(t,i,a,n,s=1e-9)=>{const r=t*t,e=i*i,o=i/(3*t),h=(3*t*a-e)/(3*r),u=(2*e*i-9*t*i*a+27*r*n)/(27*r*t);if(Math.abs(h)<s)return[Math.cbrt(-u)-o];if(Math.abs(u)<s)return h<0?[-Math.sqrt(-h)-o,-o,Math.sqrt(-h)-o]:[-o];{const t=u*u/4+h*h*h/27;if(Math.abs(t)<s)return[-1.5*u/h-o,3*u/h-o];if(t>0){const i=Math.cbrt(-u/2-Math.sqrt(t));return[i-h/(3*i)-o]}{const t=2*Math.sqrt(-h/3),i=Math.acos(3*u/h/t)/3,a=2*Math.PI/3;return[t*Math.cos(i)-o,t*Math.cos(i-a)-o,t*Math.cos(i-2*a)-o]}}},t.solveLinear=(t,i)=>-i/t,t.solveQuadratic=(t,i,a,n=1e-9)=>{const s=2*t;let r=i*i-4*t*a;return r<0?[]:r<n?[-i/s]:(r=Math.sqrt(r),[(-i-r)/s,(-i+r)/s])},t.step=(t,i)=>i<t?0:1,t.subi16=(t,i)=>j((0|t)-(0|i)),t.subi32=(t,i)=>(0|t)-(0|i)|0,t.subi8=(t,i)=>V((0|t)-(0|i)),t.subu16=(t,i)=>(t&F)-(i&F)&F,t.subu32=(t,i)=>(t>>>0)-(i>>>0)>>>0,t.subu8=(t,i)=>(t&y)-(i&y)&y,t.tangentCardinal=(t,i,a=.5,n=0,s=2)=>a*((i-t)/(s-n)),t.tangentDiff3=(t,i,a,n=0,s=1,r=2)=>.5*((a-i)/(r-s)+(i-t)/(s-n)),t.trunc=t=>t<0?Math.ceil(t):Math.floor(t),t.tween=(t,i,a)=>n=>X(i,a,t(n)),t.wrap=(t,i,a)=>{if(i===a)return i;if(t>a){const n=a-i;(t-=n)>a&&(t-=n*((t-i)/n|0))}else if(t<i){const n=a-i;(t+=n)<i&&(t+=n*((i-t)/n+1|0))}return t},t.wrap01=t=>t<0?t+1:t>1?t-1:t,t.wrap11=t=>t<-1?t+2:t>1?t-2:t,t.wrapOnce=(t,i,a)=>t<i?t-i+a:t>a?t-a+i:t,t.xori16=(t,i)=>j((0|t)^(0|i)),t.xori32=(t,i)=>(0|t)^(0|i),t.xori8=(t,i)=>V((0|t)^(0|i)),t.xoru16=(t,i)=>(t&F^i&F)&F,t.xoru32=(t,i)=>(t>>>0^i>>>0)>>>0,t.xoru8=(t,i)=>(t&y^i&y)&y,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports):"function"==typeof define&&define.amd?define(["exports"],a):a(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.math={}))}(this,(function(t){"use strict";const a=Math.PI,i=2*a,n=a/2,s=a/3,r=a/4,e=a/6,o=1/a,h=1/i,u=1/n,c=a/180,M=180/a,d=(1+Math.sqrt(5))/2,f=Math.SQRT2,l=Math.sqrt(3),m=f/2,p=l/2;let b=1e-6;var x;(x=t.Crossing||(t.Crossing={}))[x.EQUAL=0]="EQUAL",x[x.FLAT=1]="FLAT",x[x.UNDER=2]="UNDER",x[x.OVER=3]="OVER",x[x.OTHER=4]="OTHER";const g=t=>(t%=i)<0?i+t:t,R=t=>(t=Math.abs(t))>a?i-t:t,I=t=>{const a=t*t;return.99940307+a*(.03679168*a-.49558072)},T=t=>{switch((t%=i)<0&&(t=-t),t*u|0){case 0:return I(t);case 1:return-I(a-t);case 2:return-I(t-a);default:return I(i-t)}},E=Math.abs,C=Math.max,D=(t,a,i=b)=>E(t-a)<=i,v=D,A=(t,a,i,n)=>t<i&&a>n,q=(t,a,i,n)=>t>i&&a<n,H=(t,a,i)=>t>a&&a<i,P=(t,a,i)=>t<a&&a>i,S=(t,a,i=0,n=a.length)=>{n--;for(let s=i+1;s<n;s++)if(t(a[s-1],a[s],a[s+1]))return s;return-1},_=(t,a=0,i=t.length)=>S(H,t,a,i);function*w(t,a,i=0,n=a.length){for(;i<n;){const s=t(a,i,n);if(s<0)return;yield s,i=s+1}}const O=t=>t<0?0:t>1?1:t,Q=t=>t<-1?-1:t>1?1:t,U=(t,a)=>0!==t?0!==a?Math.min(t,a):t:a,L=(t,a,i)=>N(t,a,-i),N=(t,a,i)=>{const n=Math.exp(t*i),s=Math.exp(a*i);return(t*n+a*s)/(n+s)},y=(t,a,i)=>i!==a?(t-a)/(i-a):0,F=255,V=65535,j=t=>128&(t&=F)?t|~F:t,G=t=>32768&(t&=V)?t|~V:t,X=(t,a,i,n=16,s=8,r=0,e=1,o=b)=>{if(s<=0)return(r+e)/2;const h=(e-r)/n;let u=r,c=1/0;for(let s=0;s<=n;s++){const n=r+s*h,e=a(i,t(n));if(e<c){if(e<=o)return n;c=e,u=n}}return X(t,a,i,n,s-1,Math.max(u-h,0),Math.min(u+h,1))},Z=(t,a,i)=>t+(a-t)*i,k=t=>t-Math.floor(t);t.DEG2RAD=c,t.EPS=b,t.HALF_PI=n,t.INV_HALF_PI=u,t.INV_PI=o,t.INV_TAU=h,t.PHI=d,t.PI=a,t.QUARTER_PI=r,t.RAD2DEG=M,t.SIXTH=1/6,t.SIXTH_PI=e,t.SQRT2=f,t.SQRT2_2=m,t.SQRT2_3=p,t.SQRT3=l,t.TAU=i,t.THIRD=1/3,t.THIRD_PI=s,t.TWO_THIRD=2/3,t.absDiff=(t,a)=>Math.abs(t-a),t.absInnerAngle=R,t.absMax=(t,a)=>Math.abs(t)>Math.abs(a)?t:a,t.absMin=(t,a)=>Math.abs(t)<Math.abs(a)?t:a,t.absTheta=g,t.addi16=(t,a)=>G((0|t)+(0|a)),t.addi32=(t,a)=>(0|t)+(0|a)|0,t.addi8=(t,a)=>j((0|t)+(0|a)),t.addu16=(t,a)=>(t&V)+(a&V)&V,t.addu32=(t,a)=>(t>>>0)+(a>>>0)>>>0,t.addu8=(t,a)=>(t&F)+(a&F)&F,t.andi16=(t,a)=>G((0|t)&(0|a)),t.andi32=(t,a)=>(0|t)&(0|a),t.andi8=(t,a)=>j((0|t)&(0|a)),t.andu16=(t,a)=>t&V&a&V&V,t.andu32=(t,a)=>(t>>>0&a>>>0)>>>0,t.andu8=(t,a)=>t&F&a&F&F,t.angleDist=(t,a)=>R(g(a%i-t%i)),t.atan2Abs=(t,a)=>g(Math.atan2(t,a)),t.bounce=(t,a,i)=>{const s=i*t;return 1-a*Math.sin(s)/s*Math.cos(i*n)},t.circular=t=>(t=1-t,Math.sqrt(1-t*t)),t.clamp=(t,a,i)=>t<a?a:t>i?i:t,t.clamp01=O,t.clamp05=t=>t<0?0:t>.5?.5:t,t.clamp11=Q,t.classifyCrossing=(a,i,n,s,r=b)=>A(a,i,n,s)?t.Crossing.OVER:q(a,i,n,s)?t.Crossing.UNDER:D(a,n,r)&&D(i,s,r)?D(a,s,r)?t.Crossing.FLAT:t.Crossing.EQUAL:t.Crossing.OTHER,t.cosine=t=>1-(.5*Math.cos(t*a)+.5),t.cossin=(t,a=1)=>[Math.cos(t)*a,Math.sin(t)*a],t.cot=t=>1/Math.tan(t),t.csc=t=>1/Math.sin(t),t.cubicPulse=(t,a,i)=>(i=Math.abs(i-a))>t?0:1-(i/=t)*i*(3-2*i),t.decimated=(t,a)=>Math.floor(a*t)/t,t.deg=t=>t*M,t.derivative=(t,a=b)=>i=>(t(i+a)-t(i))/a,t.divi16=(t,a)=>G((0|t)/(0|a)),t.divi32=(t,a)=>(0|t)/(0|a)|0,t.divi8=(t,a)=>j((0|t)/(0|a)),t.divu16=(t,a)=>(t&V)/(a&V)&V,t.divu32=(t,a)=>(t>>>0)/(a>>>0)>>>0,t.divu8=(t,a)=>(t&F)/(a&F)&F,t.ease=(t,a)=>Math.pow(a,t),t.eqDelta=D,t.eqDeltaFixed=v,t.eqDeltaScaled=(t,a,i=b)=>E(t-a)<=i*C(1,E(t),E(a)),t.expFactor=(t,a,i)=>(a/t)**(1/i),t.expStep=(t,a,i)=>1-Math.exp(-t*Math.pow(i,a)),t.fastCos=T,t.fastSin=t=>T(n-t),t.fit=(t,a,i,n,s)=>n+(s-n)*y(t,a,i),t.fit01=(t,a,i)=>a+(i-a)*O(t),t.fit10=(t,a,i)=>i+(a-i)*O(t),t.fit11=(t,a,i)=>a+(i-a)*(.5+.5*Q(t)),t.fitClamped=(t,a,i,n,s)=>n+(s-n)*O(y(t,a,i)),t.fmod=(t,a)=>t-a*Math.floor(t/a),t.foldback=(t,a)=>a<-t||a>t?Math.abs(Math.abs((a-t)%(4*t))-2*t)-t:a,t.fract=k,t.gain=(t,a)=>a<.5?.5*Math.pow(2*a,t):1-.5*Math.pow(2-2*a,t),t.impulse=(t,a)=>{const i=t*a;return i*Math.exp(1-i)},t.inOpenRange=(t,a,i)=>t>a&&t<i,t.inRange=(t,a,i)=>t>=a&&t<=i,t.isCrossOver=A,t.isCrossUnder=q,t.isMaxima=P,t.isMinima=H,t.loc=(t,a,i)=>Math.sqrt(t*t+a*a-2*t*a*Math.cos(i)),t.lshifti16=(t,a)=>G((0|t)<<(0|a)),t.lshifti32=(t,a)=>(0|t)<<(0|a),t.lshifti8=(t,a)=>j((0|t)<<(0|a)),t.lshiftu16=(t,a)=>(t&V)<<(a&V)&V,t.lshiftu32=(t,a)=>t>>>0<<(a>>>0)>>>0,t.lshiftu8=(t,a)=>(t&F)<<(a&F)&F,t.max2id=(t,a)=>t>=a?0:1,t.max3id=(t,a,i)=>t>=a?t>=i?0:2:a>=i?1:2,t.max4id=(t,a,i,n)=>t>=a?t>=i?t>=n?0:3:i>=n?2:3:a>=i?a>=n?1:3:i>=n?2:3,t.maximaIndex=(t,a=0,i=t.length)=>S(P,t,a,i),t.maximaIndices=(t,a=0,i=t.length)=>w(_,t,a,i),t.min2id=(t,a)=>t<=a?0:1,t.min3id=(t,a,i)=>t<=a?t<=i?0:2:a<=i?1:2,t.min4id=(t,a,i,n)=>t<=a?t<=i?t<=n?0:3:i<=n?2:3:a<=i?a<=n?1:3:i<=n?2:3,t.minError=X,t.minNonZero2=U,t.minNonZero3=(t,a,i)=>U(U(t,a),i),t.minimaIndex=_,t.minimaIndices=(t,a=0,i=t.length)=>w(_,t,a,i),t.mix=Z,t.mixBilinear=(t,a,i,n,s,r)=>Z(Z(t,a,s),Z(i,n,s),r),t.mixCubic=(t,a,i,n,s)=>{const r=s*s,e=1-s,o=e*e;return t*o*e+3*a*o*s+3*i*r*e+n*r*s},t.mixCubicHermite=(t,a,i,n,s)=>{const r=s-1,e=s*s,o=r*r;return(1+2*s)*o*t+s*o*a+e*(3-2*s)*i+e*r*n},t.mixHermite=(t,a,i,n,s)=>{const r=.5*(i-t),e=1.5*(a-i)+.5*(n-t);return((e*s+t-a+r-e)*s+r)*s+a},t.mixQuadratic=(t,a,i,n)=>{const s=1-n;return t*s*s+2*a*s*n+i*n*n},t.muli16=(t,a)=>G((0|t)*(0|a)),t.muli32=(t,a)=>(0|t)*(0|a)|0,t.muli8=(t,a)=>j((0|t)*(0|a)),t.mulu16=(t,a)=>(t&V)*(a&V)&V,t.mulu32=(t,a)=>(t>>>0)*(a>>>0)>>>0,t.mulu8=(t,a)=>(t&F)*(a&F)&F,t.norm=y,t.normCos=t=>{const a=t*t;return 1+a*(2*a-4)},t.noti16=t=>G(~t),t.noti32=t=>~t,t.noti8=t=>j(~t),t.notu16=t=>~t&V,t.notu32=t=>~t>>>0,t.notu8=t=>~t&F,t.ori16=(t,a)=>G(0|t|a),t.ori32=(t,a)=>0|t|a,t.ori8=(t,a)=>j(0|t|a),t.oru16=(t,a)=>(t&V|a&V)&V,t.oru32=(t,a)=>(t>>>0|a>>>0)>>>0,t.oru8=(t,a)=>(t&F|a&F)&F,t.parabola=(t,a)=>Math.pow(4*a*(1-a),t),t.quadrant=t=>g(t)*u|0,t.rad=t=>t*c,t.roundEps=(t,a=b)=>{const i=k(t);return i<=a||i>=1-a?Math.round(t):t},t.roundTo=(t,a=1)=>Math.round(t/a)*a,t.rshifti16=(t,a)=>G((0|t)>>(0|a)),t.rshifti32=(t,a)=>(0|t)>>(0|a),t.rshifti8=(t,a)=>j((0|t)>>(0|a)),t.rshiftu16=(t,a)=>(t&V)>>>(a&V)&V,t.rshiftu32=(t,a)=>t>>>0>>>(a>>>0)>>>0,t.rshiftu8=(t,a)=>(t&F)>>>(a&F)&F,t.safeDiv=(t,a)=>0!==a?t/a:0,t.sclamp=(t,a,i,n)=>L(N(t,a,n),i,n),t.sec=t=>1/Math.cos(t),t.sigmoid=(t,a)=>1/(1+Math.exp(-t*(2*a-1))),t.sigmoid11=(t,a)=>1/(1+Math.exp(-t*a)),t.sign=(t,a=b)=>t>a?1:t<-a?-1:0,t.signExtend16=G,t.signExtend8=j,t.simplifyRatio=(t,a)=>{let i=Math.abs(t),n=Math.abs(a);for(;;){if(i<n){const t=i;i=n,n=t}const s=i%n;if(!s)return[t/n,a/n];i=s}},t.sinc=(t,i)=>(i=a*(t*i-1),Math.sin(i)/i),t.sincos=(t,a=1)=>[Math.sin(t)*a,Math.cos(t)*a],t.smax=N,t.smin=L,t.smoothStep=(t,a,i)=>(3-2*(i=O((i-t)/(a-t))))*i*i,t.smootherStep=(t,a,i)=>(i=O((i-t)/(a-t)))*i*i*(i*(6*i-15)+10),t.solveCubic=(t,a,i,n,s=1e-9)=>{const r=t*t,e=a*a,o=a/(3*t),h=(3*t*i-e)/(3*r),u=(2*e*a-9*t*a*i+27*r*n)/(27*r*t);if(Math.abs(h)<s)return[Math.cbrt(-u)-o];if(Math.abs(u)<s)return h<0?[-Math.sqrt(-h)-o,-o,Math.sqrt(-h)-o]:[-o];{const t=u*u/4+h*h*h/27;if(Math.abs(t)<s)return[-1.5*u/h-o,3*u/h-o];if(t>0){const a=Math.cbrt(-u/2-Math.sqrt(t));return[a-h/(3*a)-o]}{const t=2*Math.sqrt(-h/3),a=Math.acos(3*u/h/t)/3,i=2*Math.PI/3;return[t*Math.cos(a)-o,t*Math.cos(a-i)-o,t*Math.cos(a-2*i)-o]}}},t.solveLinear=(t,a)=>-a/t,t.solveQuadratic=(t,a,i,n=1e-9)=>{const s=2*t;let r=a*a-4*t*i;return r<0?[]:r<n?[-a/s]:(r=Math.sqrt(r),[(-a-r)/s,(-a+r)/s])},t.step=(t,a)=>a<t?0:1,t.subi16=(t,a)=>G((0|t)-(0|a)),t.subi32=(t,a)=>(0|t)-(0|a)|0,t.subi8=(t,a)=>j((0|t)-(0|a)),t.subu16=(t,a)=>(t&V)-(a&V)&V,t.subu32=(t,a)=>(t>>>0)-(a>>>0)>>>0,t.subu8=(t,a)=>(t&F)-(a&F)&F,t.tangentCardinal=(t,a,i=.5,n=0,s=2)=>i*((a-t)/(s-n)),t.tangentDiff3=(t,a,i,n=0,s=1,r=2)=>.5*((i-a)/(r-s)+(a-t)/(s-n)),t.trunc=t=>t<0?Math.ceil(t):Math.floor(t),t.tween=(t,a,i)=>n=>Z(a,i,t(n)),t.wrap=(t,a,i)=>{if(a===i)return a;if(t>i){const n=i-a;(t-=n)>i&&(t-=n*((t-a)/n|0))}else if(t<a){const n=i-a;(t+=n)<a&&(t+=n*((a-t)/n+1|0))}return t},t.wrap01=t=>t<0?t+1:t>1?t-1:t,t.wrap11=t=>t<-1?t+2:t>1?t-2:t,t.wrapOnce=(t,a,i)=>t<a?t-a+i:t>i?t-i+a:t,t.xori16=(t,a)=>G((0|t)^(0|a)),t.xori32=(t,a)=>(0|t)^(0|a),t.xori8=(t,a)=>j((0|t)^(0|a)),t.xoru16=(t,a)=>(t&V^a&V)&V,t.xoru32=(t,a)=>(t>>>0^a>>>0)>>>0,t.xoru8=(t,a)=>(t&F^a&F)&F,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@thi.ng/math",
"version": "1.7.13",
"version": "2.0.0",
"description": "Assorted common math functions & utilities",

@@ -72,3 +72,3 @@ "module": "./index.js",

},
"gitHead": "af932be5734c03553f3a4df9b00cb45e061f3a53"
"gitHead": "ca21a57b0c9b12244dc501a160b7f70f2002d973"
}

@@ -49,3 +49,3 @@ <!-- This file is generated - DO NOT EDIT! -->

Package sizes (gzipped, pre-treeshake): ESM: 3.48 KB / CJS: 4.02 KB / UMD: 3.30 KB
Package sizes (gzipped, pre-treeshake): ESM: 3.49 KB / CJS: 4.04 KB / UMD: 3.32 KB

@@ -52,0 +52,0 @@ ## Dependencies

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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