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 2.1.1 to 2.2.0

11

CHANGELOG.md

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

# [2.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@2.1.1...@thi.ng/math@2.2.0) (2020-11-24)
### Features
* **math:** add generalized schlick curve ([4b6eb84](https://github.com/thi-ng/umbrella/commit/4b6eb844f3588679ee78d0e7d60b52cfcec8eb87))
## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@2.1.0...@thi.ng/math@2.1.1) (2020-09-22)

@@ -8,0 +19,0 @@

4

lib/index.js

@@ -354,2 +354,5 @@ 'use strict';

const sigmoid11 = (k, t) => 1 / (1 + Math.exp(-k * t));
const schlick = (a, b, t) => t <= b
? (b * t) / (t + a * (b - t) + EPS)
: ((1 - b) * (t - 1)) / (1 - t - a * (b - t) + EPS) + 1;
const expFactor = (a, b, num) => (b / a) ** (1 / num);

@@ -587,2 +590,3 @@

exports.safeDiv = safeDiv;
exports.schlick = schlick;
exports.sclamp = sclamp;

@@ -589,0 +593,0 @@ exports.sec = sec;

2

lib/index.umd.js

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

!function(t,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports):"function"==typeof define&&define.amd?define(["exports"],a):a(((t="undefined"!=typeof globalThis?globalThis: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,b=l/2;let p=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,T=t=>{const a=t*t;return.99940307+a*(.03679168*a-.49558072)},I=t=>{switch((t%=i)<0&&(t=-t),t*u|0){case 0:return T(t);case 1:return-T(a-t);case 2:return-T(t-a);default:return T(i-t)}},E=Math.abs,C=Math.max,D=(t,a,i=p)=>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)=>y(t,a,-i),y=(t,a,i)=>{const n=Math.exp(t*i),s=Math.exp(a*i);return(t*n+a*s)/(n+s)},N=(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=p)=>{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=1-t,Math.sqrt(1-t*t)),B=t=>1-k(1-t),W=t=>t-Math.floor(t),z=(t,a)=>0!==a?t/a:0;t.DEG2RAD=c,t.EPS=p,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=b,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=k,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=p)=>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=p)=>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=p)=>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=I,t.fastSin=t=>I(n-t),t.fit=(t,a,i,n,s)=>n+(s-n)*N(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(N(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=W,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.invCircular=B,t.isCrossOver=A,t.isCrossUnder=q,t.isMaxima=P,t.isMinima=H,t.lens=(t,a,i)=>{const n=a>0?B:k,s=1-t,r=i<=t?n(i/t)*t:1-n((1-i)/s)*s;return Z(i,r,Math.abs(a))},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=N,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=p)=>{const i=W(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=z,t.sclamp=(t,a,i,n)=>L(y(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=p)=>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=y,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)=>z(-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})}));
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(((t="undefined"!=typeof globalThis?globalThis: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,l=Math.SQRT2,f=Math.sqrt(3),m=l/2,b=f/2;let p=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,T=t=>{const i=t*t;return.99940307+i*(.03679168*i-.49558072)},I=t=>{switch((t%=a)<0&&(t=-t),t*u|0){case 0:return T(t);case 1:return-T(i-t);case 2:return-T(t-i);default:return T(a-t)}},E=Math.abs,C=Math.max,D=(t,i,a=p)=>E(t-i)<=a,v=D,A=(t,i,a,n)=>t<a&&i>n,q=(t,i,a,n)=>t>a&&i<n,H=(t,i,a)=>t>i&&i<a,P=(t,i,a)=>t<i&&i>a,S=(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},_=(t,i=0,a=t.length)=>S(H,t,i,a);function*w(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 O=t=>t<0?0:t>1?1:t,Q=t=>t<-1?-1:t>1?1:t,U=(t,i)=>0!==t?0!==i?Math.min(t,i):t:i,L=(t,i,a)=>y(t,i,-a),y=(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,F=255,V=65535,j=t=>128&(t&=F)?t|~F:t,k=t=>32768&(t&=V)?t|~V:t,G=(t,i,a,n=16,s=8,r=0,e=1,o=p)=>{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=1-t,Math.sqrt(1-t*t)),B=t=>1-Z(1-t),W=t=>t-Math.floor(t),z=(t,i)=>0!==i?t/i:0;t.DEG2RAD=c,t.EPS=p,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=l,t.SQRT2_2=m,t.SQRT2_3=b,t.SQRT3=f,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)=>k((0|t)+(0|i)),t.addi32=(t,i)=>(0|t)+(0|i)|0,t.addi8=(t,i)=>j((0|t)+(0|i)),t.addu16=(t,i)=>(t&V)+(i&V)&V,t.addu32=(t,i)=>(t>>>0)+(i>>>0)>>>0,t.addu8=(t,i)=>(t&F)+(i&F)&F,t.andi16=(t,i)=>k((0|t)&(0|i)),t.andi32=(t,i)=>(0|t)&(0|i),t.andi8=(t,i)=>j((0|t)&(0|i)),t.andu16=(t,i)=>t&V&i&V&V,t.andu32=(t,i)=>(t>>>0&i>>>0)>>>0,t.andu8=(t,i)=>t&F&i&F&F,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=Z,t.clamp=(t,i,a)=>t<i?i:t>a?a:t,t.clamp01=O,t.clamp05=t=>t<0?0:t>.5?.5:t,t.clamp11=Q,t.classifyCrossing=(i,a,n,s,r=p)=>A(i,a,n,s)?t.Crossing.OVER:q(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=p)=>a=>(t(a+i)-t(a))/i,t.divi16=(t,i)=>k((0|t)/(0|i)),t.divi32=(t,i)=>(0|t)/(0|i)|0,t.divi8=(t,i)=>j((0|t)/(0|i)),t.divu16=(t,i)=>(t&V)/(i&V)&V,t.divu32=(t,i)=>(t>>>0)/(i>>>0)>>>0,t.divu8=(t,i)=>(t&F)/(i&F)&F,t.ease=(t,i)=>Math.pow(i,t),t.eqDelta=D,t.eqDeltaFixed=v,t.eqDeltaScaled=(t,i,a=p)=>E(t-i)<=a*C(1,E(t),E(i)),t.expFactor=(t,i,a)=>(i/t)**(1/a),t.expStep=(t,i,a)=>1-Math.exp(-t*Math.pow(a,i)),t.fastCos=I,t.fastSin=t=>I(n-t),t.fit=(t,i,a,n,s)=>n+(s-n)*N(t,i,a),t.fit01=(t,i,a)=>i+(a-i)*O(t),t.fit10=(t,i,a)=>a+(i-a)*O(t),t.fit11=(t,i,a)=>i+(a-i)*(.5+.5*Q(t)),t.fitClamped=(t,i,a,n,s)=>n+(s-n)*O(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=W,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.invCircular=B,t.isCrossOver=A,t.isCrossUnder=q,t.isMaxima=P,t.isMinima=H,t.lens=(t,i,a)=>{const n=i>0?B:Z,s=1-t,r=a<=t?n(a/t)*t:1-n((1-a)/s)*s;return X(a,r,Math.abs(i))},t.loc=(t,i,a)=>Math.sqrt(t*t+i*i-2*t*i*Math.cos(a)),t.lshifti16=(t,i)=>k((0|t)<<(0|i)),t.lshifti32=(t,i)=>(0|t)<<(0|i),t.lshifti8=(t,i)=>j((0|t)<<(0|i)),t.lshiftu16=(t,i)=>(t&V)<<(i&V)&V,t.lshiftu32=(t,i)=>t>>>0<<(i>>>0)>>>0,t.lshiftu8=(t,i)=>(t&F)<<(i&F)&F,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)=>S(P,t,i,a),t.maximaIndices=(t,i=0,a=t.length)=>w(_,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=U,t.minNonZero3=(t,i,a)=>U(U(t,i),a),t.minimaIndex=_,t.minimaIndices=(t,i=0,a=t.length)=>w(_,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)=>k((0|t)*(0|i)),t.muli32=(t,i)=>(0|t)*(0|i)|0,t.muli8=(t,i)=>j((0|t)*(0|i)),t.mulu16=(t,i)=>(t&V)*(i&V)&V,t.mulu32=(t,i)=>(t>>>0)*(i>>>0)>>>0,t.mulu8=(t,i)=>(t&F)*(i&F)&F,t.norm=N,t.normCos=t=>{const i=t*t;return 1+i*(2*i-4)},t.noti16=t=>k(~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,i)=>k(0|t|i),t.ori32=(t,i)=>0|t|i,t.ori8=(t,i)=>j(0|t|i),t.oru16=(t,i)=>(t&V|i&V)&V,t.oru32=(t,i)=>(t>>>0|i>>>0)>>>0,t.oru8=(t,i)=>(t&F|i&F)&F,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=p)=>{const a=W(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)=>k((0|t)>>(0|i)),t.rshifti32=(t,i)=>(0|t)>>(0|i),t.rshifti8=(t,i)=>j((0|t)>>(0|i)),t.rshiftu16=(t,i)=>(t&V)>>>(i&V)&V,t.rshiftu32=(t,i)=>t>>>0>>>(i>>>0)>>>0,t.rshiftu8=(t,i)=>(t&F)>>>(i&F)&F,t.safeDiv=z,t.schlick=(t,i,a)=>a<=i?i*a/(a+t*(i-a)+p):(1-i)*(a-1)/(1-a-t*(i-a)+p)+1,t.sclamp=(t,i,a,n)=>L(y(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=p)=>t>i?1:t<-i?-1:0,t.signExtend16=k,t.signExtend8=j,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=y,t.smin=L,t.smoothStep=(t,i,a)=>(3-2*(a=O((a-t)/(i-t))))*a*a,t.smootherStep=(t,i,a)=>(a=O((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)=>z(-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)=>k((0|t)-(0|i)),t.subi32=(t,i)=>(0|t)-(0|i)|0,t.subi8=(t,i)=>j((0|t)-(0|i)),t.subu16=(t,i)=>(t&V)-(i&V)&V,t.subu32=(t,i)=>(t>>>0)-(i>>>0)>>>0,t.subu8=(t,i)=>(t&F)-(i&F)&F,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)=>k((0|t)^(0|i)),t.xori32=(t,i)=>(0|t)^(0|i),t.xori8=(t,i)=>j((0|t)^(0|i)),t.xoru16=(t,i)=>(t&V^i&V)&V,t.xoru32=(t,i)=>(t>>>0^i>>>0)>>>0,t.xoru8=(t,i)=>(t&F^i&F)&F,Object.defineProperty(t,"__esModule",{value:!0})}));

@@ -116,2 +116,3 @@ import type { FnN, FnN2, FnN3, FnN4, FnN5, FnN6 } from "@thi.ng/api";

*
* @remarks
* Reference: https://www.desmos.com/calculator/tisoiazdrw

@@ -125,2 +126,3 @@ *

*
* @remarks
* Reference: https://www.desmos.com/calculator/tisoiazdrw

@@ -141,2 +143,4 @@ *

*
* Also see {@link schlick} for an alternative approach.
*
* @example

@@ -197,2 +201,15 @@ * ```ts

/**
* Generalized Schlick bias gain curve, based on:
* https://arxiv.org/abs/2010.09714
*
* @remarks
* Interactive graph:
* https://www.desmos.com/calculator/u6bkm5rb7t
*
* @param a - curve strength. recommended (0..64]
* @param b - pivot position [0..1]
* @param t - input val [0..1]
*/
export declare const schlick: FnN3;
/**
* Computes exponential factor to interpolate from `a` to `b` over

@@ -199,0 +216,0 @@ * `num` steps. I.e. multiplying `a` with the returned factor will yield

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

import { HALF_PI, PI } from "./api";
import { EPS, HALF_PI, PI } from "./api";
export const mix = (a, b, t) => a + (b - a) * t;

@@ -137,2 +137,3 @@ /**

*
* @remarks
* Reference: https://www.desmos.com/calculator/tisoiazdrw

@@ -149,2 +150,3 @@ *

*
* @remarks
* Reference: https://www.desmos.com/calculator/tisoiazdrw

@@ -165,2 +167,4 @@ *

*
* Also see {@link schlick} for an alternative approach.
*
* @example

@@ -238,2 +242,17 @@ * ```ts

/**
* Generalized Schlick bias gain curve, based on:
* https://arxiv.org/abs/2010.09714
*
* @remarks
* Interactive graph:
* https://www.desmos.com/calculator/u6bkm5rb7t
*
* @param a - curve strength. recommended (0..64]
* @param b - pivot position [0..1]
* @param t - input val [0..1]
*/
export const schlick = (a, b, t) => t <= b
? (b * t) / (t + a * (b - t) + EPS)
: ((1 - b) * (t - 1)) / (1 - t - a * (b - t) + EPS) + 1;
/**
* Computes exponential factor to interpolate from `a` to `b` over

@@ -240,0 +259,0 @@ * `num` steps. I.e. multiplying `a` with the returned factor will yield

{
"name": "@thi.ng/math",
"version": "2.1.1",
"version": "2.2.0",
"description": "Assorted common math functions & utilities",

@@ -42,13 +42,13 @@ "module": "./index.js",

"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@microsoft/api-extractor": "^7.9.11",
"@microsoft/api-extractor": "^7.12.0",
"@types/mocha": "^8.0.3",
"@types/node": "^14.6.1",
"mocha": "^8.1.2",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"ts-node": "^9.0.0",
"typedoc": "^0.18.0",
"typescript": "^4.0.2"
"typedoc": "^0.19.2",
"typescript": "^4.1.2"
},
"dependencies": {
"@thi.ng/api": "^6.13.1"
"@thi.ng/api": "^6.13.2"
},

@@ -61,2 +61,4 @@ "files": [

"keywords": [
"animation",
"bezier",
"cubic",

@@ -77,3 +79,6 @@ "hermite",

"sideEffects": false,
"gitHead": "130dff672b56f789205177c2243169d33d479948"
"thi.ng": {
"year": 2013
},
"gitHead": "3a89bdfa4c58983d5e005b3e9fb056b0351198fe"
}

@@ -12,2 +12,4 @@ <!-- This file is generated - DO NOT EDIT! -->

For the Clojure version, please visit: [thi.ng/math-clj](https://thi.ng/math-clj)
- [About](#about)

@@ -28,4 +30,5 @@ - [Status](#status)

Partially ported from Clojure version of
[thi.ng/math](https://github.com/thi-ng/math) and
Partially ported from Clojure version
[thi.ng/math-clj](https://github.com/thi-ng/math),
[c.thi.ng](https://github.com/thi-ng/c-thing) and
[thi.ng/vexed-generation](https://github.com/thi-ng/vexed-generation).

@@ -53,3 +56,3 @@

Package sizes (gzipped, pre-treeshake): ESM: 3.56 KB / CJS: 4.12 KB / UMD: 3.40 KB
Package sizes (gzipped, pre-treeshake): ESM: 3.60 KB / CJS: 4.16 KB / UMD: 3.43 KB

@@ -97,2 +100,2 @@ ## Dependencies

&copy; 2016 - 2020 Karsten Schmidt // Apache Software License 2.0
&copy; 2013 - 2020 Karsten Schmidt // Apache Software License 2.0

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