From 6c7192f5b2b8582118a44a3de722cdff01e0f500 Mon Sep 17 00:00:00 2001 From: Miriam Zusin Date: Tue, 23 Apr 2024 13:46:32 +0300 Subject: [PATCH] factorial and combination --- dist/index.d.ts | 1 + dist/mz-math.esm.js | 4 +-- dist/mz-math.esm.js.map | 6 ++-- dist/mz-math.min.js | 4 +-- dist/mz-math.min.js.map | 6 ++-- dist/mz-math.node.cjs | 4 +-- dist/mz-math.node.cjs.map | 6 ++-- src/main/combinatorics/combinatorics.ts | 26 +++++++++++++++-- test/combinatorics.test.ts | 39 ++++++++++++++++++++++++- 9 files changed, 77 insertions(+), 19 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 092a139..4eb13d1 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -381,4 +381,5 @@ declare module 'mz-math' { export const permutationsWithRepetition: (n: number, r: number) => number; export const permutationsWithoutRepetition: (n: number, r: number) => number; export const combinationsWithoutRepetition: (n: number, r: number) => number; + export const combinationsWithRepetition: (n: number, r: number) => number; } \ No newline at end of file diff --git a/dist/mz-math.esm.js b/dist/mz-math.esm.js index 3f3c06c..314e2ae 100644 --- a/dist/mz-math.esm.js +++ b/dist/mz-math.esm.js @@ -5,10 +5,10 @@ https://github.com/mzusin/mz-math Licensed GPLv3 for open source use, or Commercial License for commercial use - https://github.com/mzusin/index/blob/main/LICENSE.md Copyright (c) 2023-present, Miriam Zusin */ -var h=Math.pow;var s=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=h(10,r);return Math.round(t*e)/e};var d=(t,r)=>(t%r+r)%r,O=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Vr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),E=t=>!isNaN(parseFloat(t))&&isFinite(t),lr=(t,r,e,n=1/0)=>{let[o,i]=t,[c,u]=r;return[s(o+c*Math.cos(e),n),s(i+u*Math.sin(e),n)]};var T=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return s(e,r)},vr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return s(n,e)},K=(t,r,e=1/0)=>{let n=P(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},wr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},Sr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},At=(t,r,e=1/0)=>{let n=H(t),o=H(r),i=w(n,o),c=Math.acos(i);return s(c,e)},Rr=(t,r,e=1/0)=>{let n=I(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},zr=(t,r,e=1/0)=>At(t,r,e),Br=(t,r,e)=>{let n=F(r,e),o=F(r,t),i=F(e,t),c=o+i;return Math.abs(c-n)<=.001},J=(t,r,e=0)=>(t=t%360,r=r%360,t=t),F=(t,r,e=1/0)=>{let n=Math.abs(d(t,360)-d(r,360));return s(n<=180?n:360-n,e)},qt=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=qt(r,e,n);return J(r,e,n)?d(n+t*o/100,360):d(n-t*o/100,360)};var q=(t,r,e=1/0)=>{let n=[];for(let o=0;oq(t,r,e),$r=(t,r,e=1/0)=>q(t,r,e),I=(t,r,e=1/0)=>{let n=[];for(let o=0;oI(t,r,e),Ar=(t,r,e=1/0)=>I(t,r,e),C=(t,r,e=1/0)=>{let n=[];for(let o=0;oC(t,r,e),k=(t,r,e=1/0)=>C(t,r,e),D=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oD(t,r,e),Dr=(t,r,e=1/0)=>D(t,r,e),z=(t,r=1/0)=>{let e=0;for(let n=0;nz(t,r),Xr=(t,r=1/0)=>z(t,r),Ct=(t,r,e=1/0)=>{let n=T(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Yr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},jr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},Gr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},H=(t,r=1/0)=>{let e=z(t),n=[];for(let o=0;oH(t,r),v=(t,r=1/0)=>H(t,r),w=(t,r,e=1/0)=>{let n=0;for(let o=0;ow(t,r,e),Or=(t,r,e=1/0)=>w(t,r,e),Fr=(t,r,e=1/0)=>[s(t[1]*r[2]-t[2]*r[1],e),s(t[2]*r[0]-t[0]*r[2],e),s(t[0]*r[1]-t[1]*r[0],e)],kr=(t=0)=>[t,t],Qr=(t=0)=>[t,t,t],Zr=(t=0)=>[t,t,t,t],rt=(t,r=0)=>{if(t<0)throw new Error("N must be a non-negative number.");let e=[];for(let n=0;n{let e=[0,0];return e=Ct(e,t),K(e,r)},et=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=R(r,t);return[-s(n[1],e),s(n[0],e)]};var ot=(t,r,e=1/0)=>{let n=[];for(let o=0;oot(t,r,e),Jr=(t,r,e=1/0)=>ot(t,r,e),it=(t,r,e=1/0)=>{let n=[];for(let o=0;oit(t,r,e),te=(t,r,e=1/0)=>it(t,r,e),ct=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(C(o,r,e));return n},re=(t,r,e=1/0)=>ct(t,r,e),ee=(t,r,e=1/0)=>ct(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(D(o,r,e));return n},Dt=(t,r,e=1/0)=>Q(t,r,e),ne=(t,r,e=1/0)=>Q(t,r,e),X=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oX(t),ie=t=>X(t),st=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nst(t,r),se=(t,r=0)=>st(t,r),ue=(t=0)=>[[t,t],[t,t]],xe=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],me=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],ae=(t,r,e=0)=>{if(t<=0||r<=0)throw new Error("M and N must be positive numbers.");let n=[];for(let o=0;o[[1,0],[0,1]],pe=()=>[[1,0,0],[0,1,0],[0,0,1]],be=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],he=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;ey(t),xt=t=>y(t),Me=(t,r)=>{if(t.length<=0)return[];let e=y(t);for(let n=0;n{if(t.length<=0)return[];let e=y(t);for(let n=0;n{let e=y(t);return e.push(r),e},de=(t,r)=>{let e=ut(t);return e.push(r),e},ye=(t,r)=>{let e=xt(t);return e.push(r),e},Ie=(t,r)=>{let e=y(t);return e.unshift(r),e},ge=(t,r)=>{let e=ut(t);return e.unshift(r),e},ve=(t,r)=>{let e=xt(t);return e.unshift(r),e},we=t=>{if(t.length<=0)return[];let r=y(t);return r.pop(),r},Se=t=>{if(t.length<=0)return[];let r=y(t);return r.shift(),r},mt=t=>{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=Xt(t,r,e);return Y(o)},Y=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return pt(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},He=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(t)},bt=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},Te=t=>ht(t),ht=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return bt(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(t)===0},Mt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=pt(t);if(e===0)return null;let n=bt(t);return n===null?null:Dt(n,e,r)},Vt=(t,r=1/0)=>Z(t,r),Z=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=Y(t),o=ht(t);return o===null?null:Q(o,n,r)};var Ce=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1];return`matrix(${r}, ${e}, ${n}, ${o}, 0, 0)`},De=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],c=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${c})`},Xe=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],c=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${c}, 0, 1)`},Ye=t=>`matrix3d( +var h=Math.pow;var c=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=h(10,r);return Math.round(t*e)/e};var d=(t,r)=>(t%r+r)%r,O=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Vr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),E=t=>!isNaN(parseFloat(t))&&isFinite(t),lr=(t,r,e,n=1/0)=>{let[o,i]=t,[s,u]=r;return[c(o+s*Math.cos(e),n),c(i+u*Math.sin(e),n)]};var T=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return c(e,r)},vr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return c(n,e)},K=(t,r,e=1/0)=>{let n=P(t);return[c(Math.cos(r)*n,e),c(Math.sin(r)*n,e)]},wr=(t,r=1/0)=>{let e=t*(180/Math.PI);return c(e,r)},Sr=(t,r=1/0)=>{let e=t*(Math.PI/180);return c(e,r)},$t=(t,r,e=1/0)=>{let n=H(t),o=H(r),i=w(n,o),s=Math.acos(i);return c(s,e)},Rr=(t,r,e=1/0)=>{let n=I(t,r),o=Math.atan2(n[1],n[0]);return c(o,e)},zr=(t,r,e=1/0)=>$t(t,r,e),Br=(t,r,e)=>{let n=F(r,e),o=F(r,t),i=F(e,t),s=o+i;return Math.abs(s-n)<=.001},J=(t,r,e=0)=>(t=t%360,r=r%360,t=t),F=(t,r,e=1/0)=>{let n=Math.abs(d(t,360)-d(r,360));return c(n<=180?n:360-n,e)},qt=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=qt(r,e,n);return J(r,e,n)?d(n+t*o/100,360):d(n-t*o/100,360)};var q=(t,r,e=1/0)=>{let n=[];for(let o=0;oq(t,r,e),Lr=(t,r,e=1/0)=>q(t,r,e),I=(t,r,e=1/0)=>{let n=[];for(let o=0;oI(t,r,e),$r=(t,r,e=1/0)=>I(t,r,e),C=(t,r,e=1/0)=>{let n=[];for(let o=0;oC(t,r,e),k=(t,r,e=1/0)=>C(t,r,e),D=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oD(t,r,e),Dr=(t,r,e=1/0)=>D(t,r,e),z=(t,r=1/0)=>{let e=0;for(let n=0;nz(t,r),Xr=(t,r=1/0)=>z(t,r),Ct=(t,r,e=1/0)=>{let n=T(t);return[c(Math.cos(n)*r,e),c(Math.sin(n)*r,e)]},Yr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},jr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},Gr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},H=(t,r=1/0)=>{let e=z(t),n=[];for(let o=0;oH(t,r),v=(t,r=1/0)=>H(t,r),w=(t,r,e=1/0)=>{let n=0;for(let o=0;ow(t,r,e),Or=(t,r,e=1/0)=>w(t,r,e),Fr=(t,r,e=1/0)=>[c(t[1]*r[2]-t[2]*r[1],e),c(t[2]*r[0]-t[0]*r[2],e),c(t[0]*r[1]-t[1]*r[0],e)],kr=(t=0)=>[t,t],Qr=(t=0)=>[t,t,t],Wr=(t=0)=>[t,t,t,t],rt=(t,r=0)=>{if(t<0)throw new Error("N must be a non-negative number.");let e=[];for(let n=0;n{let e=[0,0];return e=Ct(e,t),K(e,r)},et=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=R(r,t);return[-c(n[1],e),c(n[0],e)]};var ot=(t,r,e=1/0)=>{let n=[];for(let o=0;oot(t,r,e),Jr=(t,r,e=1/0)=>ot(t,r,e),it=(t,r,e=1/0)=>{let n=[];for(let o=0;oit(t,r,e),te=(t,r,e=1/0)=>it(t,r,e),st=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(C(o,r,e));return n},re=(t,r,e=1/0)=>st(t,r,e),ee=(t,r,e=1/0)=>st(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(D(o,r,e));return n},Dt=(t,r,e=1/0)=>Q(t,r,e),ne=(t,r,e=1/0)=>Q(t,r,e),X=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oX(t),ie=t=>X(t),ct=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nct(t,r),ce=(t,r=0)=>ct(t,r),ue=(t=0)=>[[t,t],[t,t]],me=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],xe=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],ae=(t,r,e=0)=>{if(t<=0||r<=0)throw new Error("M and N must be positive numbers.");let n=[];for(let o=0;o[[1,0],[0,1]],pe=()=>[[1,0,0],[0,1,0],[0,0,1]],be=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],he=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;ey(t),mt=t=>y(t),Me=(t,r)=>{if(t.length<=0)return[];let e=y(t);for(let n=0;n{if(t.length<=0)return[];let e=y(t);for(let n=0;n{let e=y(t);return e.push(r),e},de=(t,r)=>{let e=ut(t);return e.push(r),e},ye=(t,r)=>{let e=mt(t);return e.push(r),e},Ie=(t,r)=>{let e=y(t);return e.unshift(r),e},ge=(t,r)=>{let e=ut(t);return e.unshift(r),e},ve=(t,r)=>{let e=mt(t);return e.unshift(r),e},we=t=>{if(t.length<=0)return[];let r=y(t);return r.pop(),r},Se=t=>{if(t.length<=0)return[];let r=y(t);return r.shift(),r},xt=t=>{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=Xt(t,r,e);return Y(o)},Y=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return pt(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},He=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(t)},bt=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},Te=t=>ht(t),ht=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return bt(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(t)===0},Mt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=pt(t);if(e===0)return null;let n=bt(t);return n===null?null:Dt(n,e,r)},Vt=(t,r=1/0)=>W(t,r),W=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=Y(t),o=ht(t);return o===null?null:Q(o,n,r)};var Ce=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1];return`matrix(${r}, ${e}, ${n}, ${o}, 0, 0)`},De=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${s})`},Xe=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${s}, 0, 1)`},Ye=t=>`matrix3d( ${t[0][0]}, ${t[0][1]}, ${t[0][2]}, ${t[0][3]}, ${t[1][0]}, ${t[1][1]}, ${t[1][2]}, ${t[1][3]}, ${t[2][0]}, ${t[2][1]}, ${t[2][2]}, ${t[2][3]}, ${t[3][0]}, ${t[3][1]}, ${t[3][2]}, ${t[3][3]} - )`,je=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Ge=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[s(t[0],r),s(t[1],r),s(t[2],r)]],j=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],Oe=(t,r=1/0)=>[[1,0,0,s(t[0],r)],[0,1,0,s(t[1],r)],[0,0,1,s(t[2],r)],[0,0,0,1]],Yt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},lt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},jt=(t,r,e=!0,n=1/0)=>{let o=j(r,n),i=lt(t,e,n),c=j(k(r,-1),n),u=L(o,i);return L(u,c)},Fe=(t,r,e,n=!0,o=1/0)=>{let i=jt(t,r,n,o);return M(i,e)},ke=(t,r,e=!0,n=1/0)=>{let o=N(r);return M(Yt(t,e,n),o)},Qe=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(lt(t,e,n),o)},Gt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},Ze=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[1,0,0,0],[0,n,-o,0],[0,o,n,0],[0,0,0,1]]:[[1,0,0,0],[0,n,o,0],[0,-o,n,0],[0,0,0,1]]},We=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(Gt(t,e,n),o)},Ot=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},_e=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},Ue=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(Ot(t,e,n),o)},Ft=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Ke=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0,0],[o,n,0,0],[0,0,1,0],[0,0,0,1]]:[[n,o,0,0],[-o,n,0,0],[0,0,1,0],[0,0,0,1]]},Je=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(Ft(t,e,n),o)},kt=(t,r,e=1/0)=>{let n=j(r,e),o=Zt(t),i=j(k(r,-1),e),c=L(n,o);return L(c,i)},Pe=(t,r,e,n=1/0)=>{let o=kt(t,r,n);return M(o,e)},Qt=t=>[[t[0],0],[0,t[1]]],tn=(t,r)=>M(Qt(t),r),Zt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Wt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],rn=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],en=(t,r)=>M(Wt(t),r),nn=t=>[[t,0],[0,1]],on=t=>[[t,0,0],[0,1,0],[0,0,1]],cn=t=>[[t,0,0],[0,1,0],[0,0,1]],sn=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],un=t=>[[1,0,0],[0,t,0],[0,0,1]],xn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],mn=t=>[[1,0,0],[0,1,0],[0,0,t]],an=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],fn=t=>[[1,0],[0,t]],pn=t=>[[1,0,0],[0,t,0],[0,0,1]],bn=()=>[[-1,0],[0,-1]],hn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],Mn=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],Vn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],ln=()=>[[0,-1],[-1,0]],dn=()=>[[1,0],[0,-1]],yn=()=>[[1,0,0],[0,-1,0],[0,0,1]],In=()=>[[-1,0],[0,1]],gn=()=>[[-1,0,0],[0,1,0],[0,0,1]],vn=()=>[[-1,0,0],[0,1,0],[0,0,1]],wn=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Sn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Rn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],zn=()=>[[1,0,0],[0,1,0],[0,0,-1]],Bn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],En=t=>[[1,t],[0,1]],Hn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),_t=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Ln=()=>Math.random()<.5,$n=t=>{let r=_t(0,t.length-1);return t[r]};var qn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Xn=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],c=o[1];n+=i*c*Math.pow(t,c-1)}return s(n,e)},dt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},yt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},It=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},gt=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+m*o[2],i)]},Yn=(t,r=1/0)=>s(Math.cos(t),r),jn=(t,r=1/0)=>s(-Math.sin(t),r),Gn=(t,r=1/0)=>s(1/h(Math.cos(t),2),r),On=(t,r=1/0)=>s(-1/h(Math.sin(t),2),r),Fn=(t,r=1/0)=>s(1/Math.sqrt(1-h(t,2)),r),kn=(t,r=1/0)=>s(-1/Math.sqrt(1-h(t,2)),r),Qn=(t,r=1/0)=>s(1/(1+h(t,2)),r),Zn=(t,r=1/0)=>s(-1/(1+h(t,2)),r);var $=(t,r=1/0)=>{let e=t[0],n=t[1],i=t[2]-n;return e===0&&i===0?1/0:e===0?NaN:s(i/e,r)},Pn=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=Mt(n);if(o===null)return null;let i=[t[2],r[2]];return M(o,i,e)},to=(t,r,e,n=1/0)=>{let o=[[t[0],t[1],t[2]],[r[0],r[1],r[2]],[e[0],e[1],e[2]]],i=Vt(o);if(i===null)return null;let c=[t[3],r[3],e[3]];return M(i,c,n)},ro=(t,r=1/0)=>{if(t.length<=0)return null;let e=mt(t),n=Z(e);if(n===null)return null;let o=at(t);return M(n,o,r)},eo=(t,r)=>{let[e,n]=R(r,t),[o,i]=t;if(e===0)return{slope:void 0,xIntercept:o,yIntercept:void 0,formula:`x = ${o}`};let c=n/e,u=i-c*o,x="";return c===0?x=`y = ${u}`:(x=`y = ${c===1?"":c}x`,u!==0&&(x+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:c,xIntercept:void 0,yIntercept:u,formula:x}};var W=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=$([n,o,i],r);return E(f)?[f]:[]}let c=o-i,u=n*n-4*e*c;if(u<0)return[];if(u===0)return[s(-n/(2*e),r)];let x=2*e,m=Math.sqrt(u);return[s((-n+m)/x,r),s((-n-m)/x,r)]};var Ut=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},bo=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},Kt=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,x=(1-t)*3*t*t,m=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},ho=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,x=(1-t)*3*t*t,m=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+m*o[2],i)]},Jt=(t,r,e,n,o=1/0)=>{let i=dt(t,r,e,n);return N(i,o)},Mo=(t,r,e,n,o=1/0)=>{let i=yt(t,r,e,n);return v(i,o)},Pt=(t,r,e,n,o,i=1/0)=>{let c=It(t,r,e,n,o);return N(c,i)},Vo=(t,r,e,n,o,i=1/0)=>{let c=gt(t,r,e,n,o);return v(c,i)},lo=(t,r,e,n,o=1/0)=>{let i=Jt(t,r,e,n,o);return[-i[1],i[0]]},yo=(t,r,e,n,o,i=1/0)=>{let c=Pt(t,r,e,n,o,i);return[-c[1],c[0]]},tr=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=$([o,i,0],n),x=2*t[1]-4*r[1]+2*e[1],m=-2*t[1]+2*r[1],p=$([x,m,0],n),a=[];return E(u)&&a.push(u),E(p)&&a.push(p),a},rr=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],c=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],x=[i,c,u,0],m=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[m,f,p,0],b=W(x,o).filter(l=>l>=0&&l<=1),g=W(a,o).filter(l=>l>=0&&l<=1);return[...b,...g].length===2?[...b,...g]:null},Io=(t,r,e,n=1/0)=>{let o=tr(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=Ut(m,t,r,e),p=f[0],a=f[1];i=Math.min(i,p),u=Math.max(u,p),c=Math.min(c,a),x=Math.max(x,a)}return i=s(Math.min(i,t[0],e[0]),n),u=s(Math.max(u,t[0],e[0]),n),c=s(Math.min(c,t[1],e[1]),n),x=s(Math.max(x,t[1],e[1]),n),{x:i,y:c,w:Math.abs(u-i),h:Math.abs(x-c),x2:u,y2:x}},go=(t,r,e,n,o=1/0)=>{let i=rr(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=Kt(f,t,r,e,n),a=p[0],b=p[1];c=Math.min(c,a!=null?a:1/0),x=Math.max(x,a!=null?a:-1/0),u=Math.min(u,b!=null?b:1/0),m=Math.max(m,b!=null?b:-1/0)}return c=s(Math.min(c,t[0],n[0]),o),x=s(Math.max(x,t[0],n[0]),o),u=s(Math.min(u,t[1],n[1]),o),m=s(Math.max(m,t[1],n[1]),o),{x:c,y:u,w:Math.abs(x-c),h:Math.abs(m-u),x2:x,y2:m}};var er=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),zo=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),er(r,o,e)},nr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),Bo=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),nr(r,o,e[0],e[1])},Eo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},Ho=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Ao=()=>{let t=wt();return sr(t)},qo=()=>{let t=wt();return ur(t)},wt=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Co=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},Do=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Xo=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Yo=()=>[0,0,V(0,100)],jo=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let c=V(t,r),u=V(e,n),x=V(o,i);return[c,u,x]},or=t=>(t*=60,t<0&&(t+=360),t),ir=(t,r,e,n=void 0,o=void 0)=>{if(n=n===void 0?Math.min(t,r,e):n,o=o===void 0?Math.max(t,r,e):o,n===o)return 0;let i=o-n,c=0;return o===t&&(c=(r-e)/i+(r(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,(n+o)/2*100),cr=(t,r,e,n=void 0,o=void 0,i=void 0)=>(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,n===o?0:(i=i===void 0?St(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),Go=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255,i=Math.min(e,n,o),c=Math.max(e,n,o),u=St(e,n,o,i,c),x=cr(e,n,o,i,c,u),m=ir(e,n,o,i,c);return m>360||x>100||u>100?[0,0,100]:m<0||x<0||u<0?[0,0,0]:[s(m,r),s(x,r),s(u,r)]},_=(t,r,e)=>(e<0&&(e+=1),e>1&&(e-=1),e*6<1?r+(t-r)*6*e:e*2<1?t:e*3<2?r+(t-r)*(.666-e)*6:r),sr=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let b=o*255;return[b,b,b]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,m=e-.333,f=_(i,c,u),p=_(i,c,x),a=_(i,c,m);return f*=255,p*=255,a*=255,f>255||p>255||a>255?[255,255,255]:f<0||p<0||a<0?[0,0,0]:[s(f,r),s(p,r),s(a,r)]},ur=t=>{if(t[0]>360||t[1]>100||t[2]>100)return"#ffffff";if(t[0]<0||t[1]<0||t[2]<0)return"#000000";let r=t[0]/360,e=t[1]/100,n=t[2]/100,o,i,c;if(e===0)o=i=c=n;else{let x=(p,a,b)=>(b<0&&(b+=1),b>1&&(b-=1),b<.16666666666666666?p+(a-p)*6*b:b<.5?a:b<.6666666666666666?p+(a-p)*(.6666666666666666-b)*6:p),m=n<.5?n*(1+e):n+e-n*e,f=2*n-m;o=x(f,m,r+1/3),i=x(f,m,r),c=x(f,m,r-1/3)}let u=x=>{let m=Math.round(x*255).toString(16);return m.length===1?"0"+m:m};return`#${u(o)}${u(i)}${u(c)}`},Oo=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Fo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,m,f)=>x+x+m+m+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),c=parseInt(n[3],16);return[o,i,c]},vt=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;let i=(e*.4124+n*.3576+o*.1805)/.95047,c=(e*.2126+n*.7152+o*.0722)/1,u=(e*.0193+n*.1192+o*.9505)/1.08883;return i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,c=c>.008856?Math.pow(c,1/3):7.787*c+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,[s(116*c-16,r),s(500*(i-c),r),s(200*(c-u),r)]},ko=(t,r=1/0)=>{let e=(t[0]+16)/116,n=t[1]/500+e,o=e-t[2]/200;n=.95047*(n*n*n>.008856?n*n*n:(n-16/116)/7.787),e=1*(e*e*e>.008856?e*e*e:(e-16/116)/7.787),o=1.08883*(o*o*o>.008856?o*o*o:(o-16/116)/7.787);let i=n*3.2406+e*-1.5372+o*-.4986,c=n*-.9689+e*1.8758+o*.0415,u=n*.0557+e*-.204+o*1.057;return i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,c=c>.0031308?1.055*Math.pow(c,1/2.4)-.055:12.92*c,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:12.92*u,[s(Math.max(0,Math.min(1,i))*255,r),s(Math.max(0,Math.min(1,c))*255,r),s(Math.max(0,Math.min(1,u))*255,r)]},Qo=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=d(e,360)),[e,t[1],t[2]]},Zo=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=d(e,100)),[t[0],t[1],e]},Wo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},_o=(t,r,e=1/0)=>{let n=vt(t,e),o=vt(r,e),i=n[0]-o[0],c=n[1]-o[1],u=n[2]-o[2],x=Math.sqrt(n[1]*n[1]+n[2]*n[2]),m=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=x-m,p=c*c+u*u-f*f;p=p<0?0:Math.sqrt(p);let a=1+.045*x,b=1+.015*x,g=i/1,B=f/a,l=p/b,A=g*g+B*B+l*l;return A<0?0:Math.sqrt(A)};var Ko=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),Jo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var ei=(t,r)=>t.x<=r.x+r.w&&t.x+t.w>=r.x&&t.y<=r.y+r.h&&t.h+t.y>=r.y,ni=(t,r)=>{let e=Math.abs(t.cx-r.cx),n=Math.abs(t.cy-r.cy);return Math.sqrt(e*e+n*n)<=t.r+r.r},Rt=t=>{let r=[];for(let e=0;e{let e=[];e.push(...Rt(t)),e.push(...Rt(r));for(let n of e){let o=nt(n[0],n[1]),i=zt(t,o),c=zt(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},zt=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=tt(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var ci=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,c=!1,u,x=()=>{e=void 0,o=void 0,i=void 0,c=!1,n!==void 0&&window.cancelAnimationFrame(n)},m=()=>{x(),g()},f=()=>{c=!1},p=()=>{c=!0},a=S=>{e===void 0&&(e=S),o=S-e,c&&i!==S&&typeof t.callback=="function"&&t.callback(U()),o<=r?(i=S,n=window.requestAnimationFrame(a)):x()},b=(S,$t)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(S,$t)},g=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(b),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(a)},B=()=>o,l=()=>c,A=()=>e,Nt=()=>{if(!(r===1/0||o===void 0))return o*100/r},Lt=()=>u,U=()=>({start:g,stop:x,pause:f,resume:p,restart:m,isAnimating:l,getElapsedTime:B,getStartTime:A,getPercent:Nt,getResizeObserver:Lt});return U()};var xi=(t,r=1/0)=>s(2*Math.PI*t,r),mi=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),ai=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),fi=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var hi=t=>t*(t+1)/2,Mi=(t,r,e)=>t/2*(2*r+(t-1)*e);var G=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return s(e/t.length,r)},di=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return s(e,r)},yi=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=[...t].sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?s((e[n]+e[n-1])/2,r):s(e[n],r)},Ii=t=>{if(!t||t.length<=0)return;let r=new Map;for(let o of t)r.set(o,(r.get(o)||0)+1);let e=0,n=[];for(let[o,i]of r)i>e?(e=i,n=[o]):i===e&&n.push(o);if(n.length!==t.length)return n.length===1?[n[0]]:n},gi=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return s(n/t.length,r)},xr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i,2),0);return s(n/t.length-h(e,2),r)},Bt=(t,r=1/0)=>{var n;let e=(n=xr(t))!=null?n:0;return s(Math.sqrt(e),r)};var mr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:s((t-r)/o,n)},Et=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Et(t,e,n,r);return{min:s(e,r),max:s(n,r),data:o}},Bi=(t,r,e,n=1/0)=>Et(t,r,e,n),ar=(t,r,e,n=1/0)=>e===0?0:s((t-r)/e,n),Ht=(t,r,e,n=1/0)=>[...t].map(o=>ar(o,r,e,n)),Ei=(t,r=1/0)=>{var i;let e=(i=G(t))!=null?i:0,n=Bt(t),o=Ht(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}},Hi=(t,r,e,n=1/0)=>Ht(t,r,e,n);var Ni=t=>t/2*(t+1),Li=(t,r)=>(r-t+1)*(t+r)/2;var Ai=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=1;for(let n=r;n<=t;n++)e*=n;return e},fr=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}return t===r?r:t*fr(t-1,r)},qi=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=new Map,n=(o,i)=>{var u;if(o{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===t)return t===0?1:t;r===0&&(r=1);let e=[];e[0]=1;for(let n=1;n<=t;n++)e[n]=e[n-1]*n;return e[t]/e[r-1]};var Xi=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return h(t,r)},Yi=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return Tt(t,t-r+1)},ji=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");let e=Array.from({length:t+1},()=>Array(r+1).fill(0));for(let n=0;n<=t;n++)e[n][0]=1,n<=r&&(e[n][n]=1);for(let n=1;n<=t;n++)for(let o=1;o<=Math.min(n,r);o++)e[n][o]=e[n-1][o-1]+e[n-1][o];return e[t][r]};export{ci as animate,Mi as arithmeticSequenceSum,ni as circleCollide,er as circleMovement,zo as circleMovementAfterMouse,ji as combinationsWithoutRepetition,O as convertRange,oi as convexPolygonsCollide,Sr as degreesToRadians,Vr as doRangesOverlap,kn as dxArcCos,Zn as dxArcCot,Fn as dxArcSin,Qn as dxArcTan,jn as dxCos,On as dxCot,Xn as dxPolynomial,Yn as dxSin,Gn as dxTan,It as dxV2CubicBezierCurve,dt as dxV2QuadraticBezierCurve,gt as dxV3CubicBezierCurve,yt as dxV3QuadraticBezierCurve,nr as ellipseMovement,Bo as ellipseMovementAfterMouse,Tt as factorial,Ai as factorialIterative,qi as factorialMemoized,fr as factorialRecursive,qt as getAnglesDistance,F as getAnglesSub,G as getArithmeticMean,di as getArithmeticMeanFromFrequency,xi as getCircleCircumference,_o as getColorsDelta,mi as getEllipseCircumference,eo as getLinearEquationBy2Points,yi as getMedian,Ii as getMode,V as getRandom,Ln as getRandomBoolean,Yo as getRandomGrayscaleHSLColor,wt as getRandomHSLColor,Co as getRandomHSLColorWithHue,Xo as getRandomHSLColorWithLightness,Do as getRandomHSLColorWithSaturation,jo as getRandomHSLColorWithinRanges,qo as getRandomHexColor,_t as getRandomInt,$n as getRandomItemFromArray,Ao as getRandomRGBColor,Qo as getShiftedHue,Zo as getShiftedLightness,Wo as getShiftedSaturation,fi as getSquareInCircleSide,Bt as getStandardDeviation,T as getV2Angle,Rr as getV2AngleBetween,vr as getV2AngleInEllipse,zr as getV3AngleBetween,At as getVNAngleBetween,xr as getVariance,gi as getVariance1,Ko as guid,Fo as hexToRgb,ur as hslToHex,sr as hslToRgb,fe as identity2,pe as identity3,be as identity4,he as identityN,Br as isAngleBetween,ai as isAngleInCircleArc,J as isClockwise,E as isNumber,Ne as isSingularMatrix,ko as labToRgb,$ as linearEquation,Pn as linearEquationSystem2,to as linearEquationSystem3,ro as linearEquationSystemN,Ho as lissajousCurve,bt as m2Adjugate,de as m2AppendRow,ut as m2DeepCopy,pt as m2Determinant,Dt as m2DivideScalar,Mt as m2Inverse,re as m2MulScalar,ge as m2PrependRow,bn as m2ReflectionOrigin,hn as m2ReflectionOriginH,dn as m2ReflectionX,yn as m2ReflectionXH,In as m2ReflectionY,gn as m2ReflectionYH,ln as m2ReflectionYmX,ce as m2Reset,Fe as m2RotateAroundPointH,Yt as m2Rotation,jt as m2RotationAroundPointH,lt as m2RotationH,Qt as m2Scale,Pe as m2ScaleAtPointH,kt as m2ScaleAtPointHMatrix,Zt as m2ScaleH,nn as m2ScaleX,on as m2ScaleXH,fn as m2ScaleY,pn as m2ScaleYH,Hn as m2ShearingX,En as m2ShearingY,Pr as m2Sub,Kr as m2Sum,Ce as m2ToCSS,je as m2Translation,j as m2TranslationH,oe as m2Transpose,De as m2hToCSS,Xe as m2hToCSS3d,ue as m2x2,Te as m3Adjugate,ye as m3AppendRow,xt as m3DeepCopy,He as m3Determinant,ne as m3DivideScalar,Vt as m3Inverse,ee as m3MulScalar,ve as m3PrependRow,Mn as m3ReflectionOrigin,Vn as m3ReflectionOriginH,zn as m3ReflectionXY,Bn as m3ReflectionXYH,Sn as m3ReflectionXZ,Rn as m3ReflectionXZH,vn as m3ReflectionYZ,wn as m3ReflectionYZH,se as m3Reset,Gt as m3RotationX,Ze as m3RotationXH,Ot as m3RotationY,_e as m3RotationYH,Ft as m3RotationZ,Ke as m3RotationZH,Wt as m3Scale,rn as m3ScaleH,cn as m3ScaleX,sn as m3ScaleXH,un as m3ScaleY,xn as m3ScaleYH,mn as m3ScaleZ,an as m3ScaleZH,te as m3Sub,Jr as m3Sum,Ge as m3Translation,Oe as m3TranslationH,ie as m3Transpose,Ye as m3hToCSS3d,xe as m3x3,me as m4x4,ht as mAdjugate,Me as mAppendCol,le as mAppendRow,y as mDeepCopy,Re as mDelFirstColumn,Se as mDelFirstRow,mt as mDelLastColumn,we as mDelLastRow,Y as mDeterminant,Q as mDivideScalar,Ee as mEqual,Be as mGetColumn,ze as mGetFirstColumn,at as mGetLastColumn,Z as mInverse,ft as mMinor,L as mMul,ct as mMulScalar,M as mMulVector,ae as mNxM,Ve as mPrependCol,Ie as mPrependRow,st as mReset,it as mSub,ot as mSum,X as mTranspose,Et as mlNormalizeArray,zi as mlNormalizeTestData,Bi as mlNormalizeUnseenData,mr as mlNormalizeValue,Ht as mlStandardizeArray,Ei as mlStandardizeTestData,Hi as mlStandardizeUnseenData,ar as mlStandardizeValue,d as mod,hi as naturalNumbersSequenceSum,Ni as naturalNumbersSum1ToN,Li as naturalNumbersSumMToN,Jo as newId,Er as percentToAngle,Xi as permutationsWithRepetition,Yi as permutationsWithoutRepetition,lr as polarToCartesian,wr as radiansToDegrees,ei as rectCollide,Oo as rgbToHex,Go as rgbToHsl,vt as rgbToLab,s as setDecimalPlaces,K as setV2Angle,Eo as sineWaveMovement,qn as stringToNumber,kr as v2,go as v2CubicBezierBBox,Kt as v2CubicBezierCurve,rr as v2CubicBezierCurveExtrema,yo as v2CubicBezierCurveNormal,Pt as v2CubicBezierCurveTangent,jr as v2Distance,Cr as v2DivideScalar,tt as v2DotProduct,Wr as v2FromPolarCoords,nt as v2GetNormal,P as v2Length,qr as v2MulScalar,N as v2Normalize,Io as v2QuadraticBezierBBox,Ut as v2QuadraticBezierCurve,tr as v2QuadraticBezierCurveExtrema,lo as v2QuadraticBezierCurveNormal,Jt as v2QuadraticBezierCurveTangent,ke as v2Rotate,Qe as v2RotateH,tn as v2Scale,Ct as v2SetLength,R as v2Sub,Lr as v2Sum,Qr as v3,Fr as v3CrossProduct,ho as v3CubicBezierCurve,Vo as v3CubicBezierCurveTangent,Gr as v3Distance,Dr as v3DivideScalar,Or as v3DotProduct,Xr as v3Length,k as v3MulScalar,v as v3Normalize,bo as v3QuadraticBezierCurve,Mo as v3QuadraticBezierCurveTangent,We as v3RotateX,Ue as v3RotateY,Je as v3RotateZ,en as v3Scale,Ar as v3Sub,$r as v3Sum,Zr as v4,Yr as vDistance,D as vDivideScalar,w as vDotProduct,et as vEqual,z as vLength,C as vMulScalar,rt as vN,H as vNormalize,I as vSub,q as vSum}; + )`,je=(t,r=1/0)=>[[1,0],[0,1],[c(t[0],r),c(t[1],r)]],Ge=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[c(t[0],r),c(t[1],r),c(t[2],r)]],j=(t,r=1/0)=>[[1,0,c(t[0],r)],[0,1,c(t[1],r)],[0,0,1]],Oe=(t,r=1/0)=>[[1,0,0,c(t[0],r)],[0,1,0,c(t[1],r)],[0,0,1,c(t[2],r)],[0,0,0,1]],Yt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},lt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},jt=(t,r,e=!0,n=1/0)=>{let o=j(r,n),i=lt(t,e,n),s=j(k(r,-1),n),u=A(o,i);return A(u,s)},Fe=(t,r,e,n=!0,o=1/0)=>{let i=jt(t,r,n,o);return M(i,e)},ke=(t,r,e=!0,n=1/0)=>{let o=N(r);return M(Yt(t,e,n),o)},Qe=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(lt(t,e,n),o)},Gt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},We=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0,0],[0,n,-o,0],[0,o,n,0],[0,0,0,1]]:[[1,0,0,0],[0,n,o,0],[0,-o,n,0],[0,0,0,1]]},Ze=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(Gt(t,e,n),o)},Ot=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},_e=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},Ue=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(Ot(t,e,n),o)},Ft=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Ke=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0,0],[o,n,0,0],[0,0,1,0],[0,0,0,1]]:[[n,o,0,0],[-o,n,0,0],[0,0,1,0],[0,0,0,1]]},Je=(t,r,e=!0,n=1/0)=>{let o=v(r);return M(Ft(t,e,n),o)},kt=(t,r,e=1/0)=>{let n=j(r,e),o=Wt(t),i=j(k(r,-1),e),s=A(n,o);return A(s,i)},Pe=(t,r,e,n=1/0)=>{let o=kt(t,r,n);return M(o,e)},Qt=t=>[[t[0],0],[0,t[1]]],tn=(t,r)=>M(Qt(t),r),Wt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Zt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],rn=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],en=(t,r)=>M(Zt(t),r),nn=t=>[[t,0],[0,1]],on=t=>[[t,0,0],[0,1,0],[0,0,1]],sn=t=>[[t,0,0],[0,1,0],[0,0,1]],cn=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],un=t=>[[1,0,0],[0,t,0],[0,0,1]],mn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],xn=t=>[[1,0,0],[0,1,0],[0,0,t]],an=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],fn=t=>[[1,0],[0,t]],pn=t=>[[1,0,0],[0,t,0],[0,0,1]],bn=()=>[[-1,0],[0,-1]],hn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],Mn=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],Vn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],ln=()=>[[0,-1],[-1,0]],dn=()=>[[1,0],[0,-1]],yn=()=>[[1,0,0],[0,-1,0],[0,0,1]],In=()=>[[-1,0],[0,1]],gn=()=>[[-1,0,0],[0,1,0],[0,0,1]],vn=()=>[[-1,0,0],[0,1,0],[0,0,1]],wn=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Sn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Rn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],zn=()=>[[1,0,0],[0,1,0],[0,0,-1]],Bn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],En=t=>[[1,t],[0,1]],Hn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>c(Math.random()*(r-t)+t,e),_t=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),An=()=>Math.random()<.5,Ln=t=>{let r=_t(0,t.length-1);return t[r]};var qn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Xn=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],s=o[1];n+=i*s*Math.pow(t,s-1)}return c(n,e)},dt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},yt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},It=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,x=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i)]},gt=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,x=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},Yn=(t,r=1/0)=>c(Math.cos(t),r),jn=(t,r=1/0)=>c(-Math.sin(t),r),Gn=(t,r=1/0)=>c(1/h(Math.cos(t),2),r),On=(t,r=1/0)=>c(-1/h(Math.sin(t),2),r),Fn=(t,r=1/0)=>c(1/Math.sqrt(1-h(t,2)),r),kn=(t,r=1/0)=>c(-1/Math.sqrt(1-h(t,2)),r),Qn=(t,r=1/0)=>c(1/(1+h(t,2)),r),Wn=(t,r=1/0)=>c(-1/(1+h(t,2)),r);var L=(t,r=1/0)=>{let e=t[0],n=t[1],i=t[2]-n;return e===0&&i===0?1/0:e===0?NaN:c(i/e,r)},Pn=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=Mt(n);if(o===null)return null;let i=[t[2],r[2]];return M(o,i,e)},to=(t,r,e,n=1/0)=>{let o=[[t[0],t[1],t[2]],[r[0],r[1],r[2]],[e[0],e[1],e[2]]],i=Vt(o);if(i===null)return null;let s=[t[3],r[3],e[3]];return M(i,s,n)},ro=(t,r=1/0)=>{if(t.length<=0)return null;let e=xt(t),n=W(e);if(n===null)return null;let o=at(t);return M(n,o,r)},eo=(t,r)=>{let[e,n]=R(r,t),[o,i]=t;if(e===0)return{slope:void 0,xIntercept:o,yIntercept:void 0,formula:`x = ${o}`};let s=n/e,u=i-s*o,m="";return s===0?m=`y = ${u}`:(m=`y = ${s===1?"":s}x`,u!==0&&(m+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:s,xIntercept:void 0,yIntercept:u,formula:m}};var Z=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=L([n,o,i],r);return E(f)?[f]:[]}let s=o-i,u=n*n-4*e*s;if(u<0)return[];if(u===0)return[c(-n/(2*e),r)];let m=2*e,x=Math.sqrt(u);return[c((-n+x)/m,r),c((-n-x)/m,r)]};var Ut=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},bo=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},Kt=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i)]},ho=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},Jt=(t,r,e,n,o=1/0)=>{let i=dt(t,r,e,n);return N(i,o)},Mo=(t,r,e,n,o=1/0)=>{let i=yt(t,r,e,n);return v(i,o)},Pt=(t,r,e,n,o,i=1/0)=>{let s=It(t,r,e,n,o);return N(s,i)},Vo=(t,r,e,n,o,i=1/0)=>{let s=gt(t,r,e,n,o);return v(s,i)},lo=(t,r,e,n,o=1/0)=>{let i=Jt(t,r,e,n,o);return[-i[1],i[0]]},yo=(t,r,e,n,o,i=1/0)=>{let s=Pt(t,r,e,n,o,i);return[-s[1],s[0]]},tr=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=L([o,i,0],n),m=2*t[1]-4*r[1]+2*e[1],x=-2*t[1]+2*r[1],p=L([m,x,0],n),a=[];return E(u)&&a.push(u),E(p)&&a.push(p),a},rr=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],s=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],m=[i,s,u,0],x=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[x,f,p,0],b=Z(m,o).filter(l=>l>=0&&l<=1),g=Z(a,o).filter(l=>l>=0&&l<=1);return[...b,...g].length===2?[...b,...g]:null},Io=(t,r,e,n=1/0)=>{let o=tr(t,r,e),i=1/0,s=1/0,u=-1/0,m=-1/0;for(let x of o){let f=Ut(x,t,r,e),p=f[0],a=f[1];i=Math.min(i,p),u=Math.max(u,p),s=Math.min(s,a),m=Math.max(m,a)}return i=c(Math.min(i,t[0],e[0]),n),u=c(Math.max(u,t[0],e[0]),n),s=c(Math.min(s,t[1],e[1]),n),m=c(Math.max(m,t[1],e[1]),n),{x:i,y:s,w:Math.abs(u-i),h:Math.abs(m-s),x2:u,y2:m}},go=(t,r,e,n,o=1/0)=>{let i=rr(t,r,e,n)||[],s=1/0,u=1/0,m=-1/0,x=-1/0;for(let f of i){let p=Kt(f,t,r,e,n),a=p[0],b=p[1];s=Math.min(s,a!=null?a:1/0),m=Math.max(m,a!=null?a:-1/0),u=Math.min(u,b!=null?b:1/0),x=Math.max(x,b!=null?b:-1/0)}return s=c(Math.min(s,t[0],n[0]),o),m=c(Math.max(m,t[0],n[0]),o),u=c(Math.min(u,t[1],n[1]),o),x=c(Math.max(x,t[1],n[1]),o),{x:s,y:u,w:Math.abs(m-s),h:Math.abs(x-u),x2:m,y2:x}};var er=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),zo=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),er(r,o,e)},nr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),Bo=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),nr(r,o,e[0],e[1])},Eo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},Ho=(t,r,e,n,o,i,s)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-s)];var $o=()=>{let t=wt();return cr(t)},qo=()=>{let t=wt();return ur(t)},wt=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Co=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},Do=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Xo=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Yo=()=>[0,0,V(0,100)],jo=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let s=V(t,r),u=V(e,n),m=V(o,i);return[s,u,m]},or=t=>(t*=60,t<0&&(t+=360),t),ir=(t,r,e,n=void 0,o=void 0)=>{if(n=n===void 0?Math.min(t,r,e):n,o=o===void 0?Math.max(t,r,e):o,n===o)return 0;let i=o-n,s=0;return o===t&&(s=(r-e)/i+(r(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,(n+o)/2*100),sr=(t,r,e,n=void 0,o=void 0,i=void 0)=>(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,n===o?0:(i=i===void 0?St(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),Go=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255,i=Math.min(e,n,o),s=Math.max(e,n,o),u=St(e,n,o,i,s),m=sr(e,n,o,i,s,u),x=ir(e,n,o,i,s);return x>360||m>100||u>100?[0,0,100]:x<0||m<0||u<0?[0,0,0]:[c(x,r),c(m,r),c(u,r)]},_=(t,r,e)=>(e<0&&(e+=1),e>1&&(e-=1),e*6<1?r+(t-r)*6*e:e*2<1?t:e*3<2?r+(t-r)*(.666-e)*6:r),cr=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let b=o*255;return[b,b,b]}let i=o<.5?o*(1+n):o+n-o*n,s=2*o-i,u=e+.333,m=e,x=e-.333,f=_(i,s,u),p=_(i,s,m),a=_(i,s,x);return f*=255,p*=255,a*=255,f>255||p>255||a>255?[255,255,255]:f<0||p<0||a<0?[0,0,0]:[c(f,r),c(p,r),c(a,r)]},ur=t=>{if(t[0]>360||t[1]>100||t[2]>100)return"#ffffff";if(t[0]<0||t[1]<0||t[2]<0)return"#000000";let r=t[0]/360,e=t[1]/100,n=t[2]/100,o,i,s;if(e===0)o=i=s=n;else{let m=(p,a,b)=>(b<0&&(b+=1),b>1&&(b-=1),b<.16666666666666666?p+(a-p)*6*b:b<.5?a:b<.6666666666666666?p+(a-p)*(.6666666666666666-b)*6:p),x=n<.5?n*(1+e):n+e-n*e,f=2*n-x;o=m(f,x,r+1/3),i=m(f,x,r),s=m(f,x,r-1/3)}let u=m=>{let x=Math.round(m*255).toString(16);return x.length===1?"0"+x:x};return`#${u(o)}${u(i)}${u(s)}`},Oo=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Fo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,m,x,f)=>m+m+x+x+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),s=parseInt(n[3],16);return[o,i,s]},vt=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;let i=(e*.4124+n*.3576+o*.1805)/.95047,s=(e*.2126+n*.7152+o*.0722)/1,u=(e*.0193+n*.1192+o*.9505)/1.08883;return i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,[c(116*s-16,r),c(500*(i-s),r),c(200*(s-u),r)]},ko=(t,r=1/0)=>{let e=(t[0]+16)/116,n=t[1]/500+e,o=e-t[2]/200;n=.95047*(n*n*n>.008856?n*n*n:(n-16/116)/7.787),e=1*(e*e*e>.008856?e*e*e:(e-16/116)/7.787),o=1.08883*(o*o*o>.008856?o*o*o:(o-16/116)/7.787);let i=n*3.2406+e*-1.5372+o*-.4986,s=n*-.9689+e*1.8758+o*.0415,u=n*.0557+e*-.204+o*1.057;return i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:12.92*u,[c(Math.max(0,Math.min(1,i))*255,r),c(Math.max(0,Math.min(1,s))*255,r),c(Math.max(0,Math.min(1,u))*255,r)]},Qo=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=d(e,360)),[e,t[1],t[2]]},Wo=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=d(e,100)),[t[0],t[1],e]},Zo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},_o=(t,r,e=1/0)=>{let n=vt(t,e),o=vt(r,e),i=n[0]-o[0],s=n[1]-o[1],u=n[2]-o[2],m=Math.sqrt(n[1]*n[1]+n[2]*n[2]),x=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=m-x,p=s*s+u*u-f*f;p=p<0?0:Math.sqrt(p);let a=1+.045*m,b=1+.015*m,g=i/1,B=f/a,l=p/b,$=g*g+B*B+l*l;return $<0?0:Math.sqrt($)};var Ko=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),Jo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var ei=(t,r)=>t.x<=r.x+r.w&&t.x+t.w>=r.x&&t.y<=r.y+r.h&&t.h+t.y>=r.y,ni=(t,r)=>{let e=Math.abs(t.cx-r.cx),n=Math.abs(t.cy-r.cy);return Math.sqrt(e*e+n*n)<=t.r+r.r},Rt=t=>{let r=[];for(let e=0;e{let e=[];e.push(...Rt(t)),e.push(...Rt(r));for(let n of e){let o=nt(n[0],n[1]),i=zt(t,o),s=zt(r,o);if(!(i.max>=s.min&&s.max>=i.min))return!1}return!0},zt=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=tt(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var si=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,s=!1,u,m=()=>{e=void 0,o=void 0,i=void 0,s=!1,n!==void 0&&window.cancelAnimationFrame(n)},x=()=>{m(),g()},f=()=>{s=!1},p=()=>{s=!0},a=S=>{e===void 0&&(e=S),o=S-e,s&&i!==S&&typeof t.callback=="function"&&t.callback(U()),o<=r?(i=S,n=window.requestAnimationFrame(a)):m()},b=(S,Lt)=>{x(),typeof t.resizeCallback=="function"&&t.resizeCallback(S,Lt)},g=()=>{e=void 0,o=void 0,i=void 0,s=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(b),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(a)},B=()=>o,l=()=>s,$=()=>e,Nt=()=>{if(!(r===1/0||o===void 0))return o*100/r},At=()=>u,U=()=>({start:g,stop:m,pause:f,resume:p,restart:x,isAnimating:l,getElapsedTime:B,getStartTime:$,getPercent:Nt,getResizeObserver:At});return U()};var mi=(t,r=1/0)=>c(2*Math.PI*t,r),xi=(t,r,e=1/0)=>c(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),ai=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),fi=(t,r=1/0)=>c(t*2/Math.sqrt(2),r);var hi=t=>t*(t+1)/2,Mi=(t,r,e)=>t/2*(2*r+(t-1)*e);var G=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return c(e/t.length,r)},di=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return c(e,r)},yi=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=[...t].sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?c((e[n]+e[n-1])/2,r):c(e[n],r)},Ii=t=>{if(!t||t.length<=0)return;let r=new Map;for(let o of t)r.set(o,(r.get(o)||0)+1);let e=0,n=[];for(let[o,i]of r)i>e?(e=i,n=[o]):i===e&&n.push(o);if(n.length!==t.length)return n.length===1?[n[0]]:n},gi=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return c(n/t.length,r)},mr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i,2),0);return c(n/t.length-h(e,2),r)},Bt=(t,r=1/0)=>{var n;let e=(n=mr(t))!=null?n:0;return c(Math.sqrt(e),r)};var xr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:c((t-r)/o,n)},Et=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Et(t,e,n,r);return{min:c(e,r),max:c(n,r),data:o}},Bi=(t,r,e,n=1/0)=>Et(t,r,e,n),ar=(t,r,e,n=1/0)=>e===0?0:c((t-r)/e,n),Ht=(t,r,e,n=1/0)=>[...t].map(o=>ar(o,r,e,n)),Ei=(t,r=1/0)=>{var i;let e=(i=G(t))!=null?i:0,n=Bt(t),o=Ht(t,e,n,r);return{mean:c(e,r),stdDev:c(n,r),data:o}},Hi=(t,r,e,n=1/0)=>Ht(t,r,e,n);var Ni=t=>t/2*(t+1),Ai=(t,r)=>(r-t+1)*(t+r)/2;var $i=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=1;for(let n=r;n<=t;n++)e*=n;return e},fr=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}return t===r?r:t*fr(t-1,r)},qi=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=new Map,n=(o,i)=>{var u;if(o{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===t)return t===0?1:t;r===0&&(r=1);let e=[];e[0]=1;for(let n=1;n<=t;n++)e[n]=e[n-1]*n;return e[t]/e[r-1]};var Xi=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return h(t,r)},Yi=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return Tt(t,t-r+1)},ji=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");let e=Array.from({length:t+1},()=>Array(r+1).fill(0));for(let n=0;n<=t;n++)e[n][0]=1,n<=r&&(e[n][n]=1);for(let n=1;n<=t;n++)for(let o=1;o<=Math.min(n,r);o++)e[n][o]=e[n-1][o-1]+e[n-1][o];return e[t][r]},Gi=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");if(t===0)return 1;let e=r+t-1,n=r,o=Array.from({length:e+1},()=>Array(n+1).fill(0));for(let i=0;i<=e;i++)o[i][0]=1;for(let i=1;i<=e;i++)for(let s=1;s<=Math.min(i,n);s++)o[i][s]=o[i-1][s]+o[i-1][s-1];return o[e][n]};export{si as animate,Mi as arithmeticSequenceSum,ni as circleCollide,er as circleMovement,zo as circleMovementAfterMouse,Gi as combinationsWithRepetition,ji as combinationsWithoutRepetition,O as convertRange,oi as convexPolygonsCollide,Sr as degreesToRadians,Vr as doRangesOverlap,kn as dxArcCos,Wn as dxArcCot,Fn as dxArcSin,Qn as dxArcTan,jn as dxCos,On as dxCot,Xn as dxPolynomial,Yn as dxSin,Gn as dxTan,It as dxV2CubicBezierCurve,dt as dxV2QuadraticBezierCurve,gt as dxV3CubicBezierCurve,yt as dxV3QuadraticBezierCurve,nr as ellipseMovement,Bo as ellipseMovementAfterMouse,Tt as factorial,$i as factorialIterative,qi as factorialMemoized,fr as factorialRecursive,qt as getAnglesDistance,F as getAnglesSub,G as getArithmeticMean,di as getArithmeticMeanFromFrequency,mi as getCircleCircumference,_o as getColorsDelta,xi as getEllipseCircumference,eo as getLinearEquationBy2Points,yi as getMedian,Ii as getMode,V as getRandom,An as getRandomBoolean,Yo as getRandomGrayscaleHSLColor,wt as getRandomHSLColor,Co as getRandomHSLColorWithHue,Xo as getRandomHSLColorWithLightness,Do as getRandomHSLColorWithSaturation,jo as getRandomHSLColorWithinRanges,qo as getRandomHexColor,_t as getRandomInt,Ln as getRandomItemFromArray,$o as getRandomRGBColor,Qo as getShiftedHue,Wo as getShiftedLightness,Zo as getShiftedSaturation,fi as getSquareInCircleSide,Bt as getStandardDeviation,T as getV2Angle,Rr as getV2AngleBetween,vr as getV2AngleInEllipse,zr as getV3AngleBetween,$t as getVNAngleBetween,mr as getVariance,gi as getVariance1,Ko as guid,Fo as hexToRgb,ur as hslToHex,cr as hslToRgb,fe as identity2,pe as identity3,be as identity4,he as identityN,Br as isAngleBetween,ai as isAngleInCircleArc,J as isClockwise,E as isNumber,Ne as isSingularMatrix,ko as labToRgb,L as linearEquation,Pn as linearEquationSystem2,to as linearEquationSystem3,ro as linearEquationSystemN,Ho as lissajousCurve,bt as m2Adjugate,de as m2AppendRow,ut as m2DeepCopy,pt as m2Determinant,Dt as m2DivideScalar,Mt as m2Inverse,re as m2MulScalar,ge as m2PrependRow,bn as m2ReflectionOrigin,hn as m2ReflectionOriginH,dn as m2ReflectionX,yn as m2ReflectionXH,In as m2ReflectionY,gn as m2ReflectionYH,ln as m2ReflectionYmX,se as m2Reset,Fe as m2RotateAroundPointH,Yt as m2Rotation,jt as m2RotationAroundPointH,lt as m2RotationH,Qt as m2Scale,Pe as m2ScaleAtPointH,kt as m2ScaleAtPointHMatrix,Wt as m2ScaleH,nn as m2ScaleX,on as m2ScaleXH,fn as m2ScaleY,pn as m2ScaleYH,Hn as m2ShearingX,En as m2ShearingY,Pr as m2Sub,Kr as m2Sum,Ce as m2ToCSS,je as m2Translation,j as m2TranslationH,oe as m2Transpose,De as m2hToCSS,Xe as m2hToCSS3d,ue as m2x2,Te as m3Adjugate,ye as m3AppendRow,mt as m3DeepCopy,He as m3Determinant,ne as m3DivideScalar,Vt as m3Inverse,ee as m3MulScalar,ve as m3PrependRow,Mn as m3ReflectionOrigin,Vn as m3ReflectionOriginH,zn as m3ReflectionXY,Bn as m3ReflectionXYH,Sn as m3ReflectionXZ,Rn as m3ReflectionXZH,vn as m3ReflectionYZ,wn as m3ReflectionYZH,ce as m3Reset,Gt as m3RotationX,We as m3RotationXH,Ot as m3RotationY,_e as m3RotationYH,Ft as m3RotationZ,Ke as m3RotationZH,Zt as m3Scale,rn as m3ScaleH,sn as m3ScaleX,cn as m3ScaleXH,un as m3ScaleY,mn as m3ScaleYH,xn as m3ScaleZ,an as m3ScaleZH,te as m3Sub,Jr as m3Sum,Ge as m3Translation,Oe as m3TranslationH,ie as m3Transpose,Ye as m3hToCSS3d,me as m3x3,xe as m4x4,ht as mAdjugate,Me as mAppendCol,le as mAppendRow,y as mDeepCopy,Re as mDelFirstColumn,Se as mDelFirstRow,xt as mDelLastColumn,we as mDelLastRow,Y as mDeterminant,Q as mDivideScalar,Ee as mEqual,Be as mGetColumn,ze as mGetFirstColumn,at as mGetLastColumn,W as mInverse,ft as mMinor,A as mMul,st as mMulScalar,M as mMulVector,ae as mNxM,Ve as mPrependCol,Ie as mPrependRow,ct as mReset,it as mSub,ot as mSum,X as mTranspose,Et as mlNormalizeArray,zi as mlNormalizeTestData,Bi as mlNormalizeUnseenData,xr as mlNormalizeValue,Ht as mlStandardizeArray,Ei as mlStandardizeTestData,Hi as mlStandardizeUnseenData,ar as mlStandardizeValue,d as mod,hi as naturalNumbersSequenceSum,Ni as naturalNumbersSum1ToN,Ai as naturalNumbersSumMToN,Jo as newId,Er as percentToAngle,Xi as permutationsWithRepetition,Yi as permutationsWithoutRepetition,lr as polarToCartesian,wr as radiansToDegrees,ei as rectCollide,Oo as rgbToHex,Go as rgbToHsl,vt as rgbToLab,c as setDecimalPlaces,K as setV2Angle,Eo as sineWaveMovement,qn as stringToNumber,kr as v2,go as v2CubicBezierBBox,Kt as v2CubicBezierCurve,rr as v2CubicBezierCurveExtrema,yo as v2CubicBezierCurveNormal,Pt as v2CubicBezierCurveTangent,jr as v2Distance,Cr as v2DivideScalar,tt as v2DotProduct,Zr as v2FromPolarCoords,nt as v2GetNormal,P as v2Length,qr as v2MulScalar,N as v2Normalize,Io as v2QuadraticBezierBBox,Ut as v2QuadraticBezierCurve,tr as v2QuadraticBezierCurveExtrema,lo as v2QuadraticBezierCurveNormal,Jt as v2QuadraticBezierCurveTangent,ke as v2Rotate,Qe as v2RotateH,tn as v2Scale,Ct as v2SetLength,R as v2Sub,Ar as v2Sum,Qr as v3,Fr as v3CrossProduct,ho as v3CubicBezierCurve,Vo as v3CubicBezierCurveTangent,Gr as v3Distance,Dr as v3DivideScalar,Or as v3DotProduct,Xr as v3Length,k as v3MulScalar,v as v3Normalize,bo as v3QuadraticBezierCurve,Mo as v3QuadraticBezierCurveTangent,Ze as v3RotateX,Ue as v3RotateY,Je as v3RotateZ,en as v3Scale,$r as v3Sub,Lr as v3Sum,Wr as v4,Yr as vDistance,D as vDivideScalar,w as vDotProduct,et as vEqual,z as vLength,C as vMulScalar,rt as vN,H as vNormalize,I as vSub,q as vSum}; //# sourceMappingURL=mz-math.esm.js.map diff --git a/dist/mz-math.esm.js.map b/dist/mz-math.esm.js.map index a812247..5190445 100644 --- a/dist/mz-math.esm.js.map +++ b/dist/mz-math.esm.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/main/format.ts", "../src/main/other.ts", "../src/main/angle.ts", "../src/main/linear-algebra/vector.ts", "../src/main/linear-algebra/matrix.ts", "../src/main/linear-algebra/matrix-transformations.ts", "../src/main/random.ts", "../src/main/convert.ts", "../src/main/derivative.ts", "../src/main/equations/linear-equations.ts", "../src/main/equations/quadratic-equations.ts", "../src/main/bezier-curves/bezier-curve.ts", "../src/main/path-movement.ts", "../src/main/color.ts", "../src/main/id.ts", "../src/main/collision-detection.ts", "../src/main/animation.ts", "../src/main/circle-ellipse.ts", "../src/main/sequence.ts", "../src/main/statistics.ts", "../src/main/ml.ts", "../src/main/series.ts", "../src/main/combinatorics/factorial.ts", "../src/main/combinatorics/combinatorics.ts"], - "sourcesContent": ["export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};", "/**\n * The simplest and straightforward method\n * but can become inefficient for extremely large numbers\n * due to growing computational time.\n */\nexport const factorialIterative = (n: number, start = 0): number => {\n\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n let result = 1;\n for (let i = start; i <= n; i++) {\n result *= i;\n }\n return result;\n};\n\n/**\n * A recursive approach is a classic method for calculating factorials\n * but can lead to stack overflow errors\n * for very large inputs because of deep recursion.\n * However, it's a direct translation\n * of the mathematical definition of factorial.\n */\nexport const factorialRecursive = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n // Base case: when n reaches start, return start instead of further reducing\n if (n === start) return start;\n\n // Recursive call\n return n * factorialRecursive(n - 1, start);\n};\n\n/**\n * Memoization (Top-Down Dynamic Programming).\n */\nexport const factorialMemoized = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n const memo = new Map();\n\n const traverse = (num: number, end: number): number => {\n if (num < end) return 1; // Adjust the base case to return 1 if we're below 'end'\n // if (num === 0) return 1;\n\n if (memo.has(num)) return memo.get(num) ?? 1;\n\n if (num === end) {\n memo.set(num, num);\n return num;\n }\n\n const result = num * traverse(num - 1, end);\n\n memo.set(num, result);\n\n return result;\n };\n\n return traverse(n, start);\n};\n\n/**\n * Tabulation (Bottom-Up Dynamic Programming).\n */\nexport const factorial = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === n) {\n return n === 0 ? 1 : n; // If start == n and n == 0, return 1 (0!), otherwise return n\n }\n\n if (start === 0) {\n start = 1;\n }\n\n const table = []; // new Array(n + 1);\n table[0] = 1;\n for (let i = 1; i <= n; i++) {\n table[i] = table[i - 1] * i;\n }\n return table[n] / table[start - 1];\n};", "import { factorial } from './factorial';\n\n/**\n * Permutations with repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - repetition is allowed\n *\n * Formula:\n * --------\n * n^r\n *\n * Intuition:\n * ----------\n * In other words, there are n possibilities for the first choice,\n * THEN there are n possibilities for the second choice, and so on,\n * multiplying each time.\n *\n * A Permutation is an ordered Combination.\n *\n * Example:\n * --------\n * Such as a lock that could be \"333\".\n */\nexport const permutationsWithRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return n ** r;\n};\n\n/**\n * Permutations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - no repetitions\n *\n * Formula:\n * --------\n * P(n,r) = n! / (n \u2212 r)!\n *\n * Intuition:\n * ----------\n * In this case, we have to reduce the number of available choices each time.\n * After choosing, say, number \"14\" we can't choose it again.\n * So, our first choice has 16 possibilities, and our next choice has 15 possibilities,\n * then 14, 13, 12, 11, ... etc.\n *\n * A Permutation is an ordered Combination.\n */\nexport const permutationsWithoutRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return factorial(n, n - r + 1);\n};\n\n/**\n * Order doesn't matter.\n *\n * Example:\n * --------\n * Coins in your pocket (5, 5, 5, 10, 10).\n\nexport const combinationsWithRepetition = () => {\n\n};\n */\n\n/**\n * Combinations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - no repetitions\n *\n * And is also known as the Binomial Coefficient.\n *\n * Formula:\n * --------\n * C(n, r) = C(n, n - r) = n! / (r! * (n\u2212r)!)\n *\n * Example:\n * --------\n * Such as lottery numbers (2, 14, 15, 27, 30, 33).\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42(n \u00D7 r)\n * Space Complexity: \uD835\uDC42(n \u00D7 r)\n */\nexport const combinationsWithoutRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n // Initialize a two-dimensional array (or matrix) [n + 1, r + 1].\n // The reason for n + 1 is to ensure that we can access indices directly equal to the value of n\n // without running out of bounds, as array indices start at 0.\n const dp = Array.from({ length: n + 1 }, () => Array(r + 1).fill(0));\n /*\n const dp: number[][] = [];\n for(let i=0; i<=n; i++) {\n dp[i] = [];\n for(let j=0; j<=r; j++) {\n dp[i][j] = 0;\n }\n }*/\n\n // Base cases: C(n, 0) = 1 and C(n, n) = 1 for any n.\n for (let i = 0; i <= n; i++) {\n dp[i][0] = 1;\n if (i <= r) {\n // Only fill this if i <= r to avoid filling non-existent cells\n dp[i][i] = 1;\n }\n }\n\n // Fill the table using the relation C(n, r) = C(n-1, r-1) + C(n-1, r)\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, r); j++) { // Only compute up to the minimum of i and r\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n }\n }\n\n return dp[n][r];\n};\n\n"], - "mappings": ";;;;;;;eAAO,IAAMA,EAAmB,CAACC,EAAaC,EAAoC,MAAa,CAC3F,GAAGA,IAAkB,IAAU,OAAOD,EAEnCC,EAAgB,IACfA,EAAgB,GAGpB,IAAMC,EAAcC,EAAA,GAAMF,GAC1B,OAAO,KAAK,MAAMD,EAAME,CAAW,EAAIA,CAC3C,ECNO,IAAME,EAAM,CAACC,EAAWC,KAClBD,EAAIC,EAAKA,GAAKA,EAOdC,EAAe,CAACC,EAAWC,EAAWC,EAAWC,EAAWC,KAC7DA,EAAID,IAAMH,EAAIC,IAAMC,EAAID,GAAKE,EAM5BE,GAAkB,CAACJ,EAAWC,EAAWC,EAAWC,IACtD,KAAK,IAAIH,EAAG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CAC5E,GAAIA,EAAI,GAAK,EAAI,EACb,MAAM,IAAI,MAAM,+CAA+C,EAEnE,GAAI,CAAC,OAAO,UAAUA,CAAC,GAAK,CAAC,OAAO,UAAU,CAAC,EAC3C,MAAM,IAAI,MAAM,kCAAkC,EAMtD,IAAMK,EAAK,MAAM,KAAK,CAAE,OAAQL,EAAI,CAAE,EAAG,IAAM,MAAM,EAAI,CAAC,EAAE,KAAK,CAAC,CAAC,EAWnE,QAASM,EAAI,EAAGA,GAAKN,EAAGM,IACpBD,EAAGC,GAAG,GAAK,EACPA,GAAK,IAELD,EAAGC,GAAGA,GAAK,GAKnB,QAASA,EAAI,EAAGA,GAAKN,EAAGM,IACpB,QAASC,EAAI,EAAGA,GAAK,KAAK,IAAID,EAAG,CAAC,EAAGC,IACjCF,EAAGC,GAAGC,GAAKF,EAAGC,EAAE,GAAGC,EAAE,GAAKF,EAAGC,EAAE,GAAGC,GAI1C,OAAOF,EAAGL,GAAG,EACjB", - "names": ["setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "stringToNumber", "value", "defaultNumber", "_a", "res", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "x", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "guid", "c", "newId", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "naturalNumbersSequenceSum", "n", "arithmeticSequenceSum", "a", "d", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "naturalNumbersSum1ToN", "n", "naturalNumbersSumMToN", "m", "factorialIterative", "n", "start", "result", "i", "factorialRecursive", "factorialMemoized", "memo", "traverse", "num", "end", "_a", "factorial", "table", "permutationsWithRepetition", "n", "__pow", "permutationsWithoutRepetition", "factorial", "combinationsWithoutRepetition", "dp", "i", "j"] + "sourcesContent": ["export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};", "/**\n * The simplest and straightforward method\n * but can become inefficient for extremely large numbers\n * due to growing computational time.\n */\nexport const factorialIterative = (n: number, start = 0): number => {\n\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n let result = 1;\n for (let i = start; i <= n; i++) {\n result *= i;\n }\n return result;\n};\n\n/**\n * A recursive approach is a classic method for calculating factorials\n * but can lead to stack overflow errors\n * for very large inputs because of deep recursion.\n * However, it's a direct translation\n * of the mathematical definition of factorial.\n */\nexport const factorialRecursive = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n // Base case: when n reaches start, return start instead of further reducing\n if (n === start) return start;\n\n // Recursive call\n return n * factorialRecursive(n - 1, start);\n};\n\n/**\n * Memoization (Top-Down Dynamic Programming).\n */\nexport const factorialMemoized = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n const memo = new Map();\n\n const traverse = (num: number, end: number): number => {\n if (num < end) return 1; // Adjust the base case to return 1 if we're below 'end'\n // if (num === 0) return 1;\n\n if (memo.has(num)) return memo.get(num) ?? 1;\n\n if (num === end) {\n memo.set(num, num);\n return num;\n }\n\n const result = num * traverse(num - 1, end);\n\n memo.set(num, result);\n\n return result;\n };\n\n return traverse(n, start);\n};\n\n/**\n * Tabulation (Bottom-Up Dynamic Programming).\n */\nexport const factorial = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === n) {\n return n === 0 ? 1 : n; // If start == n and n == 0, return 1 (0!), otherwise return n\n }\n\n if (start === 0) {\n start = 1;\n }\n\n const table = []; // new Array(n + 1);\n table[0] = 1;\n for (let i = 1; i <= n; i++) {\n table[i] = table[i - 1] * i;\n }\n return table[n] / table[start - 1];\n};", "import { factorial } from './factorial';\n\n/**\n * Permutations with repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - repetition is allowed\n *\n * Formula:\n * --------\n * n^r\n *\n * Intuition:\n * ----------\n * In other words, there are n possibilities for the first choice,\n * THEN there are n possibilities for the second choice, and so on,\n * multiplying each time.\n *\n * A Permutation is an ordered Combination.\n *\n * Example:\n * --------\n * Such as a lock that could be \"333\".\n */\nexport const permutationsWithRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return n ** r;\n};\n\n/**\n * Permutations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - no repetitions\n *\n * Formula:\n * --------\n * P(n,r) = n! / (n \u2212 r)!\n *\n * Intuition:\n * ----------\n * In this case, we have to reduce the number of available choices each time.\n * After choosing, say, number \"14\" we can't choose it again.\n * So, our first choice has 16 possibilities, and our next choice has 15 possibilities,\n * then 14, 13, 12, 11, ... etc.\n *\n * A Permutation is an ordered Combination.\n */\nexport const permutationsWithoutRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return factorial(n, n - r + 1);\n};\n\n/**\n * Combinations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - no repetitions\n *\n * And is also known as the Binomial Coefficient.\n * We can also use Pascal's Triangle to find the values.\n *\n * Formula:\n * --------\n * C(n, r) = C(n, n - r) = n! / (r! * (n\u2212r)!)\n *\n * Example:\n * --------\n * Such as lottery numbers (2, 14, 15, 27, 30, 33).\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42(n \u00D7 r)\n * Space Complexity: \uD835\uDC42(n \u00D7 r)\n */\nexport const combinationsWithoutRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n // Initialize a two-dimensional array (or matrix) [n + 1, r + 1].\n // The reason for n + 1 is to ensure that we can access indices directly equal to the value of n\n // without running out of bounds, as array indices start at 0.\n const dp = Array.from({ length: n + 1 }, () => Array(r + 1).fill(0));\n /*\n const dp: number[][] = [];\n for(let i=0; i<=n; i++) {\n dp[i] = [];\n for(let j=0; j<=r; j++) {\n dp[i][j] = 0;\n }\n }*/\n\n // Base cases: C(n, 0) = 1 and C(n, n) = 1 for any n.\n for (let i = 0; i <= n; i++) {\n dp[i][0] = 1;\n if (i <= r) {\n // Only fill this if i <= r to avoid filling non-existent cells\n dp[i][i] = 1;\n }\n }\n\n // Fill the table using the relation C(n, r) = C(n-1, r-1) + C(n-1, r)\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, r); j++) { // Only compute up to the minimum of i and r\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n }\n }\n\n return dp[n][r];\n};\n\n/**\n * Combinations with repetitions (multi-choose):\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - repetition is allowed\n *\n * Formula:\n * --------\n * (r + n \u2212 1)! / r!(n \u2212 1)! = C(r + n \u2212 1, r) = C(r + n \u2212 1, n \u2212 1)\n *\n * Example:\n * --------\n * - Coins in your pocket (5, 5, 5, 10, 10).\n * - Let us say there are five flavors of ice cream: banana, chocolate, lemon, strawberry and vanilla.\u00E5\n * We can have three scoops. How many variations will there be?\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42((r + n) \u00D7 r)\n * Space Complexity: \uD835\uDC42((r + n) \u00D7 r)\n */\nexport const combinationsWithRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n if(n === 0) return 1;\n\n // Calculate adjusted values for indices in the DP table\n const totalItems = r + n - 1;\n const chooseItems = r;\n\n // Initialize DP table\n const dp: number[][] = Array.from({ length: totalItems + 1 }, () => Array(chooseItems + 1).fill(0));\n\n // Base case initialization: C(i, 0) = 1 for all i, because there's one way to choose nothing\n for (let i = 0; i <= totalItems; i++) {\n dp[i][0] = 1;\n }\n\n for (let i = 1; i <= totalItems; i++) {\n for (let j = 1; j <= Math.min(i, chooseItems); j++) {\n dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];\n }\n }\n\n return dp[totalItems][chooseItems];\n};\n\n"], + "mappings": ";;;;;;;eAAO,IAAMA,EAAmB,CAACC,EAAaC,EAAoC,MAAa,CAC3F,GAAGA,IAAkB,IAAU,OAAOD,EAEnCC,EAAgB,IACfA,EAAgB,GAGpB,IAAMC,EAAcC,EAAA,GAAMF,GAC1B,OAAO,KAAK,MAAMD,EAAME,CAAW,EAAIA,CAC3C,ECNO,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AG,GAAKD,EAAY,IAC7BJ,EAAG,GAAG,GAAK,EAGf,QAAS,EAAI,EAAG,GAAKI,EAAY,IAC7B,QAASF,EAAI,EAAGA,GAAK,KAAK,IAAI,EAAGG,CAAW,EAAGH,IAC3CF,EAAG,GAAGE,GAAKF,EAAG,EAAI,GAAGE,GAAKF,EAAG,EAAI,GAAGE,EAAI,GAIhD,OAAOF,EAAGI,GAAYC,EAC1B", + "names": ["setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "stringToNumber", "value", "defaultNumber", "_a", "res", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "x", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "guid", "c", "newId", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "naturalNumbersSequenceSum", "n", "arithmeticSequenceSum", "a", "d", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "naturalNumbersSum1ToN", "n", "naturalNumbersSumMToN", "m", "factorialIterative", "n", "start", "result", "i", "factorialRecursive", "factorialMemoized", "memo", "traverse", "num", "end", "_a", "factorial", "table", "permutationsWithRepetition", "n", "__pow", "permutationsWithoutRepetition", "factorial", "combinationsWithoutRepetition", "dp", "i", "j", "combinationsWithRepetition", "totalItems", "chooseItems"] } diff --git a/dist/mz-math.min.js b/dist/mz-math.min.js index aa41bca..26d2383 100644 --- a/dist/mz-math.min.js +++ b/dist/mz-math.min.js @@ -5,10 +5,10 @@ https://github.com/mzusin/mz-math Licensed GPLv3 for open source use, or Commercial License for commercial use - https://github.com/mzusin/index/blob/main/LICENSE.md Copyright (c) 2023-present, Miriam Zusin */ -(()=>{var er=Object.defineProperty;var tr=Object.getOwnPropertySymbols;var Dr=Object.prototype.hasOwnProperty,Xr=Object.prototype.propertyIsEnumerable;var V=Math.pow,rr=(t,r,e)=>r in t?er(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,h=(t,r)=>{for(var e in r||(r={}))Dr.call(r,e)&&rr(t,e,r[e]);if(tr)for(var e of tr(r))Xr.call(r,e)&&rr(t,e,r[e]);return t};var M=(t,r)=>{for(var e in r)er(t,e,{get:r[e],enumerable:!0})};var st={};M(st,{v2:()=>ce,v2Distance:()=>ne,v2DivideScalar:()=>Pr,v2DotProduct:()=>et,v2FromPolarCoords:()=>ae,v2GetNormal:()=>it,v2Length:()=>rt,v2MulScalar:()=>Jr,v2Normalize:()=>L,v2SetLength:()=>ir,v2Sub:()=>z,v2Sum:()=>_r,v3:()=>ue,v3CrossProduct:()=>se,v3Distance:()=>oe,v3DivideScalar:()=>te,v3DotProduct:()=>ie,v3Length:()=>re,v3MulScalar:()=>W,v3Normalize:()=>w,v3Sub:()=>Kr,v3Sum:()=>Ur,v4:()=>me,vDistance:()=>ee,vDivideScalar:()=>X,vDotProduct:()=>R,vEqual:()=>ot,vLength:()=>B,vMulScalar:()=>D,vN:()=>nt,vNormalize:()=>H,vSub:()=>v,vSum:()=>C});var U={};M(U,{setDecimalPlaces:()=>c});var c=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=V(10,r);return Math.round(t*e)/e};var tt={};M(tt,{degreesToRadians:()=>Fr,getAnglesDistance:()=>or,getAnglesSub:()=>Q,getV2Angle:()=>N,getV2AngleBetween:()=>kr,getV2AngleInEllipse:()=>jr,getV3AngleBetween:()=>Qr,getVNAngleBetween:()=>nr,isAngleBetween:()=>Wr,isClockwise:()=>P,percentToAngle:()=>Zr,radiansToDegrees:()=>Or,setV2Angle:()=>J});var K={};M(K,{convertRange:()=>k,doRangesOverlap:()=>Yr,isNumber:()=>T,mod:()=>y,polarToCartesian:()=>Gr});var y=(t,r)=>(t%r+r)%r,k=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Yr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),T=t=>!isNaN(parseFloat(t))&&isFinite(t),Gr=(t,r,e,n=1/0)=>{let[o,i]=t,[s,u]=r;return[c(o+s*Math.cos(e),n),c(i+u*Math.sin(e),n)]};var N=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return c(e,r)},jr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return c(n,e)},J=(t,r,e=1/0)=>{let n=rt(t);return[c(Math.cos(r)*n,e),c(Math.sin(r)*n,e)]},Or=(t,r=1/0)=>{let e=t*(180/Math.PI);return c(e,r)},Fr=(t,r=1/0)=>{let e=t*(Math.PI/180);return c(e,r)},nr=(t,r,e=1/0)=>{let n=H(t),o=H(r),i=R(n,o),s=Math.acos(i);return c(s,e)},kr=(t,r,e=1/0)=>{let n=v(t,r),o=Math.atan2(n[1],n[0]);return c(o,e)},Qr=(t,r,e=1/0)=>nr(t,r,e),Wr=(t,r,e)=>{let n=Q(r,e),o=Q(r,t),i=Q(e,t),s=o+i;return Math.abs(s-n)<=.001},P=(t,r,e=0)=>(t=t%360,r=r%360,t=t),Q=(t,r,e=1/0)=>{let n=Math.abs(y(t,360)-y(r,360));return c(n<=180?n:360-n,e)},or=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=or(r,e,n);return P(r,e,n)?y(n+t*o/100,360):y(n-t*o/100,360)};var C=(t,r,e=1/0)=>{let n=[];for(let o=0;oC(t,r,e),Ur=(t,r,e=1/0)=>C(t,r,e),v=(t,r,e=1/0)=>{let n=[];for(let o=0;ov(t,r,e),Kr=(t,r,e=1/0)=>v(t,r,e),D=(t,r,e=1/0)=>{let n=[];for(let o=0;oD(t,r,e),W=(t,r,e=1/0)=>D(t,r,e),X=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oX(t,r,e),te=(t,r,e=1/0)=>X(t,r,e),B=(t,r=1/0)=>{let e=0;for(let n=0;nB(t,r),re=(t,r=1/0)=>B(t,r),ir=(t,r,e=1/0)=>{let n=N(t);return[c(Math.cos(n)*r,e),c(Math.sin(n)*r,e)]},ee=(t,r,e=1/0)=>{let n=v(t,r);return B(n,e)},ne=(t,r,e=1/0)=>{let n=v(t,r);return B(n,e)},oe=(t,r,e=1/0)=>{let n=v(t,r);return B(n,e)},H=(t,r=1/0)=>{let e=B(t),n=[];for(let o=0;oH(t,r),w=(t,r=1/0)=>H(t,r),R=(t,r,e=1/0)=>{let n=0;for(let o=0;oR(t,r,e),ie=(t,r,e=1/0)=>R(t,r,e),se=(t,r,e=1/0)=>[c(t[1]*r[2]-t[2]*r[1],e),c(t[2]*r[0]-t[0]*r[2],e),c(t[0]*r[1]-t[1]*r[0],e)],ce=(t=0)=>[t,t],ue=(t=0)=>[t,t,t],me=(t=0)=>[t,t,t,t],nt=(t,r=0)=>{if(t<0)throw new Error("N must be a non-negative number.");let e=[];for(let n=0;n{let e=[0,0];return e=ir(e,t),J(e,r)},ot=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=z(r,t);return[-c(n[1],e),c(n[0],e)]};var It={};M(It,{identity2:()=>Re,identity3:()=>ze,identity4:()=>Be,identityN:()=>Ee,isSingularMatrix:()=>We,m2Adjugate:()=>Vt,m2AppendRow:()=>Le,m2DeepCopy:()=>xt,m2Determinant:()=>Mt,m2DivideScalar:()=>sr,m2Inverse:()=>dt,m2MulScalar:()=>he,m2PrependRow:()=>Ae,m2Reset:()=>ye,m2Sub:()=>pe,m2Sum:()=>xe,m2Transpose:()=>le,m2x2:()=>ge,m3Adjugate:()=>Qe,m3AppendRow:()=>$e,m3DeepCopy:()=>ft,m3Determinant:()=>ke,m3DivideScalar:()=>Ve,m3Inverse:()=>yt,m3MulScalar:()=>Me,m3PrependRow:()=>Ce,m3Reset:()=>Ie,m3Sub:()=>be,m3Sum:()=>fe,m3Transpose:()=>de,m3x3:()=>ve,m4x4:()=>we,mAdjugate:()=>lt,mAppendCol:()=>Te,mAppendRow:()=>Ne,mDeepCopy:()=>I,mDelFirstColumn:()=>Ye,mDelFirstRow:()=>Xe,mDelLastColumn:()=>pt,mDelLastRow:()=>De,mDeterminant:()=>G,mDivideScalar:()=>Z,mEqual:()=>Oe,mGetColumn:()=>je,mGetFirstColumn:()=>Ge,mGetLastColumn:()=>bt,mInverse:()=>_,mMinor:()=>ht,mMul:()=>$,mMulScalar:()=>mt,mMulVector:()=>l,mNxM:()=>Se,mPrependCol:()=>He,mPrependRow:()=>qe,mReset:()=>at,mSub:()=>ut,mSum:()=>ct,mTranspose:()=>Y});var ct=(t,r,e=1/0)=>{let n=[];for(let o=0;oct(t,r,e),fe=(t,r,e=1/0)=>ct(t,r,e),ut=(t,r,e=1/0)=>{let n=[];for(let o=0;out(t,r,e),be=(t,r,e=1/0)=>ut(t,r,e),mt=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(D(o,r,e));return n},he=(t,r,e=1/0)=>mt(t,r,e),Me=(t,r,e=1/0)=>mt(t,r,e),Z=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(X(o,r,e));return n},sr=(t,r,e=1/0)=>Z(t,r,e),Ve=(t,r,e=1/0)=>Z(t,r,e),Y=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oY(t),de=t=>Y(t),at=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nat(t,r),Ie=(t,r=0)=>at(t,r),ge=(t=0)=>[[t,t],[t,t]],ve=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],we=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],Se=(t,r,e=0)=>{if(t<=0||r<=0)throw new Error("M and N must be positive numbers.");let n=[];for(let o=0;o[[1,0],[0,1]],ze=()=>[[1,0,0],[0,1,0],[0,0,1]],Be=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Ee=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;eI(t),ft=t=>I(t),Te=(t,r)=>{if(t.length<=0)return[];let e=I(t);for(let n=0;n{if(t.length<=0)return[];let e=I(t);for(let n=0;n{let e=I(t);return e.push(r),e},Le=(t,r)=>{let e=xt(t);return e.push(r),e},$e=(t,r)=>{let e=ft(t);return e.push(r),e},qe=(t,r)=>{let e=I(t);return e.unshift(r),e},Ae=(t,r)=>{let e=xt(t);return e.unshift(r),e},Ce=(t,r)=>{let e=ft(t);return e.unshift(r),e},De=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},Xe=t=>{if(t.length<=0)return[];let r=I(t);return r.shift(),r},pt=t=>{if(t.length<=0)return[];let r=I(t);for(let e=0;e{if(t.length<=0)return[];let r=I(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=Fe(t,r,e);return G(o)},G=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return Mt(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},ke=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return G(t)},Vt=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},Qe=t=>lt(t),lt=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return Vt(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return G(t)===0},dt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=Mt(t);if(e===0)return null;let n=Vt(t);return n===null?null:sr(n,e,r)},yt=(t,r=1/0)=>_(t,r),_=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=G(t),o=lt(t);return o===null?null:Z(o,n,r)};var vt={};M(vt,{m2ReflectionOrigin:()=>Sn,m2ReflectionOriginH:()=>Rn,m2ReflectionX:()=>Tn,m2ReflectionXH:()=>Hn,m2ReflectionY:()=>Nn,m2ReflectionYH:()=>Ln,m2ReflectionYmX:()=>En,m2RotateAroundPointH:()=>rn,m2Rotation:()=>cr,m2RotationAroundPointH:()=>ur,m2RotationH:()=>gt,m2Scale:()=>pr,m2ScaleAtPointH:()=>xn,m2ScaleAtPointHMatrix:()=>fr,m2ScaleH:()=>br,m2ScaleX:()=>hn,m2ScaleXH:()=>Mn,m2ScaleY:()=>vn,m2ScaleYH:()=>wn,m2ShearingX:()=>Gn,m2ShearingY:()=>Yn,m2ToCSS:()=>Ze,m2Translation:()=>Je,m2TranslationH:()=>j,m2hToCSS:()=>_e,m2hToCSS3d:()=>Ue,m3ReflectionOrigin:()=>zn,m3ReflectionOriginH:()=>Bn,m3ReflectionXY:()=>Dn,m3ReflectionXYH:()=>Xn,m3ReflectionXZ:()=>An,m3ReflectionXZH:()=>Cn,m3ReflectionYZ:()=>$n,m3ReflectionYZH:()=>qn,m3RotationX:()=>mr,m3RotationXH:()=>on,m3RotationY:()=>ar,m3RotationYH:()=>cn,m3RotationZ:()=>xr,m3RotationZH:()=>mn,m3Scale:()=>hr,m3ScaleH:()=>pn,m3ScaleX:()=>Vn,m3ScaleXH:()=>ln,m3ScaleY:()=>dn,m3ScaleYH:()=>yn,m3ScaleZ:()=>In,m3ScaleZH:()=>gn,m3Translation:()=>Pe,m3TranslationH:()=>tn,m3hToCSS3d:()=>Ke,v2Rotate:()=>en,v2RotateH:()=>nn,v2Scale:()=>fn,v3RotateX:()=>sn,v3RotateY:()=>un,v3RotateZ:()=>an,v3Scale:()=>bn});var Ze=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1];return`matrix(${r}, ${e}, ${n}, ${o}, 0, 0)`},_e=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${s})`},Ue=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${s}, 0, 1)`},Ke=t=>`matrix3d( +(()=>{var er=Object.defineProperty;var tr=Object.getOwnPropertySymbols;var Dr=Object.prototype.hasOwnProperty,Xr=Object.prototype.propertyIsEnumerable;var V=Math.pow,rr=(t,r,e)=>r in t?er(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,h=(t,r)=>{for(var e in r||(r={}))Dr.call(r,e)&&rr(t,e,r[e]);if(tr)for(var e of tr(r))Xr.call(r,e)&&rr(t,e,r[e]);return t};var M=(t,r)=>{for(var e in r)er(t,e,{get:r[e],enumerable:!0})};var st={};M(st,{v2:()=>ce,v2Distance:()=>ne,v2DivideScalar:()=>Pr,v2DotProduct:()=>et,v2FromPolarCoords:()=>ae,v2GetNormal:()=>it,v2Length:()=>rt,v2MulScalar:()=>Jr,v2Normalize:()=>A,v2SetLength:()=>ir,v2Sub:()=>z,v2Sum:()=>_r,v3:()=>ue,v3CrossProduct:()=>se,v3Distance:()=>oe,v3DivideScalar:()=>te,v3DotProduct:()=>ie,v3Length:()=>re,v3MulScalar:()=>W,v3Normalize:()=>w,v3Sub:()=>Kr,v3Sum:()=>Ur,v4:()=>me,vDistance:()=>ee,vDivideScalar:()=>X,vDotProduct:()=>R,vEqual:()=>ot,vLength:()=>B,vMulScalar:()=>D,vN:()=>nt,vNormalize:()=>H,vSub:()=>v,vSum:()=>C});var U={};M(U,{setDecimalPlaces:()=>c});var c=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=V(10,r);return Math.round(t*e)/e};var tt={};M(tt,{degreesToRadians:()=>Fr,getAnglesDistance:()=>or,getAnglesSub:()=>Q,getV2Angle:()=>N,getV2AngleBetween:()=>kr,getV2AngleInEllipse:()=>Gr,getV3AngleBetween:()=>Qr,getVNAngleBetween:()=>nr,isAngleBetween:()=>Wr,isClockwise:()=>P,percentToAngle:()=>Zr,radiansToDegrees:()=>Or,setV2Angle:()=>J});var K={};M(K,{convertRange:()=>k,doRangesOverlap:()=>Yr,isNumber:()=>T,mod:()=>y,polarToCartesian:()=>jr});var y=(t,r)=>(t%r+r)%r,k=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Yr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),T=t=>!isNaN(parseFloat(t))&&isFinite(t),jr=(t,r,e,n=1/0)=>{let[o,i]=t,[s,u]=r;return[c(o+s*Math.cos(e),n),c(i+u*Math.sin(e),n)]};var N=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return c(e,r)},Gr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return c(n,e)},J=(t,r,e=1/0)=>{let n=rt(t);return[c(Math.cos(r)*n,e),c(Math.sin(r)*n,e)]},Or=(t,r=1/0)=>{let e=t*(180/Math.PI);return c(e,r)},Fr=(t,r=1/0)=>{let e=t*(Math.PI/180);return c(e,r)},nr=(t,r,e=1/0)=>{let n=H(t),o=H(r),i=R(n,o),s=Math.acos(i);return c(s,e)},kr=(t,r,e=1/0)=>{let n=v(t,r),o=Math.atan2(n[1],n[0]);return c(o,e)},Qr=(t,r,e=1/0)=>nr(t,r,e),Wr=(t,r,e)=>{let n=Q(r,e),o=Q(r,t),i=Q(e,t),s=o+i;return Math.abs(s-n)<=.001},P=(t,r,e=0)=>(t=t%360,r=r%360,t=t),Q=(t,r,e=1/0)=>{let n=Math.abs(y(t,360)-y(r,360));return c(n<=180?n:360-n,e)},or=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=or(r,e,n);return P(r,e,n)?y(n+t*o/100,360):y(n-t*o/100,360)};var C=(t,r,e=1/0)=>{let n=[];for(let o=0;oC(t,r,e),Ur=(t,r,e=1/0)=>C(t,r,e),v=(t,r,e=1/0)=>{let n=[];for(let o=0;ov(t,r,e),Kr=(t,r,e=1/0)=>v(t,r,e),D=(t,r,e=1/0)=>{let n=[];for(let o=0;oD(t,r,e),W=(t,r,e=1/0)=>D(t,r,e),X=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oX(t,r,e),te=(t,r,e=1/0)=>X(t,r,e),B=(t,r=1/0)=>{let e=0;for(let n=0;nB(t,r),re=(t,r=1/0)=>B(t,r),ir=(t,r,e=1/0)=>{let n=N(t);return[c(Math.cos(n)*r,e),c(Math.sin(n)*r,e)]},ee=(t,r,e=1/0)=>{let n=v(t,r);return B(n,e)},ne=(t,r,e=1/0)=>{let n=v(t,r);return B(n,e)},oe=(t,r,e=1/0)=>{let n=v(t,r);return B(n,e)},H=(t,r=1/0)=>{let e=B(t),n=[];for(let o=0;oH(t,r),w=(t,r=1/0)=>H(t,r),R=(t,r,e=1/0)=>{let n=0;for(let o=0;oR(t,r,e),ie=(t,r,e=1/0)=>R(t,r,e),se=(t,r,e=1/0)=>[c(t[1]*r[2]-t[2]*r[1],e),c(t[2]*r[0]-t[0]*r[2],e),c(t[0]*r[1]-t[1]*r[0],e)],ce=(t=0)=>[t,t],ue=(t=0)=>[t,t,t],me=(t=0)=>[t,t,t,t],nt=(t,r=0)=>{if(t<0)throw new Error("N must be a non-negative number.");let e=[];for(let n=0;n{let e=[0,0];return e=ir(e,t),J(e,r)},ot=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=z(r,t);return[-c(n[1],e),c(n[0],e)]};var It={};M(It,{identity2:()=>Re,identity3:()=>ze,identity4:()=>Be,identityN:()=>Ee,isSingularMatrix:()=>We,m2Adjugate:()=>Vt,m2AppendRow:()=>Ae,m2DeepCopy:()=>xt,m2Determinant:()=>Mt,m2DivideScalar:()=>sr,m2Inverse:()=>dt,m2MulScalar:()=>he,m2PrependRow:()=>qe,m2Reset:()=>ye,m2Sub:()=>pe,m2Sum:()=>xe,m2Transpose:()=>le,m2x2:()=>ge,m3Adjugate:()=>Qe,m3AppendRow:()=>Le,m3DeepCopy:()=>ft,m3Determinant:()=>ke,m3DivideScalar:()=>Ve,m3Inverse:()=>yt,m3MulScalar:()=>Me,m3PrependRow:()=>Ce,m3Reset:()=>Ie,m3Sub:()=>be,m3Sum:()=>fe,m3Transpose:()=>de,m3x3:()=>ve,m4x4:()=>we,mAdjugate:()=>lt,mAppendCol:()=>Te,mAppendRow:()=>Ne,mDeepCopy:()=>I,mDelFirstColumn:()=>Ye,mDelFirstRow:()=>Xe,mDelLastColumn:()=>pt,mDelLastRow:()=>De,mDeterminant:()=>j,mDivideScalar:()=>Z,mEqual:()=>Oe,mGetColumn:()=>Ge,mGetFirstColumn:()=>je,mGetLastColumn:()=>bt,mInverse:()=>_,mMinor:()=>ht,mMul:()=>L,mMulScalar:()=>mt,mMulVector:()=>l,mNxM:()=>Se,mPrependCol:()=>He,mPrependRow:()=>$e,mReset:()=>at,mSub:()=>ut,mSum:()=>ct,mTranspose:()=>Y});var ct=(t,r,e=1/0)=>{let n=[];for(let o=0;oct(t,r,e),fe=(t,r,e=1/0)=>ct(t,r,e),ut=(t,r,e=1/0)=>{let n=[];for(let o=0;out(t,r,e),be=(t,r,e=1/0)=>ut(t,r,e),mt=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(D(o,r,e));return n},he=(t,r,e=1/0)=>mt(t,r,e),Me=(t,r,e=1/0)=>mt(t,r,e),Z=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(X(o,r,e));return n},sr=(t,r,e=1/0)=>Z(t,r,e),Ve=(t,r,e=1/0)=>Z(t,r,e),Y=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oY(t),de=t=>Y(t),at=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nat(t,r),Ie=(t,r=0)=>at(t,r),ge=(t=0)=>[[t,t],[t,t]],ve=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],we=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],Se=(t,r,e=0)=>{if(t<=0||r<=0)throw new Error("M and N must be positive numbers.");let n=[];for(let o=0;o[[1,0],[0,1]],ze=()=>[[1,0,0],[0,1,0],[0,0,1]],Be=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Ee=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;eI(t),ft=t=>I(t),Te=(t,r)=>{if(t.length<=0)return[];let e=I(t);for(let n=0;n{if(t.length<=0)return[];let e=I(t);for(let n=0;n{let e=I(t);return e.push(r),e},Ae=(t,r)=>{let e=xt(t);return e.push(r),e},Le=(t,r)=>{let e=ft(t);return e.push(r),e},$e=(t,r)=>{let e=I(t);return e.unshift(r),e},qe=(t,r)=>{let e=xt(t);return e.unshift(r),e},Ce=(t,r)=>{let e=ft(t);return e.unshift(r),e},De=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},Xe=t=>{if(t.length<=0)return[];let r=I(t);return r.shift(),r},pt=t=>{if(t.length<=0)return[];let r=I(t);for(let e=0;e{if(t.length<=0)return[];let r=I(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=Fe(t,r,e);return j(o)},j=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return Mt(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},ke=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return j(t)},Vt=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},Qe=t=>lt(t),lt=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return Vt(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return j(t)===0},dt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=Mt(t);if(e===0)return null;let n=Vt(t);return n===null?null:sr(n,e,r)},yt=(t,r=1/0)=>_(t,r),_=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=j(t),o=lt(t);return o===null?null:Z(o,n,r)};var vt={};M(vt,{m2ReflectionOrigin:()=>Sn,m2ReflectionOriginH:()=>Rn,m2ReflectionX:()=>Tn,m2ReflectionXH:()=>Hn,m2ReflectionY:()=>Nn,m2ReflectionYH:()=>An,m2ReflectionYmX:()=>En,m2RotateAroundPointH:()=>rn,m2Rotation:()=>cr,m2RotationAroundPointH:()=>ur,m2RotationH:()=>gt,m2Scale:()=>pr,m2ScaleAtPointH:()=>xn,m2ScaleAtPointHMatrix:()=>fr,m2ScaleH:()=>br,m2ScaleX:()=>hn,m2ScaleXH:()=>Mn,m2ScaleY:()=>vn,m2ScaleYH:()=>wn,m2ShearingX:()=>jn,m2ShearingY:()=>Yn,m2ToCSS:()=>Ze,m2Translation:()=>Je,m2TranslationH:()=>G,m2hToCSS:()=>_e,m2hToCSS3d:()=>Ue,m3ReflectionOrigin:()=>zn,m3ReflectionOriginH:()=>Bn,m3ReflectionXY:()=>Dn,m3ReflectionXYH:()=>Xn,m3ReflectionXZ:()=>qn,m3ReflectionXZH:()=>Cn,m3ReflectionYZ:()=>Ln,m3ReflectionYZH:()=>$n,m3RotationX:()=>mr,m3RotationXH:()=>on,m3RotationY:()=>ar,m3RotationYH:()=>cn,m3RotationZ:()=>xr,m3RotationZH:()=>mn,m3Scale:()=>hr,m3ScaleH:()=>pn,m3ScaleX:()=>Vn,m3ScaleXH:()=>ln,m3ScaleY:()=>dn,m3ScaleYH:()=>yn,m3ScaleZ:()=>In,m3ScaleZH:()=>gn,m3Translation:()=>Pe,m3TranslationH:()=>tn,m3hToCSS3d:()=>Ke,v2Rotate:()=>en,v2RotateH:()=>nn,v2Scale:()=>fn,v3RotateX:()=>sn,v3RotateY:()=>un,v3RotateZ:()=>an,v3Scale:()=>bn});var Ze=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1];return`matrix(${r}, ${e}, ${n}, ${o}, 0, 0)`},_e=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${s})`},Ue=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${s}, 0, 1)`},Ke=t=>`matrix3d( ${t[0][0]}, ${t[0][1]}, ${t[0][2]}, ${t[0][3]}, ${t[1][0]}, ${t[1][1]}, ${t[1][2]}, ${t[1][3]}, ${t[2][0]}, ${t[2][1]}, ${t[2][2]}, ${t[2][3]}, ${t[3][0]}, ${t[3][1]}, ${t[3][2]}, ${t[3][3]} - )`,Je=(t,r=1/0)=>[[1,0],[0,1],[c(t[0],r),c(t[1],r)]],Pe=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[c(t[0],r),c(t[1],r),c(t[2],r)]],j=(t,r=1/0)=>[[1,0,c(t[0],r)],[0,1,c(t[1],r)],[0,0,1]],tn=(t,r=1/0)=>[[1,0,0,c(t[0],r)],[0,1,0,c(t[1],r)],[0,0,1,c(t[2],r)],[0,0,0,1]],cr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},gt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},ur=(t,r,e=!0,n=1/0)=>{let o=j(r,n),i=gt(t,e,n),s=j(W(r,-1),n),u=$(o,i);return $(u,s)},rn=(t,r,e,n=!0,o=1/0)=>{let i=ur(t,r,n,o);return l(i,e)},en=(t,r,e=!0,n=1/0)=>{let o=L(r);return l(cr(t,e,n),o)},nn=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(gt(t,e,n),o)},mr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},on=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0,0],[0,n,-o,0],[0,o,n,0],[0,0,0,1]]:[[1,0,0,0],[0,n,o,0],[0,-o,n,0],[0,0,0,1]]},sn=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(mr(t,e,n),o)},ar=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},cn=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},un=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(ar(t,e,n),o)},xr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},mn=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0,0],[o,n,0,0],[0,0,1,0],[0,0,0,1]]:[[n,o,0,0],[-o,n,0,0],[0,0,1,0],[0,0,0,1]]},an=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(xr(t,e,n),o)},fr=(t,r,e=1/0)=>{let n=j(r,e),o=br(t),i=j(W(r,-1),e),s=$(n,o);return $(s,i)},xn=(t,r,e,n=1/0)=>{let o=fr(t,r,n);return l(o,e)},pr=t=>[[t[0],0],[0,t[1]]],fn=(t,r)=>l(pr(t),r),br=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],hr=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],pn=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],bn=(t,r)=>l(hr(t),r),hn=t=>[[t,0],[0,1]],Mn=t=>[[t,0,0],[0,1,0],[0,0,1]],Vn=t=>[[t,0,0],[0,1,0],[0,0,1]],ln=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],dn=t=>[[1,0,0],[0,t,0],[0,0,1]],yn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],In=t=>[[1,0,0],[0,1,0],[0,0,t]],gn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],vn=t=>[[1,0],[0,t]],wn=t=>[[1,0,0],[0,t,0],[0,0,1]],Sn=()=>[[-1,0],[0,-1]],Rn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],zn=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],Bn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],En=()=>[[0,-1],[-1,0]],Tn=()=>[[1,0],[0,-1]],Hn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Nn=()=>[[-1,0],[0,1]],Ln=()=>[[-1,0,0],[0,1,0],[0,0,1]],$n=()=>[[-1,0,0],[0,1,0],[0,0,1]],qn=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],An=()=>[[1,0,0],[0,-1,0],[0,0,1]],Cn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],Dn=()=>[[1,0,0],[0,1,0],[0,0,-1]],Xn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Yn=t=>[[1,t],[0,1]],Gn=t=>[[1,0],[t,1]];var wt={};M(wt,{getRandom:()=>d,getRandomBoolean:()=>jn,getRandomInt:()=>Mr,getRandomItemFromArray:()=>On});var d=(t,r,e=1/0)=>c(Math.random()*(r-t)+t,e),Mr=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),jn=()=>Math.random()<.5,On=t=>{let r=Mr(0,t.length-1);return t[r]};var St={};M(St,{stringToNumber:()=>Fn});var Fn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Lt={};M(Lt,{v2CubicBezierBBox:()=>xo,v2CubicBezierCurve:()=>lr,v2CubicBezierCurveExtrema:()=>gr,v2CubicBezierCurveNormal:()=>mo,v2CubicBezierCurveTangent:()=>yr,v2QuadraticBezierBBox:()=>ao,v2QuadraticBezierCurve:()=>Vr,v2QuadraticBezierCurveExtrema:()=>Ir,v2QuadraticBezierCurveNormal:()=>uo,v2QuadraticBezierCurveTangent:()=>dr,v3CubicBezierCurve:()=>io,v3CubicBezierCurveTangent:()=>co,v3QuadraticBezierCurve:()=>oo,v3QuadraticBezierCurveTangent:()=>so});var Tt={};M(Tt,{dxArcCos:()=>Kn,dxArcCot:()=>Pn,dxArcSin:()=>Un,dxArcTan:()=>Jn,dxCos:()=>Wn,dxCot:()=>_n,dxPolynomial:()=>kn,dxSin:()=>Qn,dxTan:()=>Zn,dxV2CubicBezierCurve:()=>Bt,dxV2QuadraticBezierCurve:()=>Rt,dxV3CubicBezierCurve:()=>Et,dxV3QuadraticBezierCurve:()=>zt});var kn=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],s=o[1];n+=i*s*Math.pow(t,s-1)}return c(n,e)},Rt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},zt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},Bt=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,a=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i)]},Et=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,a=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+a*o[2],i)]},Qn=(t,r=1/0)=>c(Math.cos(t),r),Wn=(t,r=1/0)=>c(-Math.sin(t),r),Zn=(t,r=1/0)=>c(1/V(Math.cos(t),2),r),_n=(t,r=1/0)=>c(-1/V(Math.sin(t),2),r),Un=(t,r=1/0)=>c(1/Math.sqrt(1-V(t,2)),r),Kn=(t,r=1/0)=>c(-1/Math.sqrt(1-V(t,2)),r),Jn=(t,r=1/0)=>c(1/(1+V(t,2)),r),Pn=(t,r=1/0)=>c(-1/(1+V(t,2)),r);var Ht={};M(Ht,{getLinearEquationBy2Points:()=>no,linearEquation:()=>q,linearEquationSystem2:()=>to,linearEquationSystem3:()=>ro,linearEquationSystemN:()=>eo});var q=(t,r=1/0)=>{let e=t[0],n=t[1],i=t[2]-n;return e===0&&i===0?1/0:e===0?NaN:c(i/e,r)},to=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=dt(n);if(o===null)return null;let i=[t[2],r[2]];return l(o,i,e)},ro=(t,r,e,n=1/0)=>{let o=[[t[0],t[1],t[2]],[r[0],r[1],r[2]],[e[0],e[1],e[2]]],i=yt(o);if(i===null)return null;let s=[t[3],r[3],e[3]];return l(i,s,n)},eo=(t,r=1/0)=>{if(t.length<=0)return null;let e=pt(t),n=_(e);if(n===null)return null;let o=bt(t);return l(n,o,r)},no=(t,r)=>{let[e,n]=z(r,t),[o,i]=t;if(e===0)return{slope:void 0,xIntercept:o,yIntercept:void 0,formula:`x = ${o}`};let s=n/e,u=i-s*o,m="";return s===0?m=`y = ${u}`:(m=`y = ${s===1?"":s}x`,u!==0&&(m+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:s,xIntercept:void 0,yIntercept:u,formula:m}};var Nt=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=q([n,o,i],r);return T(f)?[f]:[]}let s=o-i,u=n*n-4*e*s;if(u<0)return[];if(u===0)return[c(-n/(2*e),r)];let m=2*e,a=Math.sqrt(u);return[c((-n+a)/m,r),c((-n-a)/m,r)]};var Vr=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},oo=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},lr=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,a=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i)]},io=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,a=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+a*o[2],i)]},dr=(t,r,e,n,o=1/0)=>{let i=Rt(t,r,e,n);return L(i,o)},so=(t,r,e,n,o=1/0)=>{let i=zt(t,r,e,n);return w(i,o)},yr=(t,r,e,n,o,i=1/0)=>{let s=Bt(t,r,e,n,o);return L(s,i)},co=(t,r,e,n,o,i=1/0)=>{let s=Et(t,r,e,n,o);return w(s,i)},uo=(t,r,e,n,o=1/0)=>{let i=dr(t,r,e,n,o);return[-i[1],i[0]]},mo=(t,r,e,n,o,i=1/0)=>{let s=yr(t,r,e,n,o,i);return[-s[1],s[0]]},Ir=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=q([o,i,0],n),m=2*t[1]-4*r[1]+2*e[1],a=-2*t[1]+2*r[1],p=q([m,a,0],n),x=[];return T(u)&&x.push(u),T(p)&&x.push(p),x},gr=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],s=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],m=[i,s,u,0],a=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],x=[a,f,p,0],b=Nt(m,o).filter(g=>g>=0&&g<=1),S=Nt(x,o).filter(g=>g>=0&&g<=1);return[...b,...S].length===2?[...b,...S]:null},ao=(t,r,e,n=1/0)=>{let o=Ir(t,r,e),i=1/0,s=1/0,u=-1/0,m=-1/0;for(let a of o){let f=Vr(a,t,r,e),p=f[0],x=f[1];i=Math.min(i,p),u=Math.max(u,p),s=Math.min(s,x),m=Math.max(m,x)}return i=c(Math.min(i,t[0],e[0]),n),u=c(Math.max(u,t[0],e[0]),n),s=c(Math.min(s,t[1],e[1]),n),m=c(Math.max(m,t[1],e[1]),n),{x:i,y:s,w:Math.abs(u-i),h:Math.abs(m-s),x2:u,y2:m}},xo=(t,r,e,n,o=1/0)=>{let i=gr(t,r,e,n)||[],s=1/0,u=1/0,m=-1/0,a=-1/0;for(let f of i){let p=lr(f,t,r,e,n),x=p[0],b=p[1];s=Math.min(s,x!=null?x:1/0),m=Math.max(m,x!=null?x:-1/0),u=Math.min(u,b!=null?b:1/0),a=Math.max(a,b!=null?b:-1/0)}return s=c(Math.min(s,t[0],n[0]),o),m=c(Math.max(m,t[0],n[0]),o),u=c(Math.min(u,t[1],n[1]),o),a=c(Math.max(a,t[1],n[1]),o),{x:s,y:u,w:Math.abs(m-s),h:Math.abs(a-u),x2:m,y2:a}};var $t={};M($t,{circleMovement:()=>vr,circleMovementAfterMouse:()=>fo,ellipseMovement:()=>wr,ellipseMovementAfterMouse:()=>po,lissajousCurve:()=>ho,sineWaveMovement:()=>bo});var vr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),fo=(t,r,e)=>{let n=z(t,r),o=N(n);return o=k(o,0,Math.PI*2,0,Math.PI),vr(r,o,e)},wr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),po=(t,r,e)=>{let n=z(t,r),o=N(n);return o=k(o,0,Math.PI*2,0,Math.PI),wr(r,o,e[0],e[1])},bo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},ho=(t,r,e,n,o,i,s)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-s)];var Dt={};M(Dt,{getColorsDelta:()=>$o,getRandomGrayscaleHSLColor:()=>go,getRandomHSLColor:()=>Ct,getRandomHSLColorWithHue:()=>lo,getRandomHSLColorWithLightness:()=>Io,getRandomHSLColorWithSaturation:()=>yo,getRandomHSLColorWithinRanges:()=>vo,getRandomHexColor:()=>Vo,getRandomRGBColor:()=>Mo,getShiftedHue:()=>Ho,getShiftedLightness:()=>No,getShiftedSaturation:()=>Lo,hexToRgb:()=>Eo,hslToHex:()=>zr,hslToRgb:()=>Rr,labToRgb:()=>To,rgbToHex:()=>Bo,rgbToHsl:()=>zo,rgbToLab:()=>At});var Mo=()=>{let t=Ct();return Rr(t)},Vo=()=>{let t=Ct();return zr(t)},Ct=()=>{let t=d(1,360),r=d(0,100),e=d(0,100);return[t,r,e]},lo=t=>{let r=d(0,100),e=d(0,100);return[t,r,e]},yo=t=>{let r=d(1,360),e=d(0,100);return[r,t,e]},Io=t=>{let r=d(1,360),e=d(0,100);return[r,e,t]},go=()=>[0,0,d(0,100)],vo=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let s=d(t,r),u=d(e,n),m=d(o,i);return[s,u,m]},wo=t=>(t*=60,t<0&&(t+=360),t),So=(t,r,e,n=void 0,o=void 0)=>{if(n=n===void 0?Math.min(t,r,e):n,o=o===void 0?Math.max(t,r,e):o,n===o)return 0;let i=o-n,s=0;return o===t&&(s=(r-e)/i+(r(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,(n+o)/2*100),Ro=(t,r,e,n=void 0,o=void 0,i=void 0)=>(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,n===o?0:(i=i===void 0?Sr(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),zo=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255,i=Math.min(e,n,o),s=Math.max(e,n,o),u=Sr(e,n,o,i,s),m=Ro(e,n,o,i,s,u),a=So(e,n,o,i,s);return a>360||m>100||u>100?[0,0,100]:a<0||m<0||u<0?[0,0,0]:[c(a,r),c(m,r),c(u,r)]},qt=(t,r,e)=>(e<0&&(e+=1),e>1&&(e-=1),e*6<1?r+(t-r)*6*e:e*2<1?t:e*3<2?r+(t-r)*(.666-e)*6:r),Rr=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let b=o*255;return[b,b,b]}let i=o<.5?o*(1+n):o+n-o*n,s=2*o-i,u=e+.333,m=e,a=e-.333,f=qt(i,s,u),p=qt(i,s,m),x=qt(i,s,a);return f*=255,p*=255,x*=255,f>255||p>255||x>255?[255,255,255]:f<0||p<0||x<0?[0,0,0]:[c(f,r),c(p,r),c(x,r)]},zr=t=>{if(t[0]>360||t[1]>100||t[2]>100)return"#ffffff";if(t[0]<0||t[1]<0||t[2]<0)return"#000000";let r=t[0]/360,e=t[1]/100,n=t[2]/100,o,i,s;if(e===0)o=i=s=n;else{let m=(p,x,b)=>(b<0&&(b+=1),b>1&&(b-=1),b<.16666666666666666?p+(x-p)*6*b:b<.5?x:b<.6666666666666666?p+(x-p)*(.6666666666666666-b)*6:p),a=n<.5?n*(1+e):n+e-n*e,f=2*n-a;o=m(f,a,r+1/3),i=m(f,a,r),s=m(f,a,r-1/3)}let u=m=>{let a=Math.round(m*255).toString(16);return a.length===1?"0"+a:a};return`#${u(o)}${u(i)}${u(s)}`},Bo=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Eo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,m,a,f)=>m+m+a+a+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),s=parseInt(n[3],16);return[o,i,s]},At=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;let i=(e*.4124+n*.3576+o*.1805)/.95047,s=(e*.2126+n*.7152+o*.0722)/1,u=(e*.0193+n*.1192+o*.9505)/1.08883;return i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,[c(116*s-16,r),c(500*(i-s),r),c(200*(s-u),r)]},To=(t,r=1/0)=>{let e=(t[0]+16)/116,n=t[1]/500+e,o=e-t[2]/200;n=.95047*(n*n*n>.008856?n*n*n:(n-16/116)/7.787),e=1*(e*e*e>.008856?e*e*e:(e-16/116)/7.787),o=1.08883*(o*o*o>.008856?o*o*o:(o-16/116)/7.787);let i=n*3.2406+e*-1.5372+o*-.4986,s=n*-.9689+e*1.8758+o*.0415,u=n*.0557+e*-.204+o*1.057;return i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:12.92*u,[c(Math.max(0,Math.min(1,i))*255,r),c(Math.max(0,Math.min(1,s))*255,r),c(Math.max(0,Math.min(1,u))*255,r)]},Ho=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=y(e,360)),[e,t[1],t[2]]},No=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=y(e,100)),[t[0],t[1],e]},Lo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},$o=(t,r,e=1/0)=>{let n=At(t,e),o=At(r,e),i=n[0]-o[0],s=n[1]-o[1],u=n[2]-o[2],m=Math.sqrt(n[1]*n[1]+n[2]*n[2]),a=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=m-a,p=s*s+u*u-f*f;p=p<0?0:Math.sqrt(p);let x=1+.045*m,b=1+.015*m,S=i/1,A=f/x,g=p/b,F=S*S+A*A+g*g;return F<0?0:Math.sqrt(F)};var Br={};var Xt={};M(Xt,{guid:()=>qo,newId:()=>Ao});var qo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),Ao=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var Yt={};M(Yt,{circleCollide:()=>Do,convexPolygonsCollide:()=>Xo,rectCollide:()=>Co});var Co=(t,r)=>t.x<=r.x+r.w&&t.x+t.w>=r.x&&t.y<=r.y+r.h&&t.h+t.y>=r.y,Do=(t,r)=>{let e=Math.abs(t.cx-r.cx),n=Math.abs(t.cy-r.cy);return Math.sqrt(e*e+n*n)<=t.r+r.r},Er=t=>{let r=[];for(let e=0;e{let e=[];e.push(...Er(t)),e.push(...Er(r));for(let n of e){let o=it(n[0],n[1]),i=Tr(t,o),s=Tr(r,o);if(!(i.max>=s.min&&s.max>=i.min))return!1}return!0},Tr=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=et(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var Gt={};M(Gt,{animate:()=>Yo});var Yo=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,s=!1,u,m=()=>{e=void 0,o=void 0,i=void 0,s=!1,n!==void 0&&window.cancelAnimationFrame(n)},a=()=>{m(),S()},f=()=>{s=!1},p=()=>{s=!0},x=E=>{e===void 0&&(e=E),o=E-e,s&&i!==E&&typeof t.callback=="function"&&t.callback(Pt()),o<=r?(i=E,n=window.requestAnimationFrame(x)):m()},b=(E,Cr)=>{a(),typeof t.resizeCallback=="function"&&t.resizeCallback(E,Cr)},S=()=>{e=void 0,o=void 0,i=void 0,s=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(b),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(x)},A=()=>o,g=()=>s,F=()=>e,qr=()=>{if(!(r===1/0||o===void 0))return o*100/r},Ar=()=>u,Pt=()=>({start:S,stop:m,pause:f,resume:p,restart:a,isAnimating:g,getElapsedTime:A,getStartTime:F,getPercent:qr,getResizeObserver:Ar});return Pt()};var jt={};M(jt,{getCircleCircumference:()=>Go,getEllipseCircumference:()=>jo,getSquareInCircleSide:()=>Fo,isAngleInCircleArc:()=>Oo});var Go=(t,r=1/0)=>c(2*Math.PI*t,r),jo=(t,r,e=1/0)=>c(2*Math.PI*Math.sqrt((V(t,2)+V(r,2))/2),e),Oo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Fo=(t,r=1/0)=>c(t*2/Math.sqrt(2),r);var Ot={};M(Ot,{arithmeticSequenceSum:()=>Qo,naturalNumbersSequenceSum:()=>ko});var ko=t=>t*(t+1)/2,Qo=(t,r,e)=>t/2*(2*r+(t-1)*e);var kt={};M(kt,{getArithmeticMean:()=>O,getArithmeticMeanFromFrequency:()=>Wo,getMedian:()=>Zo,getMode:()=>_o,getStandardDeviation:()=>Ft,getVariance:()=>Hr,getVariance1:()=>Uo});var O=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return c(e/t.length,r)},Wo=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return c(e,r)},Zo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=[...t].sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?c((e[n]+e[n-1])/2,r):c(e[n],r)},_o=t=>{if(!t||t.length<=0)return;let r=new Map;for(let o of t)r.set(o,(r.get(o)||0)+1);let e=0,n=[];for(let[o,i]of r)i>e?(e=i,n=[o]):i===e&&n.push(o);if(n.length!==t.length)return n.length===1?[n[0]]:n},Uo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i-e,2),0);return c(n/t.length,r)},Hr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i,2),0);return c(n/t.length-V(e,2),r)},Ft=(t,r=1/0)=>{var n;let e=(n=Hr(t))!=null?n:0;return c(Math.sqrt(e),r)};var Zt={};M(Zt,{mlNormalizeArray:()=>Qt,mlNormalizeTestData:()=>Ko,mlNormalizeUnseenData:()=>Jo,mlNormalizeValue:()=>Nr,mlStandardizeArray:()=>Wt,mlStandardizeTestData:()=>Po,mlStandardizeUnseenData:()=>ti,mlStandardizeValue:()=>Lr});var Nr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:c((t-r)/o,n)},Qt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Qt(t,e,n,r);return{min:c(e,r),max:c(n,r),data:o}},Jo=(t,r,e,n=1/0)=>Qt(t,r,e,n),Lr=(t,r,e,n=1/0)=>e===0?0:c((t-r)/e,n),Wt=(t,r,e,n=1/0)=>[...t].map(o=>Lr(o,r,e,n)),Po=(t,r=1/0)=>{var i;let e=(i=O(t))!=null?i:0,n=Ft(t),o=Wt(t,e,n,r);return{mean:c(e,r),stdDev:c(n,r),data:o}},ti=(t,r,e,n=1/0)=>Wt(t,r,e,n);var _t={};M(_t,{naturalNumbersSum1ToN:()=>ri,naturalNumbersSumMToN:()=>ei});var ri=t=>t/2*(t+1),ei=(t,r)=>(r-t+1)*(t+r)/2;var Kt={};M(Kt,{factorial:()=>Ut,factorialIterative:()=>ni,factorialMemoized:()=>oi,factorialRecursive:()=>$r});var ni=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=1;for(let n=r;n<=t;n++)e*=n;return e},$r=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}return t===r?r:t*$r(t-1,r)},oi=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=new Map,n=(o,i)=>{var u;if(o{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===t)return t===0?1:t;r===0&&(r=1);let e=[];e[0]=1;for(let n=1;n<=t;n++)e[n]=e[n-1]*n;return e[t]/e[r-1]};var Jt={};M(Jt,{combinationsWithoutRepetition:()=>ci,permutationsWithRepetition:()=>ii,permutationsWithoutRepetition:()=>si});var ii=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return V(t,r)},si=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return Ut(t,t-r+1)},ci=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");let e=Array.from({length:t+1},()=>Array(r+1).fill(0));for(let n=0;n<=t;n++)e[n][0]=1,n<=r&&(e[n][n]=1);for(let n=1;n<=t;n++)for(let o=1;o<=Math.min(n,r);o++)e[n][o]=e[n-1][o-1]+e[n-1][o];return e[t][r]};var ui=h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h({},st),It),vt),U),tt),wt),K),St),Lt),Ht),$t),Dt),Br),Xt),Tt),Yt),Gt),jt),Ot),kt),Zt),_t),Kt),Jt);window.mzMath=window.mzMath||ui;})(); + )`,Je=(t,r=1/0)=>[[1,0],[0,1],[c(t[0],r),c(t[1],r)]],Pe=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[c(t[0],r),c(t[1],r),c(t[2],r)]],G=(t,r=1/0)=>[[1,0,c(t[0],r)],[0,1,c(t[1],r)],[0,0,1]],tn=(t,r=1/0)=>[[1,0,0,c(t[0],r)],[0,1,0,c(t[1],r)],[0,0,1,c(t[2],r)],[0,0,0,1]],cr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},gt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},ur=(t,r,e=!0,n=1/0)=>{let o=G(r,n),i=gt(t,e,n),s=G(W(r,-1),n),u=L(o,i);return L(u,s)},rn=(t,r,e,n=!0,o=1/0)=>{let i=ur(t,r,n,o);return l(i,e)},en=(t,r,e=!0,n=1/0)=>{let o=A(r);return l(cr(t,e,n),o)},nn=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(gt(t,e,n),o)},mr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},on=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0,0],[0,n,-o,0],[0,o,n,0],[0,0,0,1]]:[[1,0,0,0],[0,n,o,0],[0,-o,n,0],[0,0,0,1]]},sn=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(mr(t,e,n),o)},ar=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},cn=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},un=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(ar(t,e,n),o)},xr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},mn=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0,0],[o,n,0,0],[0,0,1,0],[0,0,0,1]]:[[n,o,0,0],[-o,n,0,0],[0,0,1,0],[0,0,0,1]]},an=(t,r,e=!0,n=1/0)=>{let o=w(r);return l(xr(t,e,n),o)},fr=(t,r,e=1/0)=>{let n=G(r,e),o=br(t),i=G(W(r,-1),e),s=L(n,o);return L(s,i)},xn=(t,r,e,n=1/0)=>{let o=fr(t,r,n);return l(o,e)},pr=t=>[[t[0],0],[0,t[1]]],fn=(t,r)=>l(pr(t),r),br=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],hr=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],pn=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],bn=(t,r)=>l(hr(t),r),hn=t=>[[t,0],[0,1]],Mn=t=>[[t,0,0],[0,1,0],[0,0,1]],Vn=t=>[[t,0,0],[0,1,0],[0,0,1]],ln=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],dn=t=>[[1,0,0],[0,t,0],[0,0,1]],yn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],In=t=>[[1,0,0],[0,1,0],[0,0,t]],gn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],vn=t=>[[1,0],[0,t]],wn=t=>[[1,0,0],[0,t,0],[0,0,1]],Sn=()=>[[-1,0],[0,-1]],Rn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],zn=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],Bn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],En=()=>[[0,-1],[-1,0]],Tn=()=>[[1,0],[0,-1]],Hn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Nn=()=>[[-1,0],[0,1]],An=()=>[[-1,0,0],[0,1,0],[0,0,1]],Ln=()=>[[-1,0,0],[0,1,0],[0,0,1]],$n=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],qn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Cn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],Dn=()=>[[1,0,0],[0,1,0],[0,0,-1]],Xn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Yn=t=>[[1,t],[0,1]],jn=t=>[[1,0],[t,1]];var wt={};M(wt,{getRandom:()=>d,getRandomBoolean:()=>Gn,getRandomInt:()=>Mr,getRandomItemFromArray:()=>On});var d=(t,r,e=1/0)=>c(Math.random()*(r-t)+t,e),Mr=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Gn=()=>Math.random()<.5,On=t=>{let r=Mr(0,t.length-1);return t[r]};var St={};M(St,{stringToNumber:()=>Fn});var Fn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var At={};M(At,{v2CubicBezierBBox:()=>xo,v2CubicBezierCurve:()=>lr,v2CubicBezierCurveExtrema:()=>gr,v2CubicBezierCurveNormal:()=>mo,v2CubicBezierCurveTangent:()=>yr,v2QuadraticBezierBBox:()=>ao,v2QuadraticBezierCurve:()=>Vr,v2QuadraticBezierCurveExtrema:()=>Ir,v2QuadraticBezierCurveNormal:()=>uo,v2QuadraticBezierCurveTangent:()=>dr,v3CubicBezierCurve:()=>io,v3CubicBezierCurveTangent:()=>co,v3QuadraticBezierCurve:()=>oo,v3QuadraticBezierCurveTangent:()=>so});var Tt={};M(Tt,{dxArcCos:()=>Kn,dxArcCot:()=>Pn,dxArcSin:()=>Un,dxArcTan:()=>Jn,dxCos:()=>Wn,dxCot:()=>_n,dxPolynomial:()=>kn,dxSin:()=>Qn,dxTan:()=>Zn,dxV2CubicBezierCurve:()=>Bt,dxV2QuadraticBezierCurve:()=>Rt,dxV3CubicBezierCurve:()=>Et,dxV3QuadraticBezierCurve:()=>zt});var kn=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],s=o[1];n+=i*s*Math.pow(t,s-1)}return c(n,e)},Rt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},zt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},Bt=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,a=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i)]},Et=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,a=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+a*o[2],i)]},Qn=(t,r=1/0)=>c(Math.cos(t),r),Wn=(t,r=1/0)=>c(-Math.sin(t),r),Zn=(t,r=1/0)=>c(1/V(Math.cos(t),2),r),_n=(t,r=1/0)=>c(-1/V(Math.sin(t),2),r),Un=(t,r=1/0)=>c(1/Math.sqrt(1-V(t,2)),r),Kn=(t,r=1/0)=>c(-1/Math.sqrt(1-V(t,2)),r),Jn=(t,r=1/0)=>c(1/(1+V(t,2)),r),Pn=(t,r=1/0)=>c(-1/(1+V(t,2)),r);var Ht={};M(Ht,{getLinearEquationBy2Points:()=>no,linearEquation:()=>$,linearEquationSystem2:()=>to,linearEquationSystem3:()=>ro,linearEquationSystemN:()=>eo});var $=(t,r=1/0)=>{let e=t[0],n=t[1],i=t[2]-n;return e===0&&i===0?1/0:e===0?NaN:c(i/e,r)},to=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=dt(n);if(o===null)return null;let i=[t[2],r[2]];return l(o,i,e)},ro=(t,r,e,n=1/0)=>{let o=[[t[0],t[1],t[2]],[r[0],r[1],r[2]],[e[0],e[1],e[2]]],i=yt(o);if(i===null)return null;let s=[t[3],r[3],e[3]];return l(i,s,n)},eo=(t,r=1/0)=>{if(t.length<=0)return null;let e=pt(t),n=_(e);if(n===null)return null;let o=bt(t);return l(n,o,r)},no=(t,r)=>{let[e,n]=z(r,t),[o,i]=t;if(e===0)return{slope:void 0,xIntercept:o,yIntercept:void 0,formula:`x = ${o}`};let s=n/e,u=i-s*o,m="";return s===0?m=`y = ${u}`:(m=`y = ${s===1?"":s}x`,u!==0&&(m+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:s,xIntercept:void 0,yIntercept:u,formula:m}};var Nt=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=$([n,o,i],r);return T(f)?[f]:[]}let s=o-i,u=n*n-4*e*s;if(u<0)return[];if(u===0)return[c(-n/(2*e),r)];let m=2*e,a=Math.sqrt(u);return[c((-n+a)/m,r),c((-n-a)/m,r)]};var Vr=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},oo=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},lr=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,a=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i)]},io=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,a=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+a*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+a*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+a*o[2],i)]},dr=(t,r,e,n,o=1/0)=>{let i=Rt(t,r,e,n);return A(i,o)},so=(t,r,e,n,o=1/0)=>{let i=zt(t,r,e,n);return w(i,o)},yr=(t,r,e,n,o,i=1/0)=>{let s=Bt(t,r,e,n,o);return A(s,i)},co=(t,r,e,n,o,i=1/0)=>{let s=Et(t,r,e,n,o);return w(s,i)},uo=(t,r,e,n,o=1/0)=>{let i=dr(t,r,e,n,o);return[-i[1],i[0]]},mo=(t,r,e,n,o,i=1/0)=>{let s=yr(t,r,e,n,o,i);return[-s[1],s[0]]},Ir=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=$([o,i,0],n),m=2*t[1]-4*r[1]+2*e[1],a=-2*t[1]+2*r[1],p=$([m,a,0],n),x=[];return T(u)&&x.push(u),T(p)&&x.push(p),x},gr=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],s=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],m=[i,s,u,0],a=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],x=[a,f,p,0],b=Nt(m,o).filter(g=>g>=0&&g<=1),S=Nt(x,o).filter(g=>g>=0&&g<=1);return[...b,...S].length===2?[...b,...S]:null},ao=(t,r,e,n=1/0)=>{let o=Ir(t,r,e),i=1/0,s=1/0,u=-1/0,m=-1/0;for(let a of o){let f=Vr(a,t,r,e),p=f[0],x=f[1];i=Math.min(i,p),u=Math.max(u,p),s=Math.min(s,x),m=Math.max(m,x)}return i=c(Math.min(i,t[0],e[0]),n),u=c(Math.max(u,t[0],e[0]),n),s=c(Math.min(s,t[1],e[1]),n),m=c(Math.max(m,t[1],e[1]),n),{x:i,y:s,w:Math.abs(u-i),h:Math.abs(m-s),x2:u,y2:m}},xo=(t,r,e,n,o=1/0)=>{let i=gr(t,r,e,n)||[],s=1/0,u=1/0,m=-1/0,a=-1/0;for(let f of i){let p=lr(f,t,r,e,n),x=p[0],b=p[1];s=Math.min(s,x!=null?x:1/0),m=Math.max(m,x!=null?x:-1/0),u=Math.min(u,b!=null?b:1/0),a=Math.max(a,b!=null?b:-1/0)}return s=c(Math.min(s,t[0],n[0]),o),m=c(Math.max(m,t[0],n[0]),o),u=c(Math.min(u,t[1],n[1]),o),a=c(Math.max(a,t[1],n[1]),o),{x:s,y:u,w:Math.abs(m-s),h:Math.abs(a-u),x2:m,y2:a}};var Lt={};M(Lt,{circleMovement:()=>vr,circleMovementAfterMouse:()=>fo,ellipseMovement:()=>wr,ellipseMovementAfterMouse:()=>po,lissajousCurve:()=>ho,sineWaveMovement:()=>bo});var vr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),fo=(t,r,e)=>{let n=z(t,r),o=N(n);return o=k(o,0,Math.PI*2,0,Math.PI),vr(r,o,e)},wr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),po=(t,r,e)=>{let n=z(t,r),o=N(n);return o=k(o,0,Math.PI*2,0,Math.PI),wr(r,o,e[0],e[1])},bo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},ho=(t,r,e,n,o,i,s)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-s)];var Dt={};M(Dt,{getColorsDelta:()=>Lo,getRandomGrayscaleHSLColor:()=>go,getRandomHSLColor:()=>Ct,getRandomHSLColorWithHue:()=>lo,getRandomHSLColorWithLightness:()=>Io,getRandomHSLColorWithSaturation:()=>yo,getRandomHSLColorWithinRanges:()=>vo,getRandomHexColor:()=>Vo,getRandomRGBColor:()=>Mo,getShiftedHue:()=>Ho,getShiftedLightness:()=>No,getShiftedSaturation:()=>Ao,hexToRgb:()=>Eo,hslToHex:()=>zr,hslToRgb:()=>Rr,labToRgb:()=>To,rgbToHex:()=>Bo,rgbToHsl:()=>zo,rgbToLab:()=>qt});var Mo=()=>{let t=Ct();return Rr(t)},Vo=()=>{let t=Ct();return zr(t)},Ct=()=>{let t=d(1,360),r=d(0,100),e=d(0,100);return[t,r,e]},lo=t=>{let r=d(0,100),e=d(0,100);return[t,r,e]},yo=t=>{let r=d(1,360),e=d(0,100);return[r,t,e]},Io=t=>{let r=d(1,360),e=d(0,100);return[r,e,t]},go=()=>[0,0,d(0,100)],vo=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let s=d(t,r),u=d(e,n),m=d(o,i);return[s,u,m]},wo=t=>(t*=60,t<0&&(t+=360),t),So=(t,r,e,n=void 0,o=void 0)=>{if(n=n===void 0?Math.min(t,r,e):n,o=o===void 0?Math.max(t,r,e):o,n===o)return 0;let i=o-n,s=0;return o===t&&(s=(r-e)/i+(r(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,(n+o)/2*100),Ro=(t,r,e,n=void 0,o=void 0,i=void 0)=>(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,n===o?0:(i=i===void 0?Sr(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),zo=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255,i=Math.min(e,n,o),s=Math.max(e,n,o),u=Sr(e,n,o,i,s),m=Ro(e,n,o,i,s,u),a=So(e,n,o,i,s);return a>360||m>100||u>100?[0,0,100]:a<0||m<0||u<0?[0,0,0]:[c(a,r),c(m,r),c(u,r)]},$t=(t,r,e)=>(e<0&&(e+=1),e>1&&(e-=1),e*6<1?r+(t-r)*6*e:e*2<1?t:e*3<2?r+(t-r)*(.666-e)*6:r),Rr=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let b=o*255;return[b,b,b]}let i=o<.5?o*(1+n):o+n-o*n,s=2*o-i,u=e+.333,m=e,a=e-.333,f=$t(i,s,u),p=$t(i,s,m),x=$t(i,s,a);return f*=255,p*=255,x*=255,f>255||p>255||x>255?[255,255,255]:f<0||p<0||x<0?[0,0,0]:[c(f,r),c(p,r),c(x,r)]},zr=t=>{if(t[0]>360||t[1]>100||t[2]>100)return"#ffffff";if(t[0]<0||t[1]<0||t[2]<0)return"#000000";let r=t[0]/360,e=t[1]/100,n=t[2]/100,o,i,s;if(e===0)o=i=s=n;else{let m=(p,x,b)=>(b<0&&(b+=1),b>1&&(b-=1),b<.16666666666666666?p+(x-p)*6*b:b<.5?x:b<.6666666666666666?p+(x-p)*(.6666666666666666-b)*6:p),a=n<.5?n*(1+e):n+e-n*e,f=2*n-a;o=m(f,a,r+1/3),i=m(f,a,r),s=m(f,a,r-1/3)}let u=m=>{let a=Math.round(m*255).toString(16);return a.length===1?"0"+a:a};return`#${u(o)}${u(i)}${u(s)}`},Bo=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Eo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,m,a,f)=>m+m+a+a+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),s=parseInt(n[3],16);return[o,i,s]},qt=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;let i=(e*.4124+n*.3576+o*.1805)/.95047,s=(e*.2126+n*.7152+o*.0722)/1,u=(e*.0193+n*.1192+o*.9505)/1.08883;return i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,[c(116*s-16,r),c(500*(i-s),r),c(200*(s-u),r)]},To=(t,r=1/0)=>{let e=(t[0]+16)/116,n=t[1]/500+e,o=e-t[2]/200;n=.95047*(n*n*n>.008856?n*n*n:(n-16/116)/7.787),e=1*(e*e*e>.008856?e*e*e:(e-16/116)/7.787),o=1.08883*(o*o*o>.008856?o*o*o:(o-16/116)/7.787);let i=n*3.2406+e*-1.5372+o*-.4986,s=n*-.9689+e*1.8758+o*.0415,u=n*.0557+e*-.204+o*1.057;return i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:12.92*u,[c(Math.max(0,Math.min(1,i))*255,r),c(Math.max(0,Math.min(1,s))*255,r),c(Math.max(0,Math.min(1,u))*255,r)]},Ho=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=y(e,360)),[e,t[1],t[2]]},No=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=y(e,100)),[t[0],t[1],e]},Ao=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},Lo=(t,r,e=1/0)=>{let n=qt(t,e),o=qt(r,e),i=n[0]-o[0],s=n[1]-o[1],u=n[2]-o[2],m=Math.sqrt(n[1]*n[1]+n[2]*n[2]),a=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=m-a,p=s*s+u*u-f*f;p=p<0?0:Math.sqrt(p);let x=1+.045*m,b=1+.015*m,S=i/1,q=f/x,g=p/b,F=S*S+q*q+g*g;return F<0?0:Math.sqrt(F)};var Br={};var Xt={};M(Xt,{guid:()=>$o,newId:()=>qo});var $o=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),qo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var Yt={};M(Yt,{circleCollide:()=>Do,convexPolygonsCollide:()=>Xo,rectCollide:()=>Co});var Co=(t,r)=>t.x<=r.x+r.w&&t.x+t.w>=r.x&&t.y<=r.y+r.h&&t.h+t.y>=r.y,Do=(t,r)=>{let e=Math.abs(t.cx-r.cx),n=Math.abs(t.cy-r.cy);return Math.sqrt(e*e+n*n)<=t.r+r.r},Er=t=>{let r=[];for(let e=0;e{let e=[];e.push(...Er(t)),e.push(...Er(r));for(let n of e){let o=it(n[0],n[1]),i=Tr(t,o),s=Tr(r,o);if(!(i.max>=s.min&&s.max>=i.min))return!1}return!0},Tr=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=et(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var jt={};M(jt,{animate:()=>Yo});var Yo=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,s=!1,u,m=()=>{e=void 0,o=void 0,i=void 0,s=!1,n!==void 0&&window.cancelAnimationFrame(n)},a=()=>{m(),S()},f=()=>{s=!1},p=()=>{s=!0},x=E=>{e===void 0&&(e=E),o=E-e,s&&i!==E&&typeof t.callback=="function"&&t.callback(Pt()),o<=r?(i=E,n=window.requestAnimationFrame(x)):m()},b=(E,Cr)=>{a(),typeof t.resizeCallback=="function"&&t.resizeCallback(E,Cr)},S=()=>{e=void 0,o=void 0,i=void 0,s=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(b),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(x)},q=()=>o,g=()=>s,F=()=>e,$r=()=>{if(!(r===1/0||o===void 0))return o*100/r},qr=()=>u,Pt=()=>({start:S,stop:m,pause:f,resume:p,restart:a,isAnimating:g,getElapsedTime:q,getStartTime:F,getPercent:$r,getResizeObserver:qr});return Pt()};var Gt={};M(Gt,{getCircleCircumference:()=>jo,getEllipseCircumference:()=>Go,getSquareInCircleSide:()=>Fo,isAngleInCircleArc:()=>Oo});var jo=(t,r=1/0)=>c(2*Math.PI*t,r),Go=(t,r,e=1/0)=>c(2*Math.PI*Math.sqrt((V(t,2)+V(r,2))/2),e),Oo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Fo=(t,r=1/0)=>c(t*2/Math.sqrt(2),r);var Ot={};M(Ot,{arithmeticSequenceSum:()=>Qo,naturalNumbersSequenceSum:()=>ko});var ko=t=>t*(t+1)/2,Qo=(t,r,e)=>t/2*(2*r+(t-1)*e);var kt={};M(kt,{getArithmeticMean:()=>O,getArithmeticMeanFromFrequency:()=>Wo,getMedian:()=>Zo,getMode:()=>_o,getStandardDeviation:()=>Ft,getVariance:()=>Hr,getVariance1:()=>Uo});var O=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return c(e/t.length,r)},Wo=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return c(e,r)},Zo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=[...t].sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?c((e[n]+e[n-1])/2,r):c(e[n],r)},_o=t=>{if(!t||t.length<=0)return;let r=new Map;for(let o of t)r.set(o,(r.get(o)||0)+1);let e=0,n=[];for(let[o,i]of r)i>e?(e=i,n=[o]):i===e&&n.push(o);if(n.length!==t.length)return n.length===1?[n[0]]:n},Uo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i-e,2),0);return c(n/t.length,r)},Hr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i,2),0);return c(n/t.length-V(e,2),r)},Ft=(t,r=1/0)=>{var n;let e=(n=Hr(t))!=null?n:0;return c(Math.sqrt(e),r)};var Zt={};M(Zt,{mlNormalizeArray:()=>Qt,mlNormalizeTestData:()=>Ko,mlNormalizeUnseenData:()=>Jo,mlNormalizeValue:()=>Nr,mlStandardizeArray:()=>Wt,mlStandardizeTestData:()=>Po,mlStandardizeUnseenData:()=>ti,mlStandardizeValue:()=>Ar});var Nr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:c((t-r)/o,n)},Qt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Qt(t,e,n,r);return{min:c(e,r),max:c(n,r),data:o}},Jo=(t,r,e,n=1/0)=>Qt(t,r,e,n),Ar=(t,r,e,n=1/0)=>e===0?0:c((t-r)/e,n),Wt=(t,r,e,n=1/0)=>[...t].map(o=>Ar(o,r,e,n)),Po=(t,r=1/0)=>{var i;let e=(i=O(t))!=null?i:0,n=Ft(t),o=Wt(t,e,n,r);return{mean:c(e,r),stdDev:c(n,r),data:o}},ti=(t,r,e,n=1/0)=>Wt(t,r,e,n);var _t={};M(_t,{naturalNumbersSum1ToN:()=>ri,naturalNumbersSumMToN:()=>ei});var ri=t=>t/2*(t+1),ei=(t,r)=>(r-t+1)*(t+r)/2;var Kt={};M(Kt,{factorial:()=>Ut,factorialIterative:()=>ni,factorialMemoized:()=>oi,factorialRecursive:()=>Lr});var ni=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=1;for(let n=r;n<=t;n++)e*=n;return e},Lr=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}return t===r?r:t*Lr(t-1,r)},oi=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=new Map,n=(o,i)=>{var u;if(o{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===t)return t===0?1:t;r===0&&(r=1);let e=[];e[0]=1;for(let n=1;n<=t;n++)e[n]=e[n-1]*n;return e[t]/e[r-1]};var Jt={};M(Jt,{combinationsWithRepetition:()=>ui,combinationsWithoutRepetition:()=>ci,permutationsWithRepetition:()=>ii,permutationsWithoutRepetition:()=>si});var ii=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return V(t,r)},si=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return Ut(t,t-r+1)},ci=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");let e=Array.from({length:t+1},()=>Array(r+1).fill(0));for(let n=0;n<=t;n++)e[n][0]=1,n<=r&&(e[n][n]=1);for(let n=1;n<=t;n++)for(let o=1;o<=Math.min(n,r);o++)e[n][o]=e[n-1][o-1]+e[n-1][o];return e[t][r]},ui=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");if(t===0)return 1;let e=r+t-1,n=r,o=Array.from({length:e+1},()=>Array(n+1).fill(0));for(let i=0;i<=e;i++)o[i][0]=1;for(let i=1;i<=e;i++)for(let s=1;s<=Math.min(i,n);s++)o[i][s]=o[i-1][s]+o[i-1][s-1];return o[e][n]};var mi=h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h({},st),It),vt),U),tt),wt),K),St),At),Ht),Lt),Dt),Br),Xt),Tt),Yt),jt),Gt),Ot),kt),Zt),_t),Kt),Jt);window.mzMath=window.mzMath||mi;})(); //# sourceMappingURL=mz-math.min.js.map diff --git a/dist/mz-math.min.js.map b/dist/mz-math.min.js.map index dfbaa4d..6e27f0f 100644 --- a/dist/mz-math.min.js.map +++ b/dist/mz-math.min.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/main/linear-algebra/vector.ts", "../src/main/format.ts", "../src/main/angle.ts", "../src/main/other.ts", "../src/main/linear-algebra/matrix.ts", "../src/main/linear-algebra/matrix-transformations.ts", "../src/main/random.ts", "../src/main/convert.ts", "../src/main/bezier-curves/bezier-curve.ts", "../src/main/derivative.ts", "../src/main/equations/linear-equations.ts", "../src/main/equations/quadratic-equations.ts", "../src/main/path-movement.ts", "../src/main/color.ts", "../src/main/physics.ts", "../src/main/id.ts", "../src/main/collision-detection.ts", "../src/main/animation.ts", "../src/main/circle-ellipse.ts", "../src/main/sequence.ts", "../src/main/statistics.ts", "../src/main/ml.ts", "../src/main/series.ts", "../src/main/combinatorics/factorial.ts", "../src/main/combinatorics/combinatorics.ts", "../src/index.ts"], - "sourcesContent": ["import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "import { Vector2 } from '../types';\n\n/**\n * Speed = how far something moves in a given amount of time.\n * Speed is also a vector:\n * magnitude = distance\n * direction = time\n */\nexport type Speed = Vector2;\n\n/**\n * Velocity is a measure of how fast an object is moving in a particular direction.\n * Velocity = Distance traveled / Time taken\n * It has a magnitude and direction, and can be represented as a vector.\n */\nexport type Velocity = Vector2;\n\n/**\n * Acceleration is a measure of how quickly an object's velocity changes over time.\n * Acceleration = (Final velocity - Initial velocity) / Time taken\n * a = (vf - v0)/t.\n * Distance = Initial velocity * time + (acceleration * time^2) / 2\n * It also has a magnitude and direction, and can be represented as a vector.\n * When the direction is negative ----> it's a \"slowdown\" movement\n */\nexport type Acceleration = Vector2;\n\n/**\n * Gravity is the force that attracts two objects with mass toward each other.\n * Newton's law of universal gravitation formula:\n * Gravitational force = (Gravitational constant * Mass of object 1 * Mass of object 2) / Distance between objects^2\n * It also has a magnitude and direction, and can be represented as a vector.\n * magnitude = the strength of the gravitational force\n * direction = the direction in which the force is acting (the direction of the gravitational force is always toward the center of mass of the objects involved)\n */\nexport type Gravity = Vector2;\n\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};", "/**\n * The simplest and straightforward method\n * but can become inefficient for extremely large numbers\n * due to growing computational time.\n */\nexport const factorialIterative = (n: number, start = 0): number => {\n\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n let result = 1;\n for (let i = start; i <= n; i++) {\n result *= i;\n }\n return result;\n};\n\n/**\n * A recursive approach is a classic method for calculating factorials\n * but can lead to stack overflow errors\n * for very large inputs because of deep recursion.\n * However, it's a direct translation\n * of the mathematical definition of factorial.\n */\nexport const factorialRecursive = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n // Base case: when n reaches start, return start instead of further reducing\n if (n === start) return start;\n\n // Recursive call\n return n * factorialRecursive(n - 1, start);\n};\n\n/**\n * Memoization (Top-Down Dynamic Programming).\n */\nexport const factorialMemoized = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n const memo = new Map();\n\n const traverse = (num: number, end: number): number => {\n if (num < end) return 1; // Adjust the base case to return 1 if we're below 'end'\n // if (num === 0) return 1;\n\n if (memo.has(num)) return memo.get(num) ?? 1;\n\n if (num === end) {\n memo.set(num, num);\n return num;\n }\n\n const result = num * traverse(num - 1, end);\n\n memo.set(num, result);\n\n return result;\n };\n\n return traverse(n, start);\n};\n\n/**\n * Tabulation (Bottom-Up Dynamic Programming).\n */\nexport const factorial = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === n) {\n return n === 0 ? 1 : n; // If start == n and n == 0, return 1 (0!), otherwise return n\n }\n\n if (start === 0) {\n start = 1;\n }\n\n const table = []; // new Array(n + 1);\n table[0] = 1;\n for (let i = 1; i <= n; i++) {\n table[i] = table[i - 1] * i;\n }\n return table[n] / table[start - 1];\n};", "import { factorial } from './factorial';\n\n/**\n * Permutations with repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - repetition is allowed\n *\n * Formula:\n * --------\n * n^r\n *\n * Intuition:\n * ----------\n * In other words, there are n possibilities for the first choice,\n * THEN there are n possibilities for the second choice, and so on,\n * multiplying each time.\n *\n * A Permutation is an ordered Combination.\n *\n * Example:\n * --------\n * Such as a lock that could be \"333\".\n */\nexport const permutationsWithRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return n ** r;\n};\n\n/**\n * Permutations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - no repetitions\n *\n * Formula:\n * --------\n * P(n,r) = n! / (n \u2212 r)!\n *\n * Intuition:\n * ----------\n * In this case, we have to reduce the number of available choices each time.\n * After choosing, say, number \"14\" we can't choose it again.\n * So, our first choice has 16 possibilities, and our next choice has 15 possibilities,\n * then 14, 13, 12, 11, ... etc.\n *\n * A Permutation is an ordered Combination.\n */\nexport const permutationsWithoutRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return factorial(n, n - r + 1);\n};\n\n/**\n * Order doesn't matter.\n *\n * Example:\n * --------\n * Coins in your pocket (5, 5, 5, 10, 10).\n\nexport const combinationsWithRepetition = () => {\n\n};\n */\n\n/**\n * Combinations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - no repetitions\n *\n * And is also known as the Binomial Coefficient.\n *\n * Formula:\n * --------\n * C(n, r) = C(n, n - r) = n! / (r! * (n\u2212r)!)\n *\n * Example:\n * --------\n * Such as lottery numbers (2, 14, 15, 27, 30, 33).\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42(n \u00D7 r)\n * Space Complexity: \uD835\uDC42(n \u00D7 r)\n */\nexport const combinationsWithoutRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n // Initialize a two-dimensional array (or matrix) [n + 1, r + 1].\n // The reason for n + 1 is to ensure that we can access indices directly equal to the value of n\n // without running out of bounds, as array indices start at 0.\n const dp = Array.from({ length: n + 1 }, () => Array(r + 1).fill(0));\n /*\n const dp: number[][] = [];\n for(let i=0; i<=n; i++) {\n dp[i] = [];\n for(let j=0; j<=r; j++) {\n dp[i][j] = 0;\n }\n }*/\n\n // Base cases: C(n, 0) = 1 and C(n, n) = 1 for any n.\n for (let i = 0; i <= n; i++) {\n dp[i][0] = 1;\n if (i <= r) {\n // Only fill this if i <= r to avoid filling non-existent cells\n dp[i][i] = 1;\n }\n }\n\n // Fill the table using the relation C(n, r) = C(n-1, r-1) + C(n-1, r)\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, r); j++) { // Only compute up to the minimum of i and r\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n }\n }\n\n return dp[n][r];\n};\n\n", "import * as vector from './main/linear-algebra/vector';\nimport * as matrix from './main/linear-algebra/matrix';\nimport * as matrixTransformations from './main/linear-algebra/matrix-transformations';\nimport * as format from './main/format';\nimport * as angle from './main/angle';\nimport * as random from './main/random';\nimport * as other from './main/other';\nimport * as convert from './main/convert';\nimport * as bezierCurve from './main/bezier-curves/bezier-curve';\nimport * as equations from './main/equations/linear-equations';\nimport * as pathMovement from './main/path-movement';\nimport * as color from './main/color';\nimport * as physics from './main/physics';\nimport * as id from './main/id';\nimport * as derivative from './main/derivative';\nimport * as collisions from './main/collision-detection';\nimport * as animation from './main/animation';\nimport * as circleEllipse from './main/circle-ellipse';\nimport * as sequence from './main/sequence';\nimport * as statistics from './main/statistics';\nimport * as ml from './main/ml';\nimport * as series from './main/series';\nimport * as factorial from './main/combinatorics/factorial';\nimport * as combinatorics from './main/combinatorics/combinatorics';\n\nconst api = {\n ...vector,\n ...matrix,\n ...matrixTransformations,\n ...format,\n ...angle,\n ...random,\n ...other,\n ...convert,\n ...bezierCurve,\n ...equations,\n ...pathMovement,\n ...color,\n ...physics,\n ...id,\n ...derivative,\n ...collisions,\n ...animation,\n ...circleEllipse,\n ...sequence,\n ...statistics,\n ...ml,\n ...series,\n ...factorial,\n ...combinatorics,\n};\n\ndeclare global {\n interface Window {\n mzMath: typeof api,\n }\n}\n\nwindow.mzMath = window.mzMath || api;\n\nexport * from './main/linear-algebra/vector';\nexport * from './main/linear-algebra/matrix';\nexport * from './main/linear-algebra/matrix-transformations';\nexport * from './main/format';\nexport * from './main/angle';\nexport * from './main/random';\nexport * from './main/other';\nexport * from './main/convert';\nexport * from './main/bezier-curves/bezier-curve';\nexport * from './main/equations/linear-equations';\nexport * from './main/path-movement';\nexport * from './main/color';\nexport * from './main/physics';\nexport * from './main/id';\nexport * from './main/derivative';\nexport * from './main/collision-detection';\nexport * from './main/animation';\nexport * from './main/circle-ellipse';\nexport * from './main/sequence';\nexport * from './main/statistics';\nexport * from './main/ml';\nexport * from './main/series';\nexport * from './main/combinatorics/factorial';\nexport * from './main/combinatorics/combinatorics';"], - "mappings": ";;;;;;;qbAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,QAAAE,GAAA,eAAAC,GAAA,mBAAAC,GAAA,iBAAAC,GAAA,sBAAAC,GAAA,gBAAAC,GAAA,aAAAC,GAAA,gBAAAC,GAAA,gBAAAC,EAAA,gBAAAC,GAAA,UAAAC,EAAA,UAAAC,GAAA,OAAAC,GAAA,mBAAAC,GAAA,eAAA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,KAAK,CAAC,CAAC,EAWnE,QAASM,EAAI,EAAGA,GAAKN,EAAGM,IACpBD,EAAGC,GAAG,GAAK,EACPA,GAAK,IAELD,EAAGC,GAAGA,GAAK,GAKnB,QAASA,EAAI,EAAGA,GAAKN,EAAGM,IACpB,QAASC,EAAI,EAAGA,GAAK,KAAK,IAAID,EAAG,CAAC,EAAGC,IACjCF,EAAGC,GAAGC,GAAKF,EAAGC,EAAE,GAAGC,EAAE,GAAKF,EAAGC,EAAE,GAAGC,GAI1C,OAAOF,EAAGL,GAAG,EACjB,ECjHA,IAAMQ,GAAMC,gDAAA,GACLC,IACAC,IACAC,IACAC,GACAC,IACAC,IACAC,GACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IASP,OAAO,OAAS,OAAO,QAAUzB", - "names": ["vector_exports", "__export", "v2", "v2Distance", "v2DivideScalar", "v2DotProduct", "v2FromPolarCoords", "v2GetNormal", "v2Length", "v2MulScalar", "v2Normalize", "v2SetLength", "v2Sub", "v2Sum", "v3", "v3CrossProduct", "v3Distance", "v3DivideScalar", "v3DotProduct", "v3Length", "v3MulScalar", "v3Normalize", "v3Sub", "v3Sum", "v4", "vDistance", "vDivideScalar", "vDotProduct", "vEqual", "vLength", "vMulScalar", "vN", "vNormalize", "vSub", "vSum", "format_exports", "__export", "setDecimalPlaces", "setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "angle_exports", "__export", "degreesToRadians", "getAnglesDistance", "getAnglesSub", "getV2Angle", "getV2AngleBetween", "getV2AngleInEllipse", "getV3AngleBetween", "getVNAngleBetween", "isAngleBetween", "isClockwise", "percentToAngle", "radiansToDegrees", "setV2Angle", "other_exports", "__export", "convertRange", "doRangesOverlap", "isNumber", "mod", "polarToCartesian", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "matrix_exports", "__export", "identity2", "identity3", "identity4", "identityN", "isSingularMatrix", "m2Adjugate", "m2AppendRow", "m2DeepCopy", "m2Determinant", "m2DivideScalar", "m2Inverse", "m2MulScalar", "m2PrependRow", "m2Reset", "m2Sub", "m2Sum", "m2Transpose", "m2x2", "m3Adjugate", "m3AppendRow", "m3DeepCopy", "m3Determinant", "m3DivideScalar", "m3Inverse", "m3MulScalar", "m3PrependRow", "m3Reset", "m3Sub", "m3Sum", "m3Transpose", "m3x3", "m4x4", "mAdjugate", "mAppendCol", "mAppendRow", "mDeepCopy", "mDelFirstColumn", "mDelFirstRow", "mDelLastColumn", "mDelLastRow", "mDeterminant", "mDivideScalar", "mEqual", "mGetColumn", "mGetFirstColumn", "mGetLastColumn", "mInverse", "mMinor", "mMul", "mMulScalar", "mMulVector", "mNxM", "mPrependCol", "mPrependRow", "mReset", "mSub", "mSum", "mTranspose", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "matrix_transformations_exports", "__export", "m2ReflectionOrigin", "m2ReflectionOriginH", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m2ReflectionYmX", "m2RotateAroundPointH", "m2Rotation", "m2RotationAroundPointH", "m2RotationH", "m2Scale", "m2ScaleAtPointH", "m2ScaleAtPointHMatrix", "m2ScaleH", "m2ScaleX", "m2ScaleXH", "m2ScaleY", "m2ScaleYH", "m2ShearingX", "m2ShearingY", "m2ToCSS", "m2Translation", "m2TranslationH", "m2hToCSS", "m2hToCSS3d", "m3ReflectionOrigin", "m3ReflectionOriginH", "m3ReflectionXY", "m3ReflectionXYH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionYZ", "m3ReflectionYZH", "m3RotationX", "m3RotationXH", "m3RotationY", "m3RotationYH", "m3RotationZ", "m3RotationZH", "m3Scale", "m3ScaleH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m3Translation", "m3TranslationH", "m3hToCSS3d", "v2Rotate", "v2RotateH", "v2Scale", "v3RotateX", "v3RotateY", "v3RotateZ", "v3Scale", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "random_exports", "__export", "getRandom", "getRandomBoolean", "getRandomInt", "getRandomItemFromArray", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "convert_exports", "__export", "stringToNumber", "value", "defaultNumber", "_a", "res", "bezier_curve_exports", "__export", "v2CubicBezierBBox", "v2CubicBezierCurve", "v2CubicBezierCurveExtrema", "v2CubicBezierCurveNormal", "v2CubicBezierCurveTangent", "v2QuadraticBezierBBox", "v2QuadraticBezierCurve", "v2QuadraticBezierCurveExtrema", "v2QuadraticBezierCurveNormal", "v2QuadraticBezierCurveTangent", "v3CubicBezierCurve", "v3CubicBezierCurveTangent", "v3QuadraticBezierCurve", "v3QuadraticBezierCurveTangent", "derivative_exports", "__export", "dxArcCos", "dxArcCot", "dxArcSin", "dxArcTan", "dxCos", "dxCot", "dxPolynomial", "dxSin", "dxTan", "dxV2CubicBezierCurve", "dxV2QuadraticBezierCurve", "dxV3CubicBezierCurve", "dxV3QuadraticBezierCurve", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linear_equations_exports", "__export", "getLinearEquationBy2Points", "linearEquation", "linearEquationSystem2", "linearEquationSystem3", "linearEquationSystemN", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "path_movement_exports", "__export", "circleMovement", "circleMovementAfterMouse", "ellipseMovement", "ellipseMovementAfterMouse", "lissajousCurve", "sineWaveMovement", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "color_exports", "__export", "getColorsDelta", "getRandomGrayscaleHSLColor", "getRandomHSLColor", "getRandomHSLColorWithHue", "getRandomHSLColorWithLightness", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithinRanges", "getRandomHexColor", "getRandomRGBColor", "getShiftedHue", "getShiftedLightness", "getShiftedSaturation", "hexToRgb", "hslToHex", "hslToRgb", "labToRgb", "rgbToHex", "rgbToHsl", "rgbToLab", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "x", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "physics_exports", "id_exports", "__export", "guid", "newId", "c", "collision_detection_exports", "__export", "circleCollide", "convexPolygonsCollide", "rectCollide", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animation_exports", "__export", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "circle_ellipse_exports", "__export", "getCircleCircumference", "getEllipseCircumference", "getSquareInCircleSide", "isAngleInCircleArc", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "sequence_exports", "__export", "arithmeticSequenceSum", "naturalNumbersSequenceSum", "n", "a", "d", "statistics_exports", "__export", "getArithmeticMean", "getArithmeticMeanFromFrequency", "getMedian", "getMode", "getStandardDeviation", "getVariance", "getVariance1", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "ml_exports", "__export", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "series_exports", "__export", "naturalNumbersSum1ToN", "naturalNumbersSumMToN", "n", "m", "factorial_exports", "__export", "factorial", "factorialIterative", "factorialMemoized", "factorialRecursive", "n", "start", "result", "i", "memo", "traverse", "num", "end", "_a", "table", "combinatorics_exports", "__export", "combinationsWithoutRepetition", "permutationsWithRepetition", "permutationsWithoutRepetition", "permutationsWithRepetition", "n", "__pow", "permutationsWithoutRepetition", "factorial", "combinationsWithoutRepetition", "dp", "i", "j", "api", "__spreadValues", "vector_exports", "matrix_exports", "matrix_transformations_exports", "format_exports", "angle_exports", "random_exports", "other_exports", "convert_exports", "bezier_curve_exports", "linear_equations_exports", "path_movement_exports", "color_exports", "physics_exports", "id_exports", "derivative_exports", "collision_detection_exports", "animation_exports", "circle_ellipse_exports", "sequence_exports", "statistics_exports", "ml_exports", "series_exports", "factorial_exports", "combinatorics_exports"] + "sourcesContent": ["import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "import { Vector2 } from '../types';\n\n/**\n * Speed = how far something moves in a given amount of time.\n * Speed is also a vector:\n * magnitude = distance\n * direction = time\n */\nexport type Speed = Vector2;\n\n/**\n * Velocity is a measure of how fast an object is moving in a particular direction.\n * Velocity = Distance traveled / Time taken\n * It has a magnitude and direction, and can be represented as a vector.\n */\nexport type Velocity = Vector2;\n\n/**\n * Acceleration is a measure of how quickly an object's velocity changes over time.\n * Acceleration = (Final velocity - Initial velocity) / Time taken\n * a = (vf - v0)/t.\n * Distance = Initial velocity * time + (acceleration * time^2) / 2\n * It also has a magnitude and direction, and can be represented as a vector.\n * When the direction is negative ----> it's a \"slowdown\" movement\n */\nexport type Acceleration = Vector2;\n\n/**\n * Gravity is the force that attracts two objects with mass toward each other.\n * Newton's law of universal gravitation formula:\n * Gravitational force = (Gravitational constant * Mass of object 1 * Mass of object 2) / Distance between objects^2\n * It also has a magnitude and direction, and can be represented as a vector.\n * magnitude = the strength of the gravitational force\n * direction = the direction in which the force is acting (the direction of the gravitational force is always toward the center of mass of the objects involved)\n */\nexport type Gravity = Vector2;\n\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};", "/**\n * The simplest and straightforward method\n * but can become inefficient for extremely large numbers\n * due to growing computational time.\n */\nexport const factorialIterative = (n: number, start = 0): number => {\n\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n let result = 1;\n for (let i = start; i <= n; i++) {\n result *= i;\n }\n return result;\n};\n\n/**\n * A recursive approach is a classic method for calculating factorials\n * but can lead to stack overflow errors\n * for very large inputs because of deep recursion.\n * However, it's a direct translation\n * of the mathematical definition of factorial.\n */\nexport const factorialRecursive = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n // Base case: when n reaches start, return start instead of further reducing\n if (n === start) return start;\n\n // Recursive call\n return n * factorialRecursive(n - 1, start);\n};\n\n/**\n * Memoization (Top-Down Dynamic Programming).\n */\nexport const factorialMemoized = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n const memo = new Map();\n\n const traverse = (num: number, end: number): number => {\n if (num < end) return 1; // Adjust the base case to return 1 if we're below 'end'\n // if (num === 0) return 1;\n\n if (memo.has(num)) return memo.get(num) ?? 1;\n\n if (num === end) {\n memo.set(num, num);\n return num;\n }\n\n const result = num * traverse(num - 1, end);\n\n memo.set(num, result);\n\n return result;\n };\n\n return traverse(n, start);\n};\n\n/**\n * Tabulation (Bottom-Up Dynamic Programming).\n */\nexport const factorial = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === n) {\n return n === 0 ? 1 : n; // If start == n and n == 0, return 1 (0!), otherwise return n\n }\n\n if (start === 0) {\n start = 1;\n }\n\n const table = []; // new Array(n + 1);\n table[0] = 1;\n for (let i = 1; i <= n; i++) {\n table[i] = table[i - 1] * i;\n }\n return table[n] / table[start - 1];\n};", "import { factorial } from './factorial';\n\n/**\n * Permutations with repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - repetition is allowed\n *\n * Formula:\n * --------\n * n^r\n *\n * Intuition:\n * ----------\n * In other words, there are n possibilities for the first choice,\n * THEN there are n possibilities for the second choice, and so on,\n * multiplying each time.\n *\n * A Permutation is an ordered Combination.\n *\n * Example:\n * --------\n * Such as a lock that could be \"333\".\n */\nexport const permutationsWithRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return n ** r;\n};\n\n/**\n * Permutations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - no repetitions\n *\n * Formula:\n * --------\n * P(n,r) = n! / (n \u2212 r)!\n *\n * Intuition:\n * ----------\n * In this case, we have to reduce the number of available choices each time.\n * After choosing, say, number \"14\" we can't choose it again.\n * So, our first choice has 16 possibilities, and our next choice has 15 possibilities,\n * then 14, 13, 12, 11, ... etc.\n *\n * A Permutation is an ordered Combination.\n */\nexport const permutationsWithoutRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return factorial(n, n - r + 1);\n};\n\n/**\n * Combinations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - no repetitions\n *\n * And is also known as the Binomial Coefficient.\n * We can also use Pascal's Triangle to find the values.\n *\n * Formula:\n * --------\n * C(n, r) = C(n, n - r) = n! / (r! * (n\u2212r)!)\n *\n * Example:\n * --------\n * Such as lottery numbers (2, 14, 15, 27, 30, 33).\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42(n \u00D7 r)\n * Space Complexity: \uD835\uDC42(n \u00D7 r)\n */\nexport const combinationsWithoutRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n // Initialize a two-dimensional array (or matrix) [n + 1, r + 1].\n // The reason for n + 1 is to ensure that we can access indices directly equal to the value of n\n // without running out of bounds, as array indices start at 0.\n const dp = Array.from({ length: n + 1 }, () => Array(r + 1).fill(0));\n /*\n const dp: number[][] = [];\n for(let i=0; i<=n; i++) {\n dp[i] = [];\n for(let j=0; j<=r; j++) {\n dp[i][j] = 0;\n }\n }*/\n\n // Base cases: C(n, 0) = 1 and C(n, n) = 1 for any n.\n for (let i = 0; i <= n; i++) {\n dp[i][0] = 1;\n if (i <= r) {\n // Only fill this if i <= r to avoid filling non-existent cells\n dp[i][i] = 1;\n }\n }\n\n // Fill the table using the relation C(n, r) = C(n-1, r-1) + C(n-1, r)\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, r); j++) { // Only compute up to the minimum of i and r\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n }\n }\n\n return dp[n][r];\n};\n\n/**\n * Combinations with repetitions (multi-choose):\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - repetition is allowed\n *\n * Formula:\n * --------\n * (r + n \u2212 1)! / r!(n \u2212 1)! = C(r + n \u2212 1, r) = C(r + n \u2212 1, n \u2212 1)\n *\n * Example:\n * --------\n * - Coins in your pocket (5, 5, 5, 10, 10).\n * - Let us say there are five flavors of ice cream: banana, chocolate, lemon, strawberry and vanilla.\u00E5\n * We can have three scoops. How many variations will there be?\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42((r + n) \u00D7 r)\n * Space Complexity: \uD835\uDC42((r + n) \u00D7 r)\n */\nexport const combinationsWithRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n if(n === 0) return 1;\n\n // Calculate adjusted values for indices in the DP table\n const totalItems = r + n - 1;\n const chooseItems = r;\n\n // Initialize DP table\n const dp: number[][] = Array.from({ length: totalItems + 1 }, () => Array(chooseItems + 1).fill(0));\n\n // Base case initialization: C(i, 0) = 1 for all i, because there's one way to choose nothing\n for (let i = 0; i <= totalItems; i++) {\n dp[i][0] = 1;\n }\n\n for (let i = 1; i <= totalItems; i++) {\n for (let j = 1; j <= Math.min(i, chooseItems); j++) {\n dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];\n }\n }\n\n return dp[totalItems][chooseItems];\n};\n\n", "import * as vector from './main/linear-algebra/vector';\nimport * as matrix from './main/linear-algebra/matrix';\nimport * as matrixTransformations from './main/linear-algebra/matrix-transformations';\nimport * as format from './main/format';\nimport * as angle from './main/angle';\nimport * as random from './main/random';\nimport * as other from './main/other';\nimport * as convert from './main/convert';\nimport * as bezierCurve from './main/bezier-curves/bezier-curve';\nimport * as equations from './main/equations/linear-equations';\nimport * as pathMovement from './main/path-movement';\nimport * as color from './main/color';\nimport * as physics from './main/physics';\nimport * as id from './main/id';\nimport * as derivative from './main/derivative';\nimport * as collisions from './main/collision-detection';\nimport * as animation from './main/animation';\nimport * as circleEllipse from './main/circle-ellipse';\nimport * as sequence from './main/sequence';\nimport * as statistics from './main/statistics';\nimport * as ml from './main/ml';\nimport * as series from './main/series';\nimport * as factorial from './main/combinatorics/factorial';\nimport * as combinatorics from './main/combinatorics/combinatorics';\n\nconst api = {\n ...vector,\n ...matrix,\n ...matrixTransformations,\n ...format,\n ...angle,\n ...random,\n ...other,\n ...convert,\n ...bezierCurve,\n ...equations,\n ...pathMovement,\n ...color,\n ...physics,\n ...id,\n ...derivative,\n ...collisions,\n ...animation,\n ...circleEllipse,\n ...sequence,\n ...statistics,\n ...ml,\n ...series,\n ...factorial,\n ...combinatorics,\n};\n\ndeclare global {\n interface Window {\n mzMath: typeof api,\n }\n}\n\nwindow.mzMath = window.mzMath || api;\n\nexport * from './main/linear-algebra/vector';\nexport * from './main/linear-algebra/matrix';\nexport * from './main/linear-algebra/matrix-transformations';\nexport * from './main/format';\nexport * from './main/angle';\nexport * from './main/random';\nexport * from './main/other';\nexport * from './main/convert';\nexport * from './main/bezier-curves/bezier-curve';\nexport * from './main/equations/linear-equations';\nexport * from './main/path-movement';\nexport * from './main/color';\nexport * from './main/physics';\nexport * from './main/id';\nexport * from './main/derivative';\nexport * from './main/collision-detection';\nexport * from './main/animation';\nexport * from './main/circle-ellipse';\nexport * from './main/sequence';\nexport * from './main/statistics';\nexport * from './main/ml';\nexport * from './main/series';\nexport * from './main/combinatorics/factorial';\nexport * from './main/combinatorics/combinatorics';"], + "mappings": ";;;;;;;qbAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,QAAAE,GAAA,eAAAC,GAAA,mBAAAC,GAAA,iBAAAC,GAAA,sBAAAC,GAAA,gBAAAC,GAAA,aAAAC,GAAA,gBAAAC,GAAA,gBAAAC,EAAA,gBAAAC,GAAA,UAAAC,EAAA,UAAAC,GAAA,OAAAC,GAAA,mBAAAC,GAAA,eAAAC,GAAA,mBAAAC,GAAA,iBAAAC,GAAA,aAAAC,GAAA,gBAAAC,EAAA,gBAAAC,EAAA,UAAAC,GAAA,UAAAC,GAAA,OAAAC,GAAA,cAAAC,GAAA,kBAAAC,EAAA,gBAAAC,EAAA,WAAAC,GAAA,YAAAC,EAAA,eAAAC,EAAA,OAAAC,GAAA,eAAAC,EAAA,SAAAC,EAAA,SAAAC,ICAA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAO,IAAMC,EAAmB,CAACC,EAAaC,EAAoC,MAAa,CAC3F,GAAGA,IAAkB,IAAU,OAAOD,EAEnCC,EAAgB,IACfA,EAAgB,GAGpB,IAAMC,EAAcC,EAAA,GAAMF,GAC1B,OAAO,KAAK,MAAMD,EAAME,CAAW,EAAIA,CAC3C,ECTA,IAAAE,GAAA,GAAAC,EAAAD,GAAA,sBAAAE,GAAA,sBAAAC,GAAA,iBAAAC,EAAA,eAAAC,EAAA,sBAAAC,GAAA,wBAAAC,GAAA,sBAAAC,GAAA,sBAAAC,GAAA,mBAAAC,GAAA,gBAAAC,EAAA,mBAAAC,GAAA,qBAAAC,GAAA,eAAAC,ICAA,IAAAC,EAAA,GAAAC,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,CAAC,EAGlG,QAAS,EAAI,EAAG,GAAKD,EAAY,IAC7BJ,EAAG,GAAG,GAAK,EAGf,QAAS,EAAI,EAAG,GAAKI,EAAY,IAC7B,QAASF,EAAI,EAAGA,GAAK,KAAK,IAAI,EAAGG,CAAW,EAAGH,IAC3CF,EAAG,GAAGE,GAAKF,EAAG,EAAI,GAAGE,GAAKF,EAAG,EAAI,GAAGE,EAAI,GAIhD,OAAOF,EAAGI,GAAYC,EAC1B,EC1JA,IAAMC,GAAMC,gDAAA,GACLC,IACAC,IACAC,IACAC,GACAC,IACAC,IACAC,GACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IASP,OAAO,OAAS,OAAO,QAAUzB", + "names": ["vector_exports", "__export", "v2", "v2Distance", "v2DivideScalar", "v2DotProduct", "v2FromPolarCoords", "v2GetNormal", "v2Length", "v2MulScalar", "v2Normalize", "v2SetLength", "v2Sub", "v2Sum", "v3", "v3CrossProduct", "v3Distance", "v3DivideScalar", "v3DotProduct", "v3Length", "v3MulScalar", "v3Normalize", "v3Sub", "v3Sum", "v4", "vDistance", "vDivideScalar", "vDotProduct", "vEqual", "vLength", "vMulScalar", "vN", "vNormalize", "vSub", "vSum", "format_exports", "__export", "setDecimalPlaces", "setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "angle_exports", "__export", "degreesToRadians", "getAnglesDistance", "getAnglesSub", "getV2Angle", "getV2AngleBetween", "getV2AngleInEllipse", "getV3AngleBetween", "getVNAngleBetween", "isAngleBetween", "isClockwise", "percentToAngle", "radiansToDegrees", "setV2Angle", "other_exports", "__export", "convertRange", "doRangesOverlap", "isNumber", "mod", "polarToCartesian", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "matrix_exports", "__export", "identity2", "identity3", "identity4", "identityN", "isSingularMatrix", "m2Adjugate", "m2AppendRow", "m2DeepCopy", "m2Determinant", "m2DivideScalar", "m2Inverse", "m2MulScalar", "m2PrependRow", "m2Reset", "m2Sub", "m2Sum", "m2Transpose", "m2x2", "m3Adjugate", "m3AppendRow", "m3DeepCopy", "m3Determinant", "m3DivideScalar", "m3Inverse", "m3MulScalar", "m3PrependRow", "m3Reset", "m3Sub", "m3Sum", "m3Transpose", "m3x3", "m4x4", "mAdjugate", "mAppendCol", "mAppendRow", "mDeepCopy", "mDelFirstColumn", "mDelFirstRow", "mDelLastColumn", "mDelLastRow", "mDeterminant", "mDivideScalar", "mEqual", "mGetColumn", "mGetFirstColumn", "mGetLastColumn", "mInverse", "mMinor", "mMul", "mMulScalar", "mMulVector", "mNxM", "mPrependCol", "mPrependRow", "mReset", "mSub", "mSum", "mTranspose", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "matrix_transformations_exports", "__export", "m2ReflectionOrigin", "m2ReflectionOriginH", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m2ReflectionYmX", "m2RotateAroundPointH", "m2Rotation", "m2RotationAroundPointH", "m2RotationH", "m2Scale", "m2ScaleAtPointH", "m2ScaleAtPointHMatrix", "m2ScaleH", "m2ScaleX", "m2ScaleXH", "m2ScaleY", "m2ScaleYH", "m2ShearingX", "m2ShearingY", "m2ToCSS", "m2Translation", "m2TranslationH", "m2hToCSS", "m2hToCSS3d", "m3ReflectionOrigin", "m3ReflectionOriginH", "m3ReflectionXY", "m3ReflectionXYH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionYZ", "m3ReflectionYZH", "m3RotationX", "m3RotationXH", "m3RotationY", "m3RotationYH", "m3RotationZ", "m3RotationZH", "m3Scale", "m3ScaleH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m3Translation", "m3TranslationH", "m3hToCSS3d", "v2Rotate", "v2RotateH", "v2Scale", "v3RotateX", "v3RotateY", "v3RotateZ", "v3Scale", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "random_exports", "__export", "getRandom", "getRandomBoolean", "getRandomInt", "getRandomItemFromArray", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "convert_exports", "__export", "stringToNumber", "value", "defaultNumber", "_a", "res", "bezier_curve_exports", "__export", "v2CubicBezierBBox", "v2CubicBezierCurve", "v2CubicBezierCurveExtrema", "v2CubicBezierCurveNormal", "v2CubicBezierCurveTangent", "v2QuadraticBezierBBox", "v2QuadraticBezierCurve", "v2QuadraticBezierCurveExtrema", "v2QuadraticBezierCurveNormal", "v2QuadraticBezierCurveTangent", "v3CubicBezierCurve", "v3CubicBezierCurveTangent", "v3QuadraticBezierCurve", "v3QuadraticBezierCurveTangent", "derivative_exports", "__export", "dxArcCos", "dxArcCot", "dxArcSin", "dxArcTan", "dxCos", "dxCot", "dxPolynomial", "dxSin", "dxTan", "dxV2CubicBezierCurve", "dxV2QuadraticBezierCurve", "dxV3CubicBezierCurve", "dxV3QuadraticBezierCurve", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linear_equations_exports", "__export", "getLinearEquationBy2Points", "linearEquation", "linearEquationSystem2", "linearEquationSystem3", "linearEquationSystemN", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "path_movement_exports", "__export", "circleMovement", "circleMovementAfterMouse", "ellipseMovement", "ellipseMovementAfterMouse", "lissajousCurve", "sineWaveMovement", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "color_exports", "__export", "getColorsDelta", "getRandomGrayscaleHSLColor", "getRandomHSLColor", "getRandomHSLColorWithHue", "getRandomHSLColorWithLightness", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithinRanges", "getRandomHexColor", "getRandomRGBColor", "getShiftedHue", "getShiftedLightness", "getShiftedSaturation", "hexToRgb", "hslToHex", "hslToRgb", "labToRgb", "rgbToHex", "rgbToHsl", "rgbToLab", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "x", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "physics_exports", "id_exports", "__export", "guid", "newId", "c", "collision_detection_exports", "__export", "circleCollide", "convexPolygonsCollide", "rectCollide", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animation_exports", "__export", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "circle_ellipse_exports", "__export", "getCircleCircumference", "getEllipseCircumference", "getSquareInCircleSide", "isAngleInCircleArc", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "sequence_exports", "__export", "arithmeticSequenceSum", "naturalNumbersSequenceSum", "n", "a", "d", "statistics_exports", "__export", "getArithmeticMean", "getArithmeticMeanFromFrequency", "getMedian", "getMode", "getStandardDeviation", "getVariance", "getVariance1", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "ml_exports", "__export", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "series_exports", "__export", "naturalNumbersSum1ToN", "naturalNumbersSumMToN", "n", "m", "factorial_exports", "__export", "factorial", "factorialIterative", "factorialMemoized", "factorialRecursive", "n", "start", "result", "i", "memo", "traverse", "num", "end", "_a", "table", "combinatorics_exports", "__export", "combinationsWithRepetition", "combinationsWithoutRepetition", "permutationsWithRepetition", "permutationsWithoutRepetition", "permutationsWithRepetition", "n", "__pow", "permutationsWithoutRepetition", "factorial", "combinationsWithoutRepetition", "dp", "i", "j", "combinationsWithRepetition", "totalItems", "chooseItems", "api", "__spreadValues", "vector_exports", "matrix_exports", "matrix_transformations_exports", "format_exports", "angle_exports", "random_exports", "other_exports", "convert_exports", "bezier_curve_exports", "linear_equations_exports", "path_movement_exports", "color_exports", "physics_exports", "id_exports", "derivative_exports", "collision_detection_exports", "animation_exports", "circle_ellipse_exports", "sequence_exports", "statistics_exports", "ml_exports", "series_exports", "factorial_exports", "combinatorics_exports"] } diff --git a/dist/mz-math.node.cjs b/dist/mz-math.node.cjs index 16545d8..8f8ab90 100644 --- a/dist/mz-math.node.cjs +++ b/dist/mz-math.node.cjs @@ -5,10 +5,10 @@ https://github.com/mzusin/mz-math Licensed GPLv3 for open source use, or Commercial License for commercial use - https://github.com/mzusin/index/blob/main/LICENSE.md Copyright (c) 2023-present, Miriam Zusin */ -var W=Object.defineProperty;var mr=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var fr=Object.prototype.hasOwnProperty;var h=Math.pow;var pr=(t,r)=>{for(var e in r)W(t,e,{get:r[e],enumerable:!0})},br=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ar(r))!fr.call(t,o)&&o!==e&&W(t,o,{get:()=>r[o],enumerable:!(n=mr(r,o))||n.enumerable});return t};var hr=t=>br(W({},"__esModule",{value:!0}),t);var Do={};pr(Do,{animate:()=>ho,arithmeticSequenceSum:()=>go,circleCollide:()=>po,circleMovement:()=>Ut,circleMovementAfterMouse:()=>Gn,combinationsWithoutRepetition:()=>Co,convertRange:()=>O,convexPolygonsCollide:()=>bo,degreesToRadians:()=>yr,doRangesOverlap:()=>Mr,dxArcCos:()=>zn,dxArcCot:()=>En,dxArcSin:()=>Rn,dxArcTan:()=>Bn,dxCos:()=>vn,dxCot:()=>Sn,dxPolynomial:()=>In,dxSin:()=>gn,dxTan:()=>wn,dxV2CubicBezierCurve:()=>dt,dxV2QuadraticBezierCurve:()=>Vt,dxV3CubicBezierCurve:()=>yt,dxV3QuadraticBezierCurve:()=>lt,ellipseMovement:()=>Kt,ellipseMovementAfterMouse:()=>On,factorial:()=>Bt,factorialIterative:()=>Lo,factorialMemoized:()=>$o,factorialRecursive:()=>cr,getAnglesDistance:()=>Tt,getAnglesSub:()=>F,getArithmeticMean:()=>j,getArithmeticMeanFromFrequency:()=>vo,getCircleCircumference:()=>Mo,getColorsDelta:()=>xo,getEllipseCircumference:()=>Vo,getLinearEquationBy2Points:()=>Ln,getMedian:()=>wo,getMode:()=>So,getRandom:()=>V,getRandomBoolean:()=>ln,getRandomGrayscaleHSLColor:()=>Kn,getRandomHSLColor:()=>wt,getRandomHSLColorWithHue:()=>Wn,getRandomHSLColorWithLightness:()=>Un,getRandomHSLColorWithSaturation:()=>_n,getRandomHSLColorWithinRanges:()=>Jn,getRandomHexColor:()=>Zn,getRandomInt:()=>Ot,getRandomItemFromArray:()=>dn,getRandomRGBColor:()=>Qn,getShiftedHue:()=>co,getShiftedLightness:()=>so,getShiftedSaturation:()=>uo,getSquareInCircleSide:()=>yo,getStandardDeviation:()=>St,getV2Angle:()=>H,getV2AngleBetween:()=>Ir,getV2AngleInEllipse:()=>lr,getV3AngleBetween:()=>gr,getVNAngleBetween:()=>Ht,getVariance:()=>nr,getVariance1:()=>Ro,guid:()=>mo,hexToRgb:()=>oo,hslToHex:()=>tr,hslToRgb:()=>Pt,identity2:()=>ee,identity3:()=>ne,identity4:()=>oe,identityN:()=>ie,isAngleBetween:()=>vr,isAngleInCircleArc:()=>lo,isClockwise:()=>U,isNumber:()=>B,isSingularMatrix:()=>ve,labToRgb:()=>io,linearEquation:()=>L,linearEquationSystem2:()=>Hn,linearEquationSystem3:()=>Tn,linearEquationSystemN:()=>Nn,lissajousCurve:()=>kn,m2Adjugate:()=>ft,m2AppendRow:()=>xe,m2DeepCopy:()=>ct,m2Determinant:()=>at,m2DivideScalar:()=>Lt,m2Inverse:()=>bt,m2MulScalar:()=>kr,m2PrependRow:()=>fe,m2ReflectionOrigin:()=>tn,m2ReflectionOriginH:()=>rn,m2ReflectionX:()=>cn,m2ReflectionXH:()=>sn,m2ReflectionY:()=>un,m2ReflectionYH:()=>xn,m2ReflectionYmX:()=>on,m2Reset:()=>Ur,m2RotateAroundPointH:()=>Te,m2Rotation:()=>$t,m2RotationAroundPointH:()=>At,m2RotationH:()=>Mt,m2Scale:()=>Yt,m2ScaleAtPointH:()=>Ye,m2ScaleAtPointHMatrix:()=>Xt,m2ScaleH:()=>jt,m2ScaleX:()=>Fe,m2ScaleXH:()=>ke,m2ScaleY:()=>Je,m2ScaleYH:()=>Pe,m2ShearingX:()=>Vn,m2ShearingY:()=>Mn,m2Sub:()=>Or,m2Sum:()=>jr,m2ToCSS:()=>we,m2Translation:()=>Be,m2TranslationH:()=>Y,m2Transpose:()=>Wr,m2hToCSS:()=>Se,m2hToCSS3d:()=>Re,m2x2:()=>Jr,m3Adjugate:()=>ge,m3AppendRow:()=>me,m3DeepCopy:()=>st,m3Determinant:()=>Ie,m3DivideScalar:()=>Zr,m3Inverse:()=>ht,m3MulScalar:()=>Qr,m3PrependRow:()=>pe,m3ReflectionOrigin:()=>en,m3ReflectionOriginH:()=>nn,m3ReflectionXY:()=>bn,m3ReflectionXYH:()=>hn,m3ReflectionXZ:()=>fn,m3ReflectionXZH:()=>pn,m3ReflectionYZ:()=>mn,m3ReflectionYZH:()=>an,m3Reset:()=>Kr,m3RotationX:()=>qt,m3RotationXH:()=>$e,m3RotationY:()=>Ct,m3RotationYH:()=>qe,m3RotationZ:()=>Dt,m3RotationZH:()=>De,m3Scale:()=>Gt,m3ScaleH:()=>Ge,m3ScaleX:()=>Qe,m3ScaleXH:()=>Ze,m3ScaleY:()=>We,m3ScaleYH:()=>_e,m3ScaleZ:()=>Ue,m3ScaleZH:()=>Ke,m3Sub:()=>Fr,m3Sum:()=>Gr,m3Translation:()=>Ee,m3TranslationH:()=>He,m3Transpose:()=>_r,m3hToCSS3d:()=>ze,m3x3:()=>Pr,m4x4:()=>te,mAdjugate:()=>pt,mAppendCol:()=>ce,mAppendRow:()=>ue,mDeepCopy:()=>d,mDelFirstColumn:()=>Me,mDelFirstRow:()=>he,mDelLastColumn:()=>ut,mDelLastRow:()=>be,mDeterminant:()=>X,mDivideScalar:()=>Q,mEqual:()=>de,mGetColumn:()=>le,mGetFirstColumn:()=>Ve,mGetLastColumn:()=>xt,mInverse:()=>Z,mMinor:()=>mt,mMul:()=>N,mMulScalar:()=>ot,mMulVector:()=>M,mNxM:()=>re,mPrependCol:()=>se,mPrependRow:()=>ae,mReset:()=>it,mSub:()=>nt,mSum:()=>et,mTranspose:()=>D,mlNormalizeArray:()=>Rt,mlNormalizeTestData:()=>zo,mlNormalizeUnseenData:()=>Bo,mlNormalizeValue:()=>or,mlStandardizeArray:()=>zt,mlStandardizeTestData:()=>Eo,mlStandardizeUnseenData:()=>Ho,mlStandardizeValue:()=>ir,mod:()=>l,naturalNumbersSequenceSum:()=>Io,naturalNumbersSum1ToN:()=>To,naturalNumbersSumMToN:()=>No,newId:()=>ao,percentToAngle:()=>wr,permutationsWithRepetition:()=>Ao,permutationsWithoutRepetition:()=>qo,polarToCartesian:()=>Vr,radiansToDegrees:()=>dr,rectCollide:()=>fo,rgbToHex:()=>no,rgbToHsl:()=>eo,rgbToLab:()=>vt,setDecimalPlaces:()=>s,setV2Angle:()=>_,sineWaveMovement:()=>Fn,stringToNumber:()=>yn,v2:()=>Cr,v2CubicBezierBBox:()=>jn,v2CubicBezierCurve:()=>kt,v2CubicBezierCurveExtrema:()=>_t,v2CubicBezierCurveNormal:()=>Xn,v2CubicBezierCurveTangent:()=>Zt,v2Distance:()=>Lr,v2DivideScalar:()=>Er,v2DotProduct:()=>J,v2FromPolarCoords:()=>Yr,v2GetNormal:()=>rt,v2Length:()=>K,v2MulScalar:()=>Br,v2Normalize:()=>T,v2QuadraticBezierBBox:()=>Yn,v2QuadraticBezierCurve:()=>Ft,v2QuadraticBezierCurveExtrema:()=>Wt,v2QuadraticBezierCurveNormal:()=>Dn,v2QuadraticBezierCurveTangent:()=>Qt,v2Rotate:()=>Ne,v2RotateH:()=>Le,v2Scale:()=>je,v2SetLength:()=>Nt,v2Sub:()=>S,v2Sum:()=>Sr,v3:()=>Dr,v3CrossProduct:()=>qr,v3CubicBezierCurve:()=>An,v3CubicBezierCurveTangent:()=>Cn,v3Distance:()=>$r,v3DivideScalar:()=>Hr,v3DotProduct:()=>Ar,v3Length:()=>Tr,v3MulScalar:()=>k,v3Normalize:()=>g,v3QuadraticBezierCurve:()=>$n,v3QuadraticBezierCurveTangent:()=>qn,v3RotateX:()=>Ae,v3RotateY:()=>Ce,v3RotateZ:()=>Xe,v3Scale:()=>Oe,v3Sub:()=>zr,v3Sum:()=>Rr,v4:()=>Xr,vDistance:()=>Nr,vDivideScalar:()=>C,vDotProduct:()=>w,vEqual:()=>tt,vLength:()=>R,vMulScalar:()=>q,vN:()=>P,vNormalize:()=>E,vSub:()=>I,vSum:()=>A});module.exports=hr(Do);var s=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=h(10,r);return Math.round(t*e)/e};var l=(t,r)=>(t%r+r)%r,O=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Mr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),B=t=>!isNaN(parseFloat(t))&&isFinite(t),Vr=(t,r,e,n=1/0)=>{let[o,i]=t,[c,u]=r;return[s(o+c*Math.cos(e),n),s(i+u*Math.sin(e),n)]};var H=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return s(e,r)},lr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return s(n,e)},_=(t,r,e=1/0)=>{let n=K(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},dr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},yr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},Ht=(t,r,e=1/0)=>{let n=E(t),o=E(r),i=w(n,o),c=Math.acos(i);return s(c,e)},Ir=(t,r,e=1/0)=>{let n=I(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},gr=(t,r,e=1/0)=>Ht(t,r,e),vr=(t,r,e)=>{let n=F(r,e),o=F(r,t),i=F(e,t),c=o+i;return Math.abs(c-n)<=.001},U=(t,r,e=0)=>(t=t%360,r=r%360,t=t),F=(t,r,e=1/0)=>{let n=Math.abs(l(t,360)-l(r,360));return s(n<=180?n:360-n,e)},Tt=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Tt(r,e,n);return U(r,e,n)?l(n+t*o/100,360):l(n-t*o/100,360)};var A=(t,r,e=1/0)=>{let n=[];for(let o=0;oA(t,r,e),Rr=(t,r,e=1/0)=>A(t,r,e),I=(t,r,e=1/0)=>{let n=[];for(let o=0;oI(t,r,e),zr=(t,r,e=1/0)=>I(t,r,e),q=(t,r,e=1/0)=>{let n=[];for(let o=0;oq(t,r,e),k=(t,r,e=1/0)=>q(t,r,e),C=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oC(t,r,e),Hr=(t,r,e=1/0)=>C(t,r,e),R=(t,r=1/0)=>{let e=0;for(let n=0;nR(t,r),Tr=(t,r=1/0)=>R(t,r),Nt=(t,r,e=1/0)=>{let n=H(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Nr=(t,r,e=1/0)=>{let n=I(t,r);return R(n,e)},Lr=(t,r,e=1/0)=>{let n=I(t,r);return R(n,e)},$r=(t,r,e=1/0)=>{let n=I(t,r);return R(n,e)},E=(t,r=1/0)=>{let e=R(t),n=[];for(let o=0;oE(t,r),g=(t,r=1/0)=>E(t,r),w=(t,r,e=1/0)=>{let n=0;for(let o=0;ow(t,r,e),Ar=(t,r,e=1/0)=>w(t,r,e),qr=(t,r,e=1/0)=>[s(t[1]*r[2]-t[2]*r[1],e),s(t[2]*r[0]-t[0]*r[2],e),s(t[0]*r[1]-t[1]*r[0],e)],Cr=(t=0)=>[t,t],Dr=(t=0)=>[t,t,t],Xr=(t=0)=>[t,t,t,t],P=(t,r=0)=>{if(t<0)throw new Error("N must be a non-negative number.");let e=[];for(let n=0;n{let e=[0,0];return e=Nt(e,t),_(e,r)},tt=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=S(r,t);return[-s(n[1],e),s(n[0],e)]};var et=(t,r,e=1/0)=>{let n=[];for(let o=0;oet(t,r,e),Gr=(t,r,e=1/0)=>et(t,r,e),nt=(t,r,e=1/0)=>{let n=[];for(let o=0;ont(t,r,e),Fr=(t,r,e=1/0)=>nt(t,r,e),ot=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(q(o,r,e));return n},kr=(t,r,e=1/0)=>ot(t,r,e),Qr=(t,r,e=1/0)=>ot(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(C(o,r,e));return n},Lt=(t,r,e=1/0)=>Q(t,r,e),Zr=(t,r,e=1/0)=>Q(t,r,e),D=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oD(t),_r=t=>D(t),it=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nit(t,r),Kr=(t,r=0)=>it(t,r),Jr=(t=0)=>[[t,t],[t,t]],Pr=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],te=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],re=(t,r,e=0)=>{if(t<=0||r<=0)throw new Error("M and N must be positive numbers.");let n=[];for(let o=0;o[[1,0],[0,1]],ne=()=>[[1,0,0],[0,1,0],[0,0,1]],oe=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],ie=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;ed(t),st=t=>d(t),ce=(t,r)=>{if(t.length<=0)return[];let e=d(t);for(let n=0;n{if(t.length<=0)return[];let e=d(t);for(let n=0;n{let e=d(t);return e.push(r),e},xe=(t,r)=>{let e=ct(t);return e.push(r),e},me=(t,r)=>{let e=st(t);return e.push(r),e},ae=(t,r)=>{let e=d(t);return e.unshift(r),e},fe=(t,r)=>{let e=ct(t);return e.unshift(r),e},pe=(t,r)=>{let e=st(t);return e.unshift(r),e},be=t=>{if(t.length<=0)return[];let r=d(t);return r.pop(),r},he=t=>{if(t.length<=0)return[];let r=d(t);return r.shift(),r},ut=t=>{if(t.length<=0)return[];let r=d(t);for(let e=0;e{if(t.length<=0)return[];let r=d(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=ye(t,r,e);return X(o)},X=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return at(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},Ie=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)},ft=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},ge=t=>pt(t),pt=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return ft(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)===0},bt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=at(t);if(e===0)return null;let n=ft(t);return n===null?null:Lt(n,e,r)},ht=(t,r=1/0)=>Z(t,r),Z=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=X(t),o=pt(t);return o===null?null:Q(o,n,r)};var we=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1];return`matrix(${r}, ${e}, ${n}, ${o}, 0, 0)`},Se=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],c=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${c})`},Re=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],c=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${c}, 0, 1)`},ze=t=>`matrix3d( +var Z=Object.defineProperty;var xr=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var fr=Object.prototype.hasOwnProperty;var h=Math.pow;var pr=(t,r)=>{for(var e in r)Z(t,e,{get:r[e],enumerable:!0})},br=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ar(r))!fr.call(t,o)&&o!==e&&Z(t,o,{get:()=>r[o],enumerable:!(n=xr(r,o))||n.enumerable});return t};var hr=t=>br(Z({},"__esModule",{value:!0}),t);var Xo={};pr(Xo,{animate:()=>ho,arithmeticSequenceSum:()=>go,circleCollide:()=>po,circleMovement:()=>Ut,circleMovementAfterMouse:()=>Gn,combinationsWithRepetition:()=>Do,combinationsWithoutRepetition:()=>Co,convertRange:()=>O,convexPolygonsCollide:()=>bo,degreesToRadians:()=>yr,doRangesOverlap:()=>Mr,dxArcCos:()=>zn,dxArcCot:()=>En,dxArcSin:()=>Rn,dxArcTan:()=>Bn,dxCos:()=>vn,dxCot:()=>Sn,dxPolynomial:()=>In,dxSin:()=>gn,dxTan:()=>wn,dxV2CubicBezierCurve:()=>dt,dxV2QuadraticBezierCurve:()=>Vt,dxV3CubicBezierCurve:()=>yt,dxV3QuadraticBezierCurve:()=>lt,ellipseMovement:()=>Kt,ellipseMovementAfterMouse:()=>On,factorial:()=>Bt,factorialIterative:()=>Ao,factorialMemoized:()=>Lo,factorialRecursive:()=>sr,getAnglesDistance:()=>Tt,getAnglesSub:()=>F,getArithmeticMean:()=>j,getArithmeticMeanFromFrequency:()=>vo,getCircleCircumference:()=>Mo,getColorsDelta:()=>mo,getEllipseCircumference:()=>Vo,getLinearEquationBy2Points:()=>An,getMedian:()=>wo,getMode:()=>So,getRandom:()=>V,getRandomBoolean:()=>ln,getRandomGrayscaleHSLColor:()=>Kn,getRandomHSLColor:()=>wt,getRandomHSLColorWithHue:()=>Zn,getRandomHSLColorWithLightness:()=>Un,getRandomHSLColorWithSaturation:()=>_n,getRandomHSLColorWithinRanges:()=>Jn,getRandomHexColor:()=>Wn,getRandomInt:()=>Ot,getRandomItemFromArray:()=>dn,getRandomRGBColor:()=>Qn,getShiftedHue:()=>so,getShiftedLightness:()=>co,getShiftedSaturation:()=>uo,getSquareInCircleSide:()=>yo,getStandardDeviation:()=>St,getV2Angle:()=>H,getV2AngleBetween:()=>Ir,getV2AngleInEllipse:()=>lr,getV3AngleBetween:()=>gr,getVNAngleBetween:()=>Ht,getVariance:()=>nr,getVariance1:()=>Ro,guid:()=>xo,hexToRgb:()=>oo,hslToHex:()=>tr,hslToRgb:()=>Pt,identity2:()=>ee,identity3:()=>ne,identity4:()=>oe,identityN:()=>ie,isAngleBetween:()=>vr,isAngleInCircleArc:()=>lo,isClockwise:()=>U,isNumber:()=>B,isSingularMatrix:()=>ve,labToRgb:()=>io,linearEquation:()=>A,linearEquationSystem2:()=>Hn,linearEquationSystem3:()=>Tn,linearEquationSystemN:()=>Nn,lissajousCurve:()=>kn,m2Adjugate:()=>ft,m2AppendRow:()=>me,m2DeepCopy:()=>st,m2Determinant:()=>at,m2DivideScalar:()=>At,m2Inverse:()=>bt,m2MulScalar:()=>kr,m2PrependRow:()=>fe,m2ReflectionOrigin:()=>tn,m2ReflectionOriginH:()=>rn,m2ReflectionX:()=>sn,m2ReflectionXH:()=>cn,m2ReflectionY:()=>un,m2ReflectionYH:()=>mn,m2ReflectionYmX:()=>on,m2Reset:()=>Ur,m2RotateAroundPointH:()=>Te,m2Rotation:()=>Lt,m2RotationAroundPointH:()=>$t,m2RotationH:()=>Mt,m2Scale:()=>Yt,m2ScaleAtPointH:()=>Ye,m2ScaleAtPointHMatrix:()=>Xt,m2ScaleH:()=>jt,m2ScaleX:()=>Fe,m2ScaleXH:()=>ke,m2ScaleY:()=>Je,m2ScaleYH:()=>Pe,m2ShearingX:()=>Vn,m2ShearingY:()=>Mn,m2Sub:()=>Or,m2Sum:()=>jr,m2ToCSS:()=>we,m2Translation:()=>Be,m2TranslationH:()=>Y,m2Transpose:()=>Zr,m2hToCSS:()=>Se,m2hToCSS3d:()=>Re,m2x2:()=>Jr,m3Adjugate:()=>ge,m3AppendRow:()=>xe,m3DeepCopy:()=>ct,m3Determinant:()=>Ie,m3DivideScalar:()=>Wr,m3Inverse:()=>ht,m3MulScalar:()=>Qr,m3PrependRow:()=>pe,m3ReflectionOrigin:()=>en,m3ReflectionOriginH:()=>nn,m3ReflectionXY:()=>bn,m3ReflectionXYH:()=>hn,m3ReflectionXZ:()=>fn,m3ReflectionXZH:()=>pn,m3ReflectionYZ:()=>xn,m3ReflectionYZH:()=>an,m3Reset:()=>Kr,m3RotationX:()=>qt,m3RotationXH:()=>Le,m3RotationY:()=>Ct,m3RotationYH:()=>qe,m3RotationZ:()=>Dt,m3RotationZH:()=>De,m3Scale:()=>Gt,m3ScaleH:()=>Ge,m3ScaleX:()=>Qe,m3ScaleXH:()=>We,m3ScaleY:()=>Ze,m3ScaleYH:()=>_e,m3ScaleZ:()=>Ue,m3ScaleZH:()=>Ke,m3Sub:()=>Fr,m3Sum:()=>Gr,m3Translation:()=>Ee,m3TranslationH:()=>He,m3Transpose:()=>_r,m3hToCSS3d:()=>ze,m3x3:()=>Pr,m4x4:()=>te,mAdjugate:()=>pt,mAppendCol:()=>se,mAppendRow:()=>ue,mDeepCopy:()=>d,mDelFirstColumn:()=>Me,mDelFirstRow:()=>he,mDelLastColumn:()=>ut,mDelLastRow:()=>be,mDeterminant:()=>X,mDivideScalar:()=>Q,mEqual:()=>de,mGetColumn:()=>le,mGetFirstColumn:()=>Ve,mGetLastColumn:()=>mt,mInverse:()=>W,mMinor:()=>xt,mMul:()=>N,mMulScalar:()=>ot,mMulVector:()=>M,mNxM:()=>re,mPrependCol:()=>ce,mPrependRow:()=>ae,mReset:()=>it,mSub:()=>nt,mSum:()=>et,mTranspose:()=>D,mlNormalizeArray:()=>Rt,mlNormalizeTestData:()=>zo,mlNormalizeUnseenData:()=>Bo,mlNormalizeValue:()=>or,mlStandardizeArray:()=>zt,mlStandardizeTestData:()=>Eo,mlStandardizeUnseenData:()=>Ho,mlStandardizeValue:()=>ir,mod:()=>l,naturalNumbersSequenceSum:()=>Io,naturalNumbersSum1ToN:()=>To,naturalNumbersSumMToN:()=>No,newId:()=>ao,percentToAngle:()=>wr,permutationsWithRepetition:()=>$o,permutationsWithoutRepetition:()=>qo,polarToCartesian:()=>Vr,radiansToDegrees:()=>dr,rectCollide:()=>fo,rgbToHex:()=>no,rgbToHsl:()=>eo,rgbToLab:()=>vt,setDecimalPlaces:()=>c,setV2Angle:()=>_,sineWaveMovement:()=>Fn,stringToNumber:()=>yn,v2:()=>Cr,v2CubicBezierBBox:()=>jn,v2CubicBezierCurve:()=>kt,v2CubicBezierCurveExtrema:()=>_t,v2CubicBezierCurveNormal:()=>Xn,v2CubicBezierCurveTangent:()=>Wt,v2Distance:()=>Ar,v2DivideScalar:()=>Er,v2DotProduct:()=>J,v2FromPolarCoords:()=>Yr,v2GetNormal:()=>rt,v2Length:()=>K,v2MulScalar:()=>Br,v2Normalize:()=>T,v2QuadraticBezierBBox:()=>Yn,v2QuadraticBezierCurve:()=>Ft,v2QuadraticBezierCurveExtrema:()=>Zt,v2QuadraticBezierCurveNormal:()=>Dn,v2QuadraticBezierCurveTangent:()=>Qt,v2Rotate:()=>Ne,v2RotateH:()=>Ae,v2Scale:()=>je,v2SetLength:()=>Nt,v2Sub:()=>S,v2Sum:()=>Sr,v3:()=>Dr,v3CrossProduct:()=>qr,v3CubicBezierCurve:()=>$n,v3CubicBezierCurveTangent:()=>Cn,v3Distance:()=>Lr,v3DivideScalar:()=>Hr,v3DotProduct:()=>$r,v3Length:()=>Tr,v3MulScalar:()=>k,v3Normalize:()=>g,v3QuadraticBezierCurve:()=>Ln,v3QuadraticBezierCurveTangent:()=>qn,v3RotateX:()=>$e,v3RotateY:()=>Ce,v3RotateZ:()=>Xe,v3Scale:()=>Oe,v3Sub:()=>zr,v3Sum:()=>Rr,v4:()=>Xr,vDistance:()=>Nr,vDivideScalar:()=>C,vDotProduct:()=>w,vEqual:()=>tt,vLength:()=>R,vMulScalar:()=>q,vN:()=>P,vNormalize:()=>E,vSub:()=>I,vSum:()=>$});module.exports=hr(Xo);var c=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=h(10,r);return Math.round(t*e)/e};var l=(t,r)=>(t%r+r)%r,O=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Mr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),B=t=>!isNaN(parseFloat(t))&&isFinite(t),Vr=(t,r,e,n=1/0)=>{let[o,i]=t,[s,u]=r;return[c(o+s*Math.cos(e),n),c(i+u*Math.sin(e),n)]};var H=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return c(e,r)},lr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return c(n,e)},_=(t,r,e=1/0)=>{let n=K(t);return[c(Math.cos(r)*n,e),c(Math.sin(r)*n,e)]},dr=(t,r=1/0)=>{let e=t*(180/Math.PI);return c(e,r)},yr=(t,r=1/0)=>{let e=t*(Math.PI/180);return c(e,r)},Ht=(t,r,e=1/0)=>{let n=E(t),o=E(r),i=w(n,o),s=Math.acos(i);return c(s,e)},Ir=(t,r,e=1/0)=>{let n=I(t,r),o=Math.atan2(n[1],n[0]);return c(o,e)},gr=(t,r,e=1/0)=>Ht(t,r,e),vr=(t,r,e)=>{let n=F(r,e),o=F(r,t),i=F(e,t),s=o+i;return Math.abs(s-n)<=.001},U=(t,r,e=0)=>(t=t%360,r=r%360,t=t),F=(t,r,e=1/0)=>{let n=Math.abs(l(t,360)-l(r,360));return c(n<=180?n:360-n,e)},Tt=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Tt(r,e,n);return U(r,e,n)?l(n+t*o/100,360):l(n-t*o/100,360)};var $=(t,r,e=1/0)=>{let n=[];for(let o=0;o$(t,r,e),Rr=(t,r,e=1/0)=>$(t,r,e),I=(t,r,e=1/0)=>{let n=[];for(let o=0;oI(t,r,e),zr=(t,r,e=1/0)=>I(t,r,e),q=(t,r,e=1/0)=>{let n=[];for(let o=0;oq(t,r,e),k=(t,r,e=1/0)=>q(t,r,e),C=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oC(t,r,e),Hr=(t,r,e=1/0)=>C(t,r,e),R=(t,r=1/0)=>{let e=0;for(let n=0;nR(t,r),Tr=(t,r=1/0)=>R(t,r),Nt=(t,r,e=1/0)=>{let n=H(t);return[c(Math.cos(n)*r,e),c(Math.sin(n)*r,e)]},Nr=(t,r,e=1/0)=>{let n=I(t,r);return R(n,e)},Ar=(t,r,e=1/0)=>{let n=I(t,r);return R(n,e)},Lr=(t,r,e=1/0)=>{let n=I(t,r);return R(n,e)},E=(t,r=1/0)=>{let e=R(t),n=[];for(let o=0;oE(t,r),g=(t,r=1/0)=>E(t,r),w=(t,r,e=1/0)=>{let n=0;for(let o=0;ow(t,r,e),$r=(t,r,e=1/0)=>w(t,r,e),qr=(t,r,e=1/0)=>[c(t[1]*r[2]-t[2]*r[1],e),c(t[2]*r[0]-t[0]*r[2],e),c(t[0]*r[1]-t[1]*r[0],e)],Cr=(t=0)=>[t,t],Dr=(t=0)=>[t,t,t],Xr=(t=0)=>[t,t,t,t],P=(t,r=0)=>{if(t<0)throw new Error("N must be a non-negative number.");let e=[];for(let n=0;n{let e=[0,0];return e=Nt(e,t),_(e,r)},tt=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=S(r,t);return[-c(n[1],e),c(n[0],e)]};var et=(t,r,e=1/0)=>{let n=[];for(let o=0;oet(t,r,e),Gr=(t,r,e=1/0)=>et(t,r,e),nt=(t,r,e=1/0)=>{let n=[];for(let o=0;ont(t,r,e),Fr=(t,r,e=1/0)=>nt(t,r,e),ot=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(q(o,r,e));return n},kr=(t,r,e=1/0)=>ot(t,r,e),Qr=(t,r,e=1/0)=>ot(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(C(o,r,e));return n},At=(t,r,e=1/0)=>Q(t,r,e),Wr=(t,r,e=1/0)=>Q(t,r,e),D=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oD(t),_r=t=>D(t),it=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nit(t,r),Kr=(t,r=0)=>it(t,r),Jr=(t=0)=>[[t,t],[t,t]],Pr=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],te=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],re=(t,r,e=0)=>{if(t<=0||r<=0)throw new Error("M and N must be positive numbers.");let n=[];for(let o=0;o[[1,0],[0,1]],ne=()=>[[1,0,0],[0,1,0],[0,0,1]],oe=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],ie=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;ed(t),ct=t=>d(t),se=(t,r)=>{if(t.length<=0)return[];let e=d(t);for(let n=0;n{if(t.length<=0)return[];let e=d(t);for(let n=0;n{let e=d(t);return e.push(r),e},me=(t,r)=>{let e=st(t);return e.push(r),e},xe=(t,r)=>{let e=ct(t);return e.push(r),e},ae=(t,r)=>{let e=d(t);return e.unshift(r),e},fe=(t,r)=>{let e=st(t);return e.unshift(r),e},pe=(t,r)=>{let e=ct(t);return e.unshift(r),e},be=t=>{if(t.length<=0)return[];let r=d(t);return r.pop(),r},he=t=>{if(t.length<=0)return[];let r=d(t);return r.shift(),r},ut=t=>{if(t.length<=0)return[];let r=d(t);for(let e=0;e{if(t.length<=0)return[];let r=d(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=ye(t,r,e);return X(o)},X=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return at(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},Ie=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)},ft=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},ge=t=>pt(t),pt=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return ft(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)===0},bt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=at(t);if(e===0)return null;let n=ft(t);return n===null?null:At(n,e,r)},ht=(t,r=1/0)=>W(t,r),W=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=X(t),o=pt(t);return o===null?null:Q(o,n,r)};var we=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1];return`matrix(${r}, ${e}, ${n}, ${o}, 0, 0)`},Se=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${s})`},Re=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${s}, 0, 1)`},ze=t=>`matrix3d( ${t[0][0]}, ${t[0][1]}, ${t[0][2]}, ${t[0][3]}, ${t[1][0]}, ${t[1][1]}, ${t[1][2]}, ${t[1][3]}, ${t[2][0]}, ${t[2][1]}, ${t[2][2]}, ${t[2][3]}, ${t[3][0]}, ${t[3][1]}, ${t[3][2]}, ${t[3][3]} - )`,Be=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Ee=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[s(t[0],r),s(t[1],r),s(t[2],r)]],Y=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],He=(t,r=1/0)=>[[1,0,0,s(t[0],r)],[0,1,0,s(t[1],r)],[0,0,1,s(t[2],r)],[0,0,0,1]],$t=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},Mt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},At=(t,r,e=!0,n=1/0)=>{let o=Y(r,n),i=Mt(t,e,n),c=Y(k(r,-1),n),u=N(o,i);return N(u,c)},Te=(t,r,e,n=!0,o=1/0)=>{let i=At(t,r,n,o);return M(i,e)},Ne=(t,r,e=!0,n=1/0)=>{let o=T(r);return M($t(t,e,n),o)},Le=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(Mt(t,e,n),o)},qt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},$e=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[1,0,0,0],[0,n,-o,0],[0,o,n,0],[0,0,0,1]]:[[1,0,0,0],[0,n,o,0],[0,-o,n,0],[0,0,0,1]]},Ae=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(qt(t,e,n),o)},Ct=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},qe=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},Ce=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(Ct(t,e,n),o)},Dt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},De=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0,0],[o,n,0,0],[0,0,1,0],[0,0,0,1]]:[[n,o,0,0],[-o,n,0,0],[0,0,1,0],[0,0,0,1]]},Xe=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(Dt(t,e,n),o)},Xt=(t,r,e=1/0)=>{let n=Y(r,e),o=jt(t),i=Y(k(r,-1),e),c=N(n,o);return N(c,i)},Ye=(t,r,e,n=1/0)=>{let o=Xt(t,r,n);return M(o,e)},Yt=t=>[[t[0],0],[0,t[1]]],je=(t,r)=>M(Yt(t),r),jt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Gt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Ge=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Oe=(t,r)=>M(Gt(t),r),Fe=t=>[[t,0],[0,1]],ke=t=>[[t,0,0],[0,1,0],[0,0,1]],Qe=t=>[[t,0,0],[0,1,0],[0,0,1]],Ze=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],We=t=>[[1,0,0],[0,t,0],[0,0,1]],_e=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],Ue=t=>[[1,0,0],[0,1,0],[0,0,t]],Ke=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],Je=t=>[[1,0],[0,t]],Pe=t=>[[1,0,0],[0,t,0],[0,0,1]],tn=()=>[[-1,0],[0,-1]],rn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],en=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],nn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],on=()=>[[0,-1],[-1,0]],cn=()=>[[1,0],[0,-1]],sn=()=>[[1,0,0],[0,-1,0],[0,0,1]],un=()=>[[-1,0],[0,1]],xn=()=>[[-1,0,0],[0,1,0],[0,0,1]],mn=()=>[[-1,0,0],[0,1,0],[0,0,1]],an=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],fn=()=>[[1,0,0],[0,-1,0],[0,0,1]],pn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],bn=()=>[[1,0,0],[0,1,0],[0,0,-1]],hn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Mn=t=>[[1,t],[0,1]],Vn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),Ot=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),ln=()=>Math.random()<.5,dn=t=>{let r=Ot(0,t.length-1);return t[r]};var yn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var In=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],c=o[1];n+=i*c*Math.pow(t,c-1)}return s(n,e)},Vt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},lt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},dt=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},yt=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+m*o[2],i)]},gn=(t,r=1/0)=>s(Math.cos(t),r),vn=(t,r=1/0)=>s(-Math.sin(t),r),wn=(t,r=1/0)=>s(1/h(Math.cos(t),2),r),Sn=(t,r=1/0)=>s(-1/h(Math.sin(t),2),r),Rn=(t,r=1/0)=>s(1/Math.sqrt(1-h(t,2)),r),zn=(t,r=1/0)=>s(-1/Math.sqrt(1-h(t,2)),r),Bn=(t,r=1/0)=>s(1/(1+h(t,2)),r),En=(t,r=1/0)=>s(-1/(1+h(t,2)),r);var L=(t,r=1/0)=>{let e=t[0],n=t[1],i=t[2]-n;return e===0&&i===0?1/0:e===0?NaN:s(i/e,r)},Hn=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=bt(n);if(o===null)return null;let i=[t[2],r[2]];return M(o,i,e)},Tn=(t,r,e,n=1/0)=>{let o=[[t[0],t[1],t[2]],[r[0],r[1],r[2]],[e[0],e[1],e[2]]],i=ht(o);if(i===null)return null;let c=[t[3],r[3],e[3]];return M(i,c,n)},Nn=(t,r=1/0)=>{if(t.length<=0)return null;let e=ut(t),n=Z(e);if(n===null)return null;let o=xt(t);return M(n,o,r)},Ln=(t,r)=>{let[e,n]=S(r,t),[o,i]=t;if(e===0)return{slope:void 0,xIntercept:o,yIntercept:void 0,formula:`x = ${o}`};let c=n/e,u=i-c*o,x="";return c===0?x=`y = ${u}`:(x=`y = ${c===1?"":c}x`,u!==0&&(x+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:c,xIntercept:void 0,yIntercept:u,formula:x}};var It=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=L([n,o,i],r);return B(f)?[f]:[]}let c=o-i,u=n*n-4*e*c;if(u<0)return[];if(u===0)return[s(-n/(2*e),r)];let x=2*e,m=Math.sqrt(u);return[s((-n+m)/x,r),s((-n-m)/x,r)]};var Ft=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},$n=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},kt=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,x=(1-t)*3*t*t,m=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},An=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,x=(1-t)*3*t*t,m=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+m*o[2],i)]},Qt=(t,r,e,n,o=1/0)=>{let i=Vt(t,r,e,n);return T(i,o)},qn=(t,r,e,n,o=1/0)=>{let i=lt(t,r,e,n);return g(i,o)},Zt=(t,r,e,n,o,i=1/0)=>{let c=dt(t,r,e,n,o);return T(c,i)},Cn=(t,r,e,n,o,i=1/0)=>{let c=yt(t,r,e,n,o);return g(c,i)},Dn=(t,r,e,n,o=1/0)=>{let i=Qt(t,r,e,n,o);return[-i[1],i[0]]},Xn=(t,r,e,n,o,i=1/0)=>{let c=Zt(t,r,e,n,o,i);return[-c[1],c[0]]},Wt=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=L([o,i,0],n),x=2*t[1]-4*r[1]+2*e[1],m=-2*t[1]+2*r[1],p=L([x,m,0],n),a=[];return B(u)&&a.push(u),B(p)&&a.push(p),a},_t=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],c=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],x=[i,c,u,0],m=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[m,f,p,0],b=It(x,o).filter(y=>y>=0&&y<=1),v=It(a,o).filter(y=>y>=0&&y<=1);return[...b,...v].length===2?[...b,...v]:null},Yn=(t,r,e,n=1/0)=>{let o=Wt(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=Ft(m,t,r,e),p=f[0],a=f[1];i=Math.min(i,p),u=Math.max(u,p),c=Math.min(c,a),x=Math.max(x,a)}return i=s(Math.min(i,t[0],e[0]),n),u=s(Math.max(u,t[0],e[0]),n),c=s(Math.min(c,t[1],e[1]),n),x=s(Math.max(x,t[1],e[1]),n),{x:i,y:c,w:Math.abs(u-i),h:Math.abs(x-c),x2:u,y2:x}},jn=(t,r,e,n,o=1/0)=>{let i=_t(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=kt(f,t,r,e,n),a=p[0],b=p[1];c=Math.min(c,a!=null?a:1/0),x=Math.max(x,a!=null?a:-1/0),u=Math.min(u,b!=null?b:1/0),m=Math.max(m,b!=null?b:-1/0)}return c=s(Math.min(c,t[0],n[0]),o),x=s(Math.max(x,t[0],n[0]),o),u=s(Math.min(u,t[1],n[1]),o),m=s(Math.max(m,t[1],n[1]),o),{x:c,y:u,w:Math.abs(x-c),h:Math.abs(m-u),x2:x,y2:m}};var Ut=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Gn=(t,r,e)=>{let n=S(t,r),o=H(n);return o=O(o,0,Math.PI*2,0,Math.PI),Ut(r,o,e)},Kt=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),On=(t,r,e)=>{let n=S(t,r),o=H(n);return o=O(o,0,Math.PI*2,0,Math.PI),Kt(r,o,e[0],e[1])},Fn=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},kn=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Qn=()=>{let t=wt();return Pt(t)},Zn=()=>{let t=wt();return tr(t)},wt=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Wn=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},_n=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Un=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Kn=()=>[0,0,V(0,100)],Jn=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let c=V(t,r),u=V(e,n),x=V(o,i);return[c,u,x]},Pn=t=>(t*=60,t<0&&(t+=360),t),to=(t,r,e,n=void 0,o=void 0)=>{if(n=n===void 0?Math.min(t,r,e):n,o=o===void 0?Math.max(t,r,e):o,n===o)return 0;let i=o-n,c=0;return o===t&&(c=(r-e)/i+(r(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,(n+o)/2*100),ro=(t,r,e,n=void 0,o=void 0,i=void 0)=>(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,n===o?0:(i=i===void 0?Jt(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),eo=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255,i=Math.min(e,n,o),c=Math.max(e,n,o),u=Jt(e,n,o,i,c),x=ro(e,n,o,i,c,u),m=to(e,n,o,i,c);return m>360||x>100||u>100?[0,0,100]:m<0||x<0||u<0?[0,0,0]:[s(m,r),s(x,r),s(u,r)]},gt=(t,r,e)=>(e<0&&(e+=1),e>1&&(e-=1),e*6<1?r+(t-r)*6*e:e*2<1?t:e*3<2?r+(t-r)*(.666-e)*6:r),Pt=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let b=o*255;return[b,b,b]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,m=e-.333,f=gt(i,c,u),p=gt(i,c,x),a=gt(i,c,m);return f*=255,p*=255,a*=255,f>255||p>255||a>255?[255,255,255]:f<0||p<0||a<0?[0,0,0]:[s(f,r),s(p,r),s(a,r)]},tr=t=>{if(t[0]>360||t[1]>100||t[2]>100)return"#ffffff";if(t[0]<0||t[1]<0||t[2]<0)return"#000000";let r=t[0]/360,e=t[1]/100,n=t[2]/100,o,i,c;if(e===0)o=i=c=n;else{let x=(p,a,b)=>(b<0&&(b+=1),b>1&&(b-=1),b<.16666666666666666?p+(a-p)*6*b:b<.5?a:b<.6666666666666666?p+(a-p)*(.6666666666666666-b)*6:p),m=n<.5?n*(1+e):n+e-n*e,f=2*n-m;o=x(f,m,r+1/3),i=x(f,m,r),c=x(f,m,r-1/3)}let u=x=>{let m=Math.round(x*255).toString(16);return m.length===1?"0"+m:m};return`#${u(o)}${u(i)}${u(c)}`},no=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},oo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,m,f)=>x+x+m+m+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),c=parseInt(n[3],16);return[o,i,c]},vt=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;let i=(e*.4124+n*.3576+o*.1805)/.95047,c=(e*.2126+n*.7152+o*.0722)/1,u=(e*.0193+n*.1192+o*.9505)/1.08883;return i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,c=c>.008856?Math.pow(c,1/3):7.787*c+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,[s(116*c-16,r),s(500*(i-c),r),s(200*(c-u),r)]},io=(t,r=1/0)=>{let e=(t[0]+16)/116,n=t[1]/500+e,o=e-t[2]/200;n=.95047*(n*n*n>.008856?n*n*n:(n-16/116)/7.787),e=1*(e*e*e>.008856?e*e*e:(e-16/116)/7.787),o=1.08883*(o*o*o>.008856?o*o*o:(o-16/116)/7.787);let i=n*3.2406+e*-1.5372+o*-.4986,c=n*-.9689+e*1.8758+o*.0415,u=n*.0557+e*-.204+o*1.057;return i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,c=c>.0031308?1.055*Math.pow(c,1/2.4)-.055:12.92*c,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:12.92*u,[s(Math.max(0,Math.min(1,i))*255,r),s(Math.max(0,Math.min(1,c))*255,r),s(Math.max(0,Math.min(1,u))*255,r)]},co=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=l(e,360)),[e,t[1],t[2]]},so=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=l(e,100)),[t[0],t[1],e]},uo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},xo=(t,r,e=1/0)=>{let n=vt(t,e),o=vt(r,e),i=n[0]-o[0],c=n[1]-o[1],u=n[2]-o[2],x=Math.sqrt(n[1]*n[1]+n[2]*n[2]),m=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=x-m,p=c*c+u*u-f*f;p=p<0?0:Math.sqrt(p);let a=1+.045*x,b=1+.015*x,v=i/1,$=f/a,y=p/b,G=v*v+$*$+y*y;return G<0?0:Math.sqrt(G)};var mo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),ao=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var fo=(t,r)=>t.x<=r.x+r.w&&t.x+t.w>=r.x&&t.y<=r.y+r.h&&t.h+t.y>=r.y,po=(t,r)=>{let e=Math.abs(t.cx-r.cx),n=Math.abs(t.cy-r.cy);return Math.sqrt(e*e+n*n)<=t.r+r.r},rr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...rr(t)),e.push(...rr(r));for(let n of e){let o=rt(n[0],n[1]),i=er(t,o),c=er(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},er=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=J(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var ho=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,c=!1,u,x=()=>{e=void 0,o=void 0,i=void 0,c=!1,n!==void 0&&window.cancelAnimationFrame(n)},m=()=>{x(),v()},f=()=>{c=!1},p=()=>{c=!0},a=z=>{e===void 0&&(e=z),o=z-e,c&&i!==z&&typeof t.callback=="function"&&t.callback(Et()),o<=r?(i=z,n=window.requestAnimationFrame(a)):x()},b=(z,xr)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(z,xr)},v=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(b),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(a)},$=()=>o,y=()=>c,G=()=>e,sr=()=>{if(!(r===1/0||o===void 0))return o*100/r},ur=()=>u,Et=()=>({start:v,stop:x,pause:f,resume:p,restart:m,isAnimating:y,getElapsedTime:$,getStartTime:G,getPercent:sr,getResizeObserver:ur});return Et()};var Mo=(t,r=1/0)=>s(2*Math.PI*t,r),Vo=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),lo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),yo=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var Io=t=>t*(t+1)/2,go=(t,r,e)=>t/2*(2*r+(t-1)*e);var j=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return s(e/t.length,r)},vo=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return s(e,r)},wo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=[...t].sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?s((e[n]+e[n-1])/2,r):s(e[n],r)},So=t=>{if(!t||t.length<=0)return;let r=new Map;for(let o of t)r.set(o,(r.get(o)||0)+1);let e=0,n=[];for(let[o,i]of r)i>e?(e=i,n=[o]):i===e&&n.push(o);if(n.length!==t.length)return n.length===1?[n[0]]:n},Ro=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return s(n/t.length,r)},nr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i,2),0);return s(n/t.length-h(e,2),r)},St=(t,r=1/0)=>{var n;let e=(n=nr(t))!=null?n:0;return s(Math.sqrt(e),r)};var or=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:s((t-r)/o,n)},Rt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Rt(t,e,n,r);return{min:s(e,r),max:s(n,r),data:o}},Bo=(t,r,e,n=1/0)=>Rt(t,r,e,n),ir=(t,r,e,n=1/0)=>e===0?0:s((t-r)/e,n),zt=(t,r,e,n=1/0)=>[...t].map(o=>ir(o,r,e,n)),Eo=(t,r=1/0)=>{var i;let e=(i=j(t))!=null?i:0,n=St(t),o=zt(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}},Ho=(t,r,e,n=1/0)=>zt(t,r,e,n);var To=t=>t/2*(t+1),No=(t,r)=>(r-t+1)*(t+r)/2;var Lo=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=1;for(let n=r;n<=t;n++)e*=n;return e},cr=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}return t===r?r:t*cr(t-1,r)},$o=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=new Map,n=(o,i)=>{var u;if(o{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===t)return t===0?1:t;r===0&&(r=1);let e=[];e[0]=1;for(let n=1;n<=t;n++)e[n]=e[n-1]*n;return e[t]/e[r-1]};var Ao=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return h(t,r)},qo=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return Bt(t,t-r+1)},Co=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");let e=Array.from({length:t+1},()=>Array(r+1).fill(0));for(let n=0;n<=t;n++)e[n][0]=1,n<=r&&(e[n][n]=1);for(let n=1;n<=t;n++)for(let o=1;o<=Math.min(n,r);o++)e[n][o]=e[n-1][o-1]+e[n-1][o];return e[t][r]};0&&(module.exports={animate,arithmeticSequenceSum,circleCollide,circleMovement,circleMovementAfterMouse,combinationsWithoutRepetition,convertRange,convexPolygonsCollide,degreesToRadians,doRangesOverlap,dxArcCos,dxArcCot,dxArcSin,dxArcTan,dxCos,dxCot,dxPolynomial,dxSin,dxTan,dxV2CubicBezierCurve,dxV2QuadraticBezierCurve,dxV3CubicBezierCurve,dxV3QuadraticBezierCurve,ellipseMovement,ellipseMovementAfterMouse,factorial,factorialIterative,factorialMemoized,factorialRecursive,getAnglesDistance,getAnglesSub,getArithmeticMean,getArithmeticMeanFromFrequency,getCircleCircumference,getColorsDelta,getEllipseCircumference,getLinearEquationBy2Points,getMedian,getMode,getRandom,getRandomBoolean,getRandomGrayscaleHSLColor,getRandomHSLColor,getRandomHSLColorWithHue,getRandomHSLColorWithLightness,getRandomHSLColorWithSaturation,getRandomHSLColorWithinRanges,getRandomHexColor,getRandomInt,getRandomItemFromArray,getRandomRGBColor,getShiftedHue,getShiftedLightness,getShiftedSaturation,getSquareInCircleSide,getStandardDeviation,getV2Angle,getV2AngleBetween,getV2AngleInEllipse,getV3AngleBetween,getVNAngleBetween,getVariance,getVariance1,guid,hexToRgb,hslToHex,hslToRgb,identity2,identity3,identity4,identityN,isAngleBetween,isAngleInCircleArc,isClockwise,isNumber,isSingularMatrix,labToRgb,linearEquation,linearEquationSystem2,linearEquationSystem3,linearEquationSystemN,lissajousCurve,m2Adjugate,m2AppendRow,m2DeepCopy,m2Determinant,m2DivideScalar,m2Inverse,m2MulScalar,m2PrependRow,m2ReflectionOrigin,m2ReflectionOriginH,m2ReflectionX,m2ReflectionXH,m2ReflectionY,m2ReflectionYH,m2ReflectionYmX,m2Reset,m2RotateAroundPointH,m2Rotation,m2RotationAroundPointH,m2RotationH,m2Scale,m2ScaleAtPointH,m2ScaleAtPointHMatrix,m2ScaleH,m2ScaleX,m2ScaleXH,m2ScaleY,m2ScaleYH,m2ShearingX,m2ShearingY,m2Sub,m2Sum,m2ToCSS,m2Translation,m2TranslationH,m2Transpose,m2hToCSS,m2hToCSS3d,m2x2,m3Adjugate,m3AppendRow,m3DeepCopy,m3Determinant,m3DivideScalar,m3Inverse,m3MulScalar,m3PrependRow,m3ReflectionOrigin,m3ReflectionOriginH,m3ReflectionXY,m3ReflectionXYH,m3ReflectionXZ,m3ReflectionXZH,m3ReflectionYZ,m3ReflectionYZH,m3Reset,m3RotationX,m3RotationXH,m3RotationY,m3RotationYH,m3RotationZ,m3RotationZH,m3Scale,m3ScaleH,m3ScaleX,m3ScaleXH,m3ScaleY,m3ScaleYH,m3ScaleZ,m3ScaleZH,m3Sub,m3Sum,m3Translation,m3TranslationH,m3Transpose,m3hToCSS3d,m3x3,m4x4,mAdjugate,mAppendCol,mAppendRow,mDeepCopy,mDelFirstColumn,mDelFirstRow,mDelLastColumn,mDelLastRow,mDeterminant,mDivideScalar,mEqual,mGetColumn,mGetFirstColumn,mGetLastColumn,mInverse,mMinor,mMul,mMulScalar,mMulVector,mNxM,mPrependCol,mPrependRow,mReset,mSub,mSum,mTranspose,mlNormalizeArray,mlNormalizeTestData,mlNormalizeUnseenData,mlNormalizeValue,mlStandardizeArray,mlStandardizeTestData,mlStandardizeUnseenData,mlStandardizeValue,mod,naturalNumbersSequenceSum,naturalNumbersSum1ToN,naturalNumbersSumMToN,newId,percentToAngle,permutationsWithRepetition,permutationsWithoutRepetition,polarToCartesian,radiansToDegrees,rectCollide,rgbToHex,rgbToHsl,rgbToLab,setDecimalPlaces,setV2Angle,sineWaveMovement,stringToNumber,v2,v2CubicBezierBBox,v2CubicBezierCurve,v2CubicBezierCurveExtrema,v2CubicBezierCurveNormal,v2CubicBezierCurveTangent,v2Distance,v2DivideScalar,v2DotProduct,v2FromPolarCoords,v2GetNormal,v2Length,v2MulScalar,v2Normalize,v2QuadraticBezierBBox,v2QuadraticBezierCurve,v2QuadraticBezierCurveExtrema,v2QuadraticBezierCurveNormal,v2QuadraticBezierCurveTangent,v2Rotate,v2RotateH,v2Scale,v2SetLength,v2Sub,v2Sum,v3,v3CrossProduct,v3CubicBezierCurve,v3CubicBezierCurveTangent,v3Distance,v3DivideScalar,v3DotProduct,v3Length,v3MulScalar,v3Normalize,v3QuadraticBezierCurve,v3QuadraticBezierCurveTangent,v3RotateX,v3RotateY,v3RotateZ,v3Scale,v3Sub,v3Sum,v4,vDistance,vDivideScalar,vDotProduct,vEqual,vLength,vMulScalar,vN,vNormalize,vSub,vSum}); + )`,Be=(t,r=1/0)=>[[1,0],[0,1],[c(t[0],r),c(t[1],r)]],Ee=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[c(t[0],r),c(t[1],r),c(t[2],r)]],Y=(t,r=1/0)=>[[1,0,c(t[0],r)],[0,1,c(t[1],r)],[0,0,1]],He=(t,r=1/0)=>[[1,0,0,c(t[0],r)],[0,1,0,c(t[1],r)],[0,0,1,c(t[2],r)],[0,0,0,1]],Lt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},Mt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},$t=(t,r,e=!0,n=1/0)=>{let o=Y(r,n),i=Mt(t,e,n),s=Y(k(r,-1),n),u=N(o,i);return N(u,s)},Te=(t,r,e,n=!0,o=1/0)=>{let i=$t(t,r,n,o);return M(i,e)},Ne=(t,r,e=!0,n=1/0)=>{let o=T(r);return M(Lt(t,e,n),o)},Ae=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(Mt(t,e,n),o)},qt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},Le=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0,0],[0,n,-o,0],[0,o,n,0],[0,0,0,1]]:[[1,0,0,0],[0,n,o,0],[0,-o,n,0],[0,0,0,1]]},$e=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(qt(t,e,n),o)},Ct=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},qe=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},Ce=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(Ct(t,e,n),o)},Dt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},De=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0,0],[o,n,0,0],[0,0,1,0],[0,0,0,1]]:[[n,o,0,0],[-o,n,0,0],[0,0,1,0],[0,0,0,1]]},Xe=(t,r,e=!0,n=1/0)=>{let o=g(r);return M(Dt(t,e,n),o)},Xt=(t,r,e=1/0)=>{let n=Y(r,e),o=jt(t),i=Y(k(r,-1),e),s=N(n,o);return N(s,i)},Ye=(t,r,e,n=1/0)=>{let o=Xt(t,r,n);return M(o,e)},Yt=t=>[[t[0],0],[0,t[1]]],je=(t,r)=>M(Yt(t),r),jt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Gt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Ge=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Oe=(t,r)=>M(Gt(t),r),Fe=t=>[[t,0],[0,1]],ke=t=>[[t,0,0],[0,1,0],[0,0,1]],Qe=t=>[[t,0,0],[0,1,0],[0,0,1]],We=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Ze=t=>[[1,0,0],[0,t,0],[0,0,1]],_e=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],Ue=t=>[[1,0,0],[0,1,0],[0,0,t]],Ke=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],Je=t=>[[1,0],[0,t]],Pe=t=>[[1,0,0],[0,t,0],[0,0,1]],tn=()=>[[-1,0],[0,-1]],rn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],en=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],nn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],on=()=>[[0,-1],[-1,0]],sn=()=>[[1,0],[0,-1]],cn=()=>[[1,0,0],[0,-1,0],[0,0,1]],un=()=>[[-1,0],[0,1]],mn=()=>[[-1,0,0],[0,1,0],[0,0,1]],xn=()=>[[-1,0,0],[0,1,0],[0,0,1]],an=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],fn=()=>[[1,0,0],[0,-1,0],[0,0,1]],pn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],bn=()=>[[1,0,0],[0,1,0],[0,0,-1]],hn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Mn=t=>[[1,t],[0,1]],Vn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>c(Math.random()*(r-t)+t,e),Ot=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),ln=()=>Math.random()<.5,dn=t=>{let r=Ot(0,t.length-1);return t[r]};var yn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var In=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],s=o[1];n+=i*s*Math.pow(t,s-1)}return c(n,e)},Vt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},lt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},dt=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,x=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i)]},yt=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,x=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},gn=(t,r=1/0)=>c(Math.cos(t),r),vn=(t,r=1/0)=>c(-Math.sin(t),r),wn=(t,r=1/0)=>c(1/h(Math.cos(t),2),r),Sn=(t,r=1/0)=>c(-1/h(Math.sin(t),2),r),Rn=(t,r=1/0)=>c(1/Math.sqrt(1-h(t,2)),r),zn=(t,r=1/0)=>c(-1/Math.sqrt(1-h(t,2)),r),Bn=(t,r=1/0)=>c(1/(1+h(t,2)),r),En=(t,r=1/0)=>c(-1/(1+h(t,2)),r);var A=(t,r=1/0)=>{let e=t[0],n=t[1],i=t[2]-n;return e===0&&i===0?1/0:e===0?NaN:c(i/e,r)},Hn=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=bt(n);if(o===null)return null;let i=[t[2],r[2]];return M(o,i,e)},Tn=(t,r,e,n=1/0)=>{let o=[[t[0],t[1],t[2]],[r[0],r[1],r[2]],[e[0],e[1],e[2]]],i=ht(o);if(i===null)return null;let s=[t[3],r[3],e[3]];return M(i,s,n)},Nn=(t,r=1/0)=>{if(t.length<=0)return null;let e=ut(t),n=W(e);if(n===null)return null;let o=mt(t);return M(n,o,r)},An=(t,r)=>{let[e,n]=S(r,t),[o,i]=t;if(e===0)return{slope:void 0,xIntercept:o,yIntercept:void 0,formula:`x = ${o}`};let s=n/e,u=i-s*o,m="";return s===0?m=`y = ${u}`:(m=`y = ${s===1?"":s}x`,u!==0&&(m+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:s,xIntercept:void 0,yIntercept:u,formula:m}};var It=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=A([n,o,i],r);return B(f)?[f]:[]}let s=o-i,u=n*n-4*e*s;if(u<0)return[];if(u===0)return[c(-n/(2*e),r)];let m=2*e,x=Math.sqrt(u);return[c((-n+x)/m,r),c((-n-x)/m,r)]};var Ft=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},Ln=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},kt=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i)]},$n=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},Qt=(t,r,e,n,o=1/0)=>{let i=Vt(t,r,e,n);return T(i,o)},qn=(t,r,e,n,o=1/0)=>{let i=lt(t,r,e,n);return g(i,o)},Wt=(t,r,e,n,o,i=1/0)=>{let s=dt(t,r,e,n,o);return T(s,i)},Cn=(t,r,e,n,o,i=1/0)=>{let s=yt(t,r,e,n,o);return g(s,i)},Dn=(t,r,e,n,o=1/0)=>{let i=Qt(t,r,e,n,o);return[-i[1],i[0]]},Xn=(t,r,e,n,o,i=1/0)=>{let s=Wt(t,r,e,n,o,i);return[-s[1],s[0]]},Zt=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=A([o,i,0],n),m=2*t[1]-4*r[1]+2*e[1],x=-2*t[1]+2*r[1],p=A([m,x,0],n),a=[];return B(u)&&a.push(u),B(p)&&a.push(p),a},_t=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],s=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],m=[i,s,u,0],x=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[x,f,p,0],b=It(m,o).filter(y=>y>=0&&y<=1),v=It(a,o).filter(y=>y>=0&&y<=1);return[...b,...v].length===2?[...b,...v]:null},Yn=(t,r,e,n=1/0)=>{let o=Zt(t,r,e),i=1/0,s=1/0,u=-1/0,m=-1/0;for(let x of o){let f=Ft(x,t,r,e),p=f[0],a=f[1];i=Math.min(i,p),u=Math.max(u,p),s=Math.min(s,a),m=Math.max(m,a)}return i=c(Math.min(i,t[0],e[0]),n),u=c(Math.max(u,t[0],e[0]),n),s=c(Math.min(s,t[1],e[1]),n),m=c(Math.max(m,t[1],e[1]),n),{x:i,y:s,w:Math.abs(u-i),h:Math.abs(m-s),x2:u,y2:m}},jn=(t,r,e,n,o=1/0)=>{let i=_t(t,r,e,n)||[],s=1/0,u=1/0,m=-1/0,x=-1/0;for(let f of i){let p=kt(f,t,r,e,n),a=p[0],b=p[1];s=Math.min(s,a!=null?a:1/0),m=Math.max(m,a!=null?a:-1/0),u=Math.min(u,b!=null?b:1/0),x=Math.max(x,b!=null?b:-1/0)}return s=c(Math.min(s,t[0],n[0]),o),m=c(Math.max(m,t[0],n[0]),o),u=c(Math.min(u,t[1],n[1]),o),x=c(Math.max(x,t[1],n[1]),o),{x:s,y:u,w:Math.abs(m-s),h:Math.abs(x-u),x2:m,y2:x}};var Ut=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Gn=(t,r,e)=>{let n=S(t,r),o=H(n);return o=O(o,0,Math.PI*2,0,Math.PI),Ut(r,o,e)},Kt=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),On=(t,r,e)=>{let n=S(t,r),o=H(n);return o=O(o,0,Math.PI*2,0,Math.PI),Kt(r,o,e[0],e[1])},Fn=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},kn=(t,r,e,n,o,i,s)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-s)];var Qn=()=>{let t=wt();return Pt(t)},Wn=()=>{let t=wt();return tr(t)},wt=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Zn=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},_n=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Un=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Kn=()=>[0,0,V(0,100)],Jn=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let s=V(t,r),u=V(e,n),m=V(o,i);return[s,u,m]},Pn=t=>(t*=60,t<0&&(t+=360),t),to=(t,r,e,n=void 0,o=void 0)=>{if(n=n===void 0?Math.min(t,r,e):n,o=o===void 0?Math.max(t,r,e):o,n===o)return 0;let i=o-n,s=0;return o===t&&(s=(r-e)/i+(r(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,(n+o)/2*100),ro=(t,r,e,n=void 0,o=void 0,i=void 0)=>(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,n===o?0:(i=i===void 0?Jt(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),eo=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255,i=Math.min(e,n,o),s=Math.max(e,n,o),u=Jt(e,n,o,i,s),m=ro(e,n,o,i,s,u),x=to(e,n,o,i,s);return x>360||m>100||u>100?[0,0,100]:x<0||m<0||u<0?[0,0,0]:[c(x,r),c(m,r),c(u,r)]},gt=(t,r,e)=>(e<0&&(e+=1),e>1&&(e-=1),e*6<1?r+(t-r)*6*e:e*2<1?t:e*3<2?r+(t-r)*(.666-e)*6:r),Pt=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let b=o*255;return[b,b,b]}let i=o<.5?o*(1+n):o+n-o*n,s=2*o-i,u=e+.333,m=e,x=e-.333,f=gt(i,s,u),p=gt(i,s,m),a=gt(i,s,x);return f*=255,p*=255,a*=255,f>255||p>255||a>255?[255,255,255]:f<0||p<0||a<0?[0,0,0]:[c(f,r),c(p,r),c(a,r)]},tr=t=>{if(t[0]>360||t[1]>100||t[2]>100)return"#ffffff";if(t[0]<0||t[1]<0||t[2]<0)return"#000000";let r=t[0]/360,e=t[1]/100,n=t[2]/100,o,i,s;if(e===0)o=i=s=n;else{let m=(p,a,b)=>(b<0&&(b+=1),b>1&&(b-=1),b<.16666666666666666?p+(a-p)*6*b:b<.5?a:b<.6666666666666666?p+(a-p)*(.6666666666666666-b)*6:p),x=n<.5?n*(1+e):n+e-n*e,f=2*n-x;o=m(f,x,r+1/3),i=m(f,x,r),s=m(f,x,r-1/3)}let u=m=>{let x=Math.round(m*255).toString(16);return x.length===1?"0"+x:x};return`#${u(o)}${u(i)}${u(s)}`},no=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},oo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,m,x,f)=>m+m+x+x+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),s=parseInt(n[3],16);return[o,i,s]},vt=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;let i=(e*.4124+n*.3576+o*.1805)/.95047,s=(e*.2126+n*.7152+o*.0722)/1,u=(e*.0193+n*.1192+o*.9505)/1.08883;return i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,[c(116*s-16,r),c(500*(i-s),r),c(200*(s-u),r)]},io=(t,r=1/0)=>{let e=(t[0]+16)/116,n=t[1]/500+e,o=e-t[2]/200;n=.95047*(n*n*n>.008856?n*n*n:(n-16/116)/7.787),e=1*(e*e*e>.008856?e*e*e:(e-16/116)/7.787),o=1.08883*(o*o*o>.008856?o*o*o:(o-16/116)/7.787);let i=n*3.2406+e*-1.5372+o*-.4986,s=n*-.9689+e*1.8758+o*.0415,u=n*.0557+e*-.204+o*1.057;return i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:12.92*u,[c(Math.max(0,Math.min(1,i))*255,r),c(Math.max(0,Math.min(1,s))*255,r),c(Math.max(0,Math.min(1,u))*255,r)]},so=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=l(e,360)),[e,t[1],t[2]]},co=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=l(e,100)),[t[0],t[1],e]},uo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},mo=(t,r,e=1/0)=>{let n=vt(t,e),o=vt(r,e),i=n[0]-o[0],s=n[1]-o[1],u=n[2]-o[2],m=Math.sqrt(n[1]*n[1]+n[2]*n[2]),x=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=m-x,p=s*s+u*u-f*f;p=p<0?0:Math.sqrt(p);let a=1+.045*m,b=1+.015*m,v=i/1,L=f/a,y=p/b,G=v*v+L*L+y*y;return G<0?0:Math.sqrt(G)};var xo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),ao=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var fo=(t,r)=>t.x<=r.x+r.w&&t.x+t.w>=r.x&&t.y<=r.y+r.h&&t.h+t.y>=r.y,po=(t,r)=>{let e=Math.abs(t.cx-r.cx),n=Math.abs(t.cy-r.cy);return Math.sqrt(e*e+n*n)<=t.r+r.r},rr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...rr(t)),e.push(...rr(r));for(let n of e){let o=rt(n[0],n[1]),i=er(t,o),s=er(r,o);if(!(i.max>=s.min&&s.max>=i.min))return!1}return!0},er=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=J(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var ho=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,s=!1,u,m=()=>{e=void 0,o=void 0,i=void 0,s=!1,n!==void 0&&window.cancelAnimationFrame(n)},x=()=>{m(),v()},f=()=>{s=!1},p=()=>{s=!0},a=z=>{e===void 0&&(e=z),o=z-e,s&&i!==z&&typeof t.callback=="function"&&t.callback(Et()),o<=r?(i=z,n=window.requestAnimationFrame(a)):m()},b=(z,mr)=>{x(),typeof t.resizeCallback=="function"&&t.resizeCallback(z,mr)},v=()=>{e=void 0,o=void 0,i=void 0,s=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(b),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(a)},L=()=>o,y=()=>s,G=()=>e,cr=()=>{if(!(r===1/0||o===void 0))return o*100/r},ur=()=>u,Et=()=>({start:v,stop:m,pause:f,resume:p,restart:x,isAnimating:y,getElapsedTime:L,getStartTime:G,getPercent:cr,getResizeObserver:ur});return Et()};var Mo=(t,r=1/0)=>c(2*Math.PI*t,r),Vo=(t,r,e=1/0)=>c(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),lo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),yo=(t,r=1/0)=>c(t*2/Math.sqrt(2),r);var Io=t=>t*(t+1)/2,go=(t,r,e)=>t/2*(2*r+(t-1)*e);var j=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return c(e/t.length,r)},vo=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return c(e,r)},wo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=[...t].sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?c((e[n]+e[n-1])/2,r):c(e[n],r)},So=t=>{if(!t||t.length<=0)return;let r=new Map;for(let o of t)r.set(o,(r.get(o)||0)+1);let e=0,n=[];for(let[o,i]of r)i>e?(e=i,n=[o]):i===e&&n.push(o);if(n.length!==t.length)return n.length===1?[n[0]]:n},Ro=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return c(n/t.length,r)},nr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i,2),0);return c(n/t.length-h(e,2),r)},St=(t,r=1/0)=>{var n;let e=(n=nr(t))!=null?n:0;return c(Math.sqrt(e),r)};var or=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:c((t-r)/o,n)},Rt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Rt(t,e,n,r);return{min:c(e,r),max:c(n,r),data:o}},Bo=(t,r,e,n=1/0)=>Rt(t,r,e,n),ir=(t,r,e,n=1/0)=>e===0?0:c((t-r)/e,n),zt=(t,r,e,n=1/0)=>[...t].map(o=>ir(o,r,e,n)),Eo=(t,r=1/0)=>{var i;let e=(i=j(t))!=null?i:0,n=St(t),o=zt(t,e,n,r);return{mean:c(e,r),stdDev:c(n,r),data:o}},Ho=(t,r,e,n=1/0)=>zt(t,r,e,n);var To=t=>t/2*(t+1),No=(t,r)=>(r-t+1)*(t+r)/2;var Ao=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=1;for(let n=r;n<=t;n++)e*=n;return e},sr=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}return t===r?r:t*sr(t-1,r)},Lo=(t,r=0)=>{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===0){if(t===0)return 1;r=1}let e=new Map,n=(o,i)=>{var u;if(o{if(t<0)throw new Error("Factorial is not defined for negative numbers.");if(r>t)throw new Error("Start cannot be greater than n.");if(r<0)throw new Error("Start must be non-negative.");if(r===t)return t===0?1:t;r===0&&(r=1);let e=[];e[0]=1;for(let n=1;n<=t;n++)e[n]=e[n-1]*n;return e[t]/e[r-1]};var $o=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return h(t,r)},qo=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");return Bt(t,t-r+1)},Co=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");let e=Array.from({length:t+1},()=>Array(r+1).fill(0));for(let n=0;n<=t;n++)e[n][0]=1,n<=r&&(e[n][n]=1);for(let n=1;n<=t;n++)for(let o=1;o<=Math.min(n,r);o++)e[n][o]=e[n-1][o-1]+e[n-1][o];return e[t][r]},Do=(t,r)=>{if(t<0||r<0)throw new Error("Both n and r should be non-negative integers.");if(!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Both n and r should be integers.");if(t===0)return 1;let e=r+t-1,n=r,o=Array.from({length:e+1},()=>Array(n+1).fill(0));for(let i=0;i<=e;i++)o[i][0]=1;for(let i=1;i<=e;i++)for(let s=1;s<=Math.min(i,n);s++)o[i][s]=o[i-1][s]+o[i-1][s-1];return o[e][n]};0&&(module.exports={animate,arithmeticSequenceSum,circleCollide,circleMovement,circleMovementAfterMouse,combinationsWithRepetition,combinationsWithoutRepetition,convertRange,convexPolygonsCollide,degreesToRadians,doRangesOverlap,dxArcCos,dxArcCot,dxArcSin,dxArcTan,dxCos,dxCot,dxPolynomial,dxSin,dxTan,dxV2CubicBezierCurve,dxV2QuadraticBezierCurve,dxV3CubicBezierCurve,dxV3QuadraticBezierCurve,ellipseMovement,ellipseMovementAfterMouse,factorial,factorialIterative,factorialMemoized,factorialRecursive,getAnglesDistance,getAnglesSub,getArithmeticMean,getArithmeticMeanFromFrequency,getCircleCircumference,getColorsDelta,getEllipseCircumference,getLinearEquationBy2Points,getMedian,getMode,getRandom,getRandomBoolean,getRandomGrayscaleHSLColor,getRandomHSLColor,getRandomHSLColorWithHue,getRandomHSLColorWithLightness,getRandomHSLColorWithSaturation,getRandomHSLColorWithinRanges,getRandomHexColor,getRandomInt,getRandomItemFromArray,getRandomRGBColor,getShiftedHue,getShiftedLightness,getShiftedSaturation,getSquareInCircleSide,getStandardDeviation,getV2Angle,getV2AngleBetween,getV2AngleInEllipse,getV3AngleBetween,getVNAngleBetween,getVariance,getVariance1,guid,hexToRgb,hslToHex,hslToRgb,identity2,identity3,identity4,identityN,isAngleBetween,isAngleInCircleArc,isClockwise,isNumber,isSingularMatrix,labToRgb,linearEquation,linearEquationSystem2,linearEquationSystem3,linearEquationSystemN,lissajousCurve,m2Adjugate,m2AppendRow,m2DeepCopy,m2Determinant,m2DivideScalar,m2Inverse,m2MulScalar,m2PrependRow,m2ReflectionOrigin,m2ReflectionOriginH,m2ReflectionX,m2ReflectionXH,m2ReflectionY,m2ReflectionYH,m2ReflectionYmX,m2Reset,m2RotateAroundPointH,m2Rotation,m2RotationAroundPointH,m2RotationH,m2Scale,m2ScaleAtPointH,m2ScaleAtPointHMatrix,m2ScaleH,m2ScaleX,m2ScaleXH,m2ScaleY,m2ScaleYH,m2ShearingX,m2ShearingY,m2Sub,m2Sum,m2ToCSS,m2Translation,m2TranslationH,m2Transpose,m2hToCSS,m2hToCSS3d,m2x2,m3Adjugate,m3AppendRow,m3DeepCopy,m3Determinant,m3DivideScalar,m3Inverse,m3MulScalar,m3PrependRow,m3ReflectionOrigin,m3ReflectionOriginH,m3ReflectionXY,m3ReflectionXYH,m3ReflectionXZ,m3ReflectionXZH,m3ReflectionYZ,m3ReflectionYZH,m3Reset,m3RotationX,m3RotationXH,m3RotationY,m3RotationYH,m3RotationZ,m3RotationZH,m3Scale,m3ScaleH,m3ScaleX,m3ScaleXH,m3ScaleY,m3ScaleYH,m3ScaleZ,m3ScaleZH,m3Sub,m3Sum,m3Translation,m3TranslationH,m3Transpose,m3hToCSS3d,m3x3,m4x4,mAdjugate,mAppendCol,mAppendRow,mDeepCopy,mDelFirstColumn,mDelFirstRow,mDelLastColumn,mDelLastRow,mDeterminant,mDivideScalar,mEqual,mGetColumn,mGetFirstColumn,mGetLastColumn,mInverse,mMinor,mMul,mMulScalar,mMulVector,mNxM,mPrependCol,mPrependRow,mReset,mSub,mSum,mTranspose,mlNormalizeArray,mlNormalizeTestData,mlNormalizeUnseenData,mlNormalizeValue,mlStandardizeArray,mlStandardizeTestData,mlStandardizeUnseenData,mlStandardizeValue,mod,naturalNumbersSequenceSum,naturalNumbersSum1ToN,naturalNumbersSumMToN,newId,percentToAngle,permutationsWithRepetition,permutationsWithoutRepetition,polarToCartesian,radiansToDegrees,rectCollide,rgbToHex,rgbToHsl,rgbToLab,setDecimalPlaces,setV2Angle,sineWaveMovement,stringToNumber,v2,v2CubicBezierBBox,v2CubicBezierCurve,v2CubicBezierCurveExtrema,v2CubicBezierCurveNormal,v2CubicBezierCurveTangent,v2Distance,v2DivideScalar,v2DotProduct,v2FromPolarCoords,v2GetNormal,v2Length,v2MulScalar,v2Normalize,v2QuadraticBezierBBox,v2QuadraticBezierCurve,v2QuadraticBezierCurveExtrema,v2QuadraticBezierCurveNormal,v2QuadraticBezierCurveTangent,v2Rotate,v2RotateH,v2Scale,v2SetLength,v2Sub,v2Sum,v3,v3CrossProduct,v3CubicBezierCurve,v3CubicBezierCurveTangent,v3Distance,v3DivideScalar,v3DotProduct,v3Length,v3MulScalar,v3Normalize,v3QuadraticBezierCurve,v3QuadraticBezierCurveTangent,v3RotateX,v3RotateY,v3RotateZ,v3Scale,v3Sub,v3Sum,v4,vDistance,vDivideScalar,vDotProduct,vEqual,vLength,vMulScalar,vN,vNormalize,vSub,vSum}); //# sourceMappingURL=mz-math.node.cjs.map diff --git a/dist/mz-math.node.cjs.map b/dist/mz-math.node.cjs.map index 223409b..c0a4ecd 100644 --- a/dist/mz-math.node.cjs.map +++ b/dist/mz-math.node.cjs.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/index-esm.ts", "../src/main/format.ts", "../src/main/other.ts", "../src/main/angle.ts", "../src/main/linear-algebra/vector.ts", "../src/main/linear-algebra/matrix.ts", "../src/main/linear-algebra/matrix-transformations.ts", "../src/main/random.ts", "../src/main/convert.ts", "../src/main/derivative.ts", "../src/main/equations/linear-equations.ts", "../src/main/equations/quadratic-equations.ts", "../src/main/bezier-curves/bezier-curve.ts", "../src/main/path-movement.ts", "../src/main/color.ts", "../src/main/id.ts", "../src/main/collision-detection.ts", "../src/main/animation.ts", "../src/main/circle-ellipse.ts", "../src/main/sequence.ts", "../src/main/statistics.ts", "../src/main/ml.ts", "../src/main/series.ts", "../src/main/combinatorics/factorial.ts", "../src/main/combinatorics/combinatorics.ts"], - "sourcesContent": ["export * from './main/linear-algebra/vector';\nexport * from './main/linear-algebra/matrix';\nexport * from './main/linear-algebra/matrix-transformations';\nexport * from './main/format';\nexport * from './main/angle';\nexport * from './main/random';\nexport * from './main/other';\nexport * from './main/convert';\nexport * from './main/bezier-curves/bezier-curve';\nexport * from './main/equations/linear-equations';\nexport * from './main/path-movement';\nexport * from './main/color';\nexport * from './main/physics';\nexport * from './main/id';\nexport * from './main/derivative';\nexport * from './main/collision-detection';\nexport * from './main/animation';\nexport * from './main/circle-ellipse';\nexport * from './main/sequence';\nexport * from './main/statistics';\nexport * from './main/ml';\nexport * from './main/series';\nexport * from './main/combinatorics/factorial';\nexport * from './main/combinatorics/combinatorics';", "export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};", "/**\n * The simplest and straightforward method\n * but can become inefficient for extremely large numbers\n * due to growing computational time.\n */\nexport const factorialIterative = (n: number, start = 0): number => {\n\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n let result = 1;\n for (let i = start; i <= n; i++) {\n result *= i;\n }\n return result;\n};\n\n/**\n * A recursive approach is a classic method for calculating factorials\n * but can lead to stack overflow errors\n * for very large inputs because of deep recursion.\n * However, it's a direct translation\n * of the mathematical definition of factorial.\n */\nexport const factorialRecursive = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n // Base case: when n reaches start, return start instead of further reducing\n if (n === start) return start;\n\n // Recursive call\n return n * factorialRecursive(n - 1, start);\n};\n\n/**\n * Memoization (Top-Down Dynamic Programming).\n */\nexport const factorialMemoized = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n const memo = new Map();\n\n const traverse = (num: number, end: number): number => {\n if (num < end) return 1; // Adjust the base case to return 1 if we're below 'end'\n // if (num === 0) return 1;\n\n if (memo.has(num)) return memo.get(num) ?? 1;\n\n if (num === end) {\n memo.set(num, num);\n return num;\n }\n\n const result = num * traverse(num - 1, end);\n\n memo.set(num, result);\n\n return result;\n };\n\n return traverse(n, start);\n};\n\n/**\n * Tabulation (Bottom-Up Dynamic Programming).\n */\nexport const factorial = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === n) {\n return n === 0 ? 1 : n; // If start == n and n == 0, return 1 (0!), otherwise return n\n }\n\n if (start === 0) {\n start = 1;\n }\n\n const table = []; // new Array(n + 1);\n table[0] = 1;\n for (let i = 1; i <= n; i++) {\n table[i] = table[i - 1] * i;\n }\n return table[n] / table[start - 1];\n};", "import { factorial } from './factorial';\n\n/**\n * Permutations with repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - repetition is allowed\n *\n * Formula:\n * --------\n * n^r\n *\n * Intuition:\n * ----------\n * In other words, there are n possibilities for the first choice,\n * THEN there are n possibilities for the second choice, and so on,\n * multiplying each time.\n *\n * A Permutation is an ordered Combination.\n *\n * Example:\n * --------\n * Such as a lock that could be \"333\".\n */\nexport const permutationsWithRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return n ** r;\n};\n\n/**\n * Permutations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - no repetitions\n *\n * Formula:\n * --------\n * P(n,r) = n! / (n \u2212 r)!\n *\n * Intuition:\n * ----------\n * In this case, we have to reduce the number of available choices each time.\n * After choosing, say, number \"14\" we can't choose it again.\n * So, our first choice has 16 possibilities, and our next choice has 15 possibilities,\n * then 14, 13, 12, 11, ... etc.\n *\n * A Permutation is an ordered Combination.\n */\nexport const permutationsWithoutRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return factorial(n, n - r + 1);\n};\n\n/**\n * Order doesn't matter.\n *\n * Example:\n * --------\n * Coins in your pocket (5, 5, 5, 10, 10).\n\nexport const combinationsWithRepetition = () => {\n\n};\n */\n\n/**\n * Combinations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - no repetitions\n *\n * And is also known as the Binomial Coefficient.\n *\n * Formula:\n * --------\n * C(n, r) = C(n, n - r) = n! / (r! * (n\u2212r)!)\n *\n * Example:\n * --------\n * Such as lottery numbers (2, 14, 15, 27, 30, 33).\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42(n \u00D7 r)\n * Space Complexity: \uD835\uDC42(n \u00D7 r)\n */\nexport const combinationsWithoutRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n // Initialize a two-dimensional array (or matrix) [n + 1, r + 1].\n // The reason for n + 1 is to ensure that we can access indices directly equal to the value of n\n // without running out of bounds, as array indices start at 0.\n const dp = Array.from({ length: n + 1 }, () => Array(r + 1).fill(0));\n /*\n const dp: number[][] = [];\n for(let i=0; i<=n; i++) {\n dp[i] = [];\n for(let j=0; j<=r; j++) {\n dp[i][j] = 0;\n }\n }*/\n\n // Base cases: C(n, 0) = 1 and C(n, n) = 1 for any n.\n for (let i = 0; i <= n; i++) {\n dp[i][0] = 1;\n if (i <= r) {\n // Only fill this if i <= r to avoid filling non-existent cells\n dp[i][i] = 1;\n }\n }\n\n // Fill the table using the relation C(n, r) = C(n-1, r-1) + C(n-1, r)\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, r); j++) { // Only compute up to the minimum of i and r\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n }\n }\n\n return dp[n][r];\n};\n\n"], - "mappings": ";;;;;;;qbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,GAAA,0BAAAC,GAAA,kBAAAC,GAAA,mBAAAC,GAAA,6BAAAC,GAAA,kCAAAC,GAAA,iBAAAC,EAAA,0BAAAC,GAAA,qBAAAC,GAAA,oBAAAC,GAAA,aAAAC,GAAA,aAAAC,GAAA,aAAAC,GAAA,aAAAC,GAAA,UAAAC,GAAA,UAAAC,GAAA,iBAAAC,GAAA,UAAAC,GAAA,UAAAC,GAAA,yBAAAC,GAAA,6BAAAC,GAAA,yBAAAC,GAAA,6BAAAC,GAAA,oBAAAC,GAAA,8BAAAC,GAAA,cAAAC,GAAA,uBAAAC,GAAA,sBAAAC,GAAA,uBAAAC,GAAA,sBAAAC,GAAA,iBAAAC,EAAA,sBAAAC,EAAA,mCAAAC,GAAA,2BAAAC,GAAA,mBAAAC,GAAA,4BAAAC,GAAA,+BAAAC,GAAA,cAAAC,GAAA,YAAAC,GAAA,cAAAC,EAAA,qBAAAC,GAAA,+BAAAC,GAAA,sBAAAC,GAAA,6BAAAC,GAAA,mCAAAC,GAAA,oCAAAC,GAAA,kCAAAC,GAAA,sBAAAC,GAAA,iBAAAC,GAAA,2BAAAC,GAAA,sBAAAC,GAAA,kBAAAC,GAAA,wBAAAC,GAAA,yBAAAC,GAAA,0BAAAC,GAAA,yBAAAC,GAAA,eAAAC,EAAA,sBAAAC,GAAA,wBAAAC,GAAA,sBAAAC,GAAA,sBAAAC,GAAA,gBAAAC,GAAA,iBAAAC,GAAA,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AASC,EAAI,EAAGA,GAAK,KAAK,IAAID,EAAG,CAAC,EAAGC,IACjCF,EAAGC,GAAGC,GAAKF,EAAGC,EAAE,GAAGC,EAAE,GAAKF,EAAGC,EAAE,GAAGC,GAI1C,OAAOF,EAAGL,GAAG,EACjB", - "names": ["index_esm_exports", "__export", "animate", "arithmeticSequenceSum", "circleCollide", "circleMovement", "circleMovementAfterMouse", "combinationsWithoutRepetition", "convertRange", "convexPolygonsCollide", "degreesToRadians", "doRangesOverlap", "dxArcCos", "dxArcCot", "dxArcSin", "dxArcTan", "dxCos", "dxCot", "dxPolynomial", "dxSin", "dxTan", "dxV2CubicBezierCurve", "dxV2QuadraticBezierCurve", "dxV3CubicBezierCurve", "dxV3QuadraticBezierCurve", "ellipseMovement", "ellipseMovementAfterMouse", "factorial", "factorialIterative", "factorialMemoized", "factorialRecursive", "getAnglesDistance", "getAnglesSub", "getArithmeticMean", "getArithmeticMeanFromFrequency", "getCircleCircumference", "getColorsDelta", "getEllipseCircumference", "getLinearEquationBy2Points", "getMedian", "getMode", "getRandom", "getRandomBoolean", "getRandomGrayscaleHSLColor", "getRandomHSLColor", "getRandomHSLColorWithHue", "getRandomHSLColorWithLightness", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithinRanges", "getRandomHexColor", "getRandomInt", "getRandomItemFromArray", "getRandomRGBColor", "getShiftedHue", "getShiftedLightness", "getShiftedSaturation", "getSquareInCircleSide", "getStandardDeviation", "getV2Angle", "getV2AngleBetween", "getV2AngleInEllipse", "getV3AngleBetween", "getVNAngleBetween", "getVariance", "getVariance1", "guid", "hexToRgb", "hslToHex", "hslToRgb", "identity2", "identity3", "identity4", "identityN", "isAngleBetween", "isAngleInCircleArc", "isClockwise", "isNumber", "isSingularMatrix", "labToRgb", "linearEquation", "linearEquationSystem2", "linearEquationSystem3", "linearEquationSystemN", "lissajousCurve", "m2Adjugate", "m2AppendRow", "m2DeepCopy", "m2Determinant", "m2DivideScalar", "m2Inverse", "m2MulScalar", "m2PrependRow", "m2ReflectionOrigin", "m2ReflectionOriginH", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m2ReflectionYmX", "m2Reset", "m2RotateAroundPointH", "m2Rotation", "m2RotationAroundPointH", "m2RotationH", "m2Scale", "m2ScaleAtPointH", "m2ScaleAtPointHMatrix", "m2ScaleH", "m2ScaleX", "m2ScaleXH", "m2ScaleY", "m2ScaleYH", "m2ShearingX", "m2ShearingY", "m2Sub", "m2Sum", "m2ToCSS", "m2Translation", "m2TranslationH", "m2Transpose", "m2hToCSS", "m2hToCSS3d", "m2x2", "m3Adjugate", "m3AppendRow", "m3DeepCopy", "m3Determinant", "m3DivideScalar", "m3Inverse", "m3MulScalar", "m3PrependRow", "m3ReflectionOrigin", "m3ReflectionOriginH", "m3ReflectionXY", "m3ReflectionXYH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionYZ", "m3ReflectionYZH", "m3Reset", "m3RotationX", "m3RotationXH", "m3RotationY", "m3RotationYH", "m3RotationZ", "m3RotationZH", "m3Scale", "m3ScaleH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m3Sub", "m3Sum", "m3Translation", "m3TranslationH", "m3Transpose", "m3hToCSS3d", "m3x3", "m4x4", "mAdjugate", "mAppendCol", "mAppendRow", "mDeepCopy", "mDelFirstColumn", "mDelFirstRow", "mDelLastColumn", "mDelLastRow", "mDeterminant", "mDivideScalar", "mEqual", "mGetColumn", "mGetFirstColumn", "mGetLastColumn", "mInverse", "mMinor", "mMul", "mMulScalar", "mMulVector", "mNxM", "mPrependCol", "mPrependRow", "mReset", "mSub", "mSum", "mTranspose", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mod", "naturalNumbersSequenceSum", "naturalNumbersSum1ToN", "naturalNumbersSumMToN", "newId", "percentToAngle", "permutationsWithRepetition", "permutationsWithoutRepetition", "polarToCartesian", "radiansToDegrees", "rectCollide", "rgbToHex", "rgbToHsl", "rgbToLab", "setDecimalPlaces", "setV2Angle", "sineWaveMovement", "stringToNumber", "v2", "v2CubicBezierBBox", "v2CubicBezierCurve", "v2CubicBezierCurveExtrema", "v2CubicBezierCurveNormal", "v2CubicBezierCurveTangent", "v2Distance", "v2DivideScalar", "v2DotProduct", "v2FromPolarCoords", "v2GetNormal", "v2Length", "v2MulScalar", "v2Normalize", "v2QuadraticBezierBBox", "v2QuadraticBezierCurve", "v2QuadraticBezierCurveExtrema", "v2QuadraticBezierCurveNormal", "v2QuadraticBezierCurveTangent", "v2Rotate", "v2RotateH", "v2Scale", "v2SetLength", "v2Sub", "v2Sum", "v3", "v3CrossProduct", "v3CubicBezierCurve", "v3CubicBezierCurveTangent", "v3Distance", "v3DivideScalar", "v3DotProduct", "v3Length", "v3MulScalar", "v3Normalize", "v3QuadraticBezierCurve", "v3QuadraticBezierCurveTangent", "v3RotateX", "v3RotateY", "v3RotateZ", "v3Scale", "v3Sub", "v3Sum", "v4", "vDistance", "vDivideScalar", "vDotProduct", "vEqual", "vLength", "vMulScalar", "vN", "vNormalize", "vSub", "vSum", "__toCommonJS", "setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "stringToNumber", "value", "defaultNumber", "_a", "res", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "x", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "guid", "c", "newId", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "naturalNumbersSequenceSum", "n", "arithmeticSequenceSum", "a", "d", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "naturalNumbersSum1ToN", "n", "naturalNumbersSumMToN", "m", "factorialIterative", "n", "start", "result", "i", "factorialRecursive", "factorialMemoized", "memo", "traverse", "num", "end", "_a", "factorial", "table", "permutationsWithRepetition", "n", "__pow", "permutationsWithoutRepetition", "factorial", "combinationsWithoutRepetition", "dp", "i", "j"] + "sourcesContent": ["export * from './main/linear-algebra/vector';\nexport * from './main/linear-algebra/matrix';\nexport * from './main/linear-algebra/matrix-transformations';\nexport * from './main/format';\nexport * from './main/angle';\nexport * from './main/random';\nexport * from './main/other';\nexport * from './main/convert';\nexport * from './main/bezier-curves/bezier-curve';\nexport * from './main/equations/linear-equations';\nexport * from './main/path-movement';\nexport * from './main/color';\nexport * from './main/physics';\nexport * from './main/id';\nexport * from './main/derivative';\nexport * from './main/collision-detection';\nexport * from './main/animation';\nexport * from './main/circle-ellipse';\nexport * from './main/sequence';\nexport * from './main/statistics';\nexport * from './main/ml';\nexport * from './main/series';\nexport * from './main/combinatorics/factorial';\nexport * from './main/combinatorics/combinatorics';", "export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};", "/**\n * The simplest and straightforward method\n * but can become inefficient for extremely large numbers\n * due to growing computational time.\n */\nexport const factorialIterative = (n: number, start = 0): number => {\n\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n let result = 1;\n for (let i = start; i <= n; i++) {\n result *= i;\n }\n return result;\n};\n\n/**\n * A recursive approach is a classic method for calculating factorials\n * but can lead to stack overflow errors\n * for very large inputs because of deep recursion.\n * However, it's a direct translation\n * of the mathematical definition of factorial.\n */\nexport const factorialRecursive = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n // Base case: when n reaches start, return start instead of further reducing\n if (n === start) return start;\n\n // Recursive call\n return n * factorialRecursive(n - 1, start);\n};\n\n/**\n * Memoization (Top-Down Dynamic Programming).\n */\nexport const factorialMemoized = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === 0) {\n if (n === 0) {\n return 1; // 0! is defined as 1\n }\n else {\n start = 1; // Adjust start to 1 to prevent multiplication by zero\n }\n }\n\n const memo = new Map();\n\n const traverse = (num: number, end: number): number => {\n if (num < end) return 1; // Adjust the base case to return 1 if we're below 'end'\n // if (num === 0) return 1;\n\n if (memo.has(num)) return memo.get(num) ?? 1;\n\n if (num === end) {\n memo.set(num, num);\n return num;\n }\n\n const result = num * traverse(num - 1, end);\n\n memo.set(num, result);\n\n return result;\n };\n\n return traverse(n, start);\n};\n\n/**\n * Tabulation (Bottom-Up Dynamic Programming).\n */\nexport const factorial = (n: number, start = 0): number => {\n if (n < 0) {\n throw new Error('Factorial is not defined for negative numbers.');\n }\n\n if (start > n) {\n throw new Error('Start cannot be greater than n.');\n }\n\n if (start < 0) {\n throw new Error('Start must be non-negative.');\n }\n\n if (start === n) {\n return n === 0 ? 1 : n; // If start == n and n == 0, return 1 (0!), otherwise return n\n }\n\n if (start === 0) {\n start = 1;\n }\n\n const table = []; // new Array(n + 1);\n table[0] = 1;\n for (let i = 1; i <= n; i++) {\n table[i] = table[i - 1] * i;\n }\n return table[n] / table[start - 1];\n};", "import { factorial } from './factorial';\n\n/**\n * Permutations with repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - repetition is allowed\n *\n * Formula:\n * --------\n * n^r\n *\n * Intuition:\n * ----------\n * In other words, there are n possibilities for the first choice,\n * THEN there are n possibilities for the second choice, and so on,\n * multiplying each time.\n *\n * A Permutation is an ordered Combination.\n *\n * Example:\n * --------\n * Such as a lock that could be \"333\".\n */\nexport const permutationsWithRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return n ** r;\n};\n\n/**\n * Permutations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order matters\n * - no repetitions\n *\n * Formula:\n * --------\n * P(n,r) = n! / (n \u2212 r)!\n *\n * Intuition:\n * ----------\n * In this case, we have to reduce the number of available choices each time.\n * After choosing, say, number \"14\" we can't choose it again.\n * So, our first choice has 16 possibilities, and our next choice has 15 possibilities,\n * then 14, 13, 12, 11, ... etc.\n *\n * A Permutation is an ordered Combination.\n */\nexport const permutationsWithoutRepetition = (n: number, r: number) => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n return factorial(n, n - r + 1);\n};\n\n/**\n * Combinations without repetitions:\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - no repetitions\n *\n * And is also known as the Binomial Coefficient.\n * We can also use Pascal's Triangle to find the values.\n *\n * Formula:\n * --------\n * C(n, r) = C(n, n - r) = n! / (r! * (n\u2212r)!)\n *\n * Example:\n * --------\n * Such as lottery numbers (2, 14, 15, 27, 30, 33).\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42(n \u00D7 r)\n * Space Complexity: \uD835\uDC42(n \u00D7 r)\n */\nexport const combinationsWithoutRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n // Initialize a two-dimensional array (or matrix) [n + 1, r + 1].\n // The reason for n + 1 is to ensure that we can access indices directly equal to the value of n\n // without running out of bounds, as array indices start at 0.\n const dp = Array.from({ length: n + 1 }, () => Array(r + 1).fill(0));\n /*\n const dp: number[][] = [];\n for(let i=0; i<=n; i++) {\n dp[i] = [];\n for(let j=0; j<=r; j++) {\n dp[i][j] = 0;\n }\n }*/\n\n // Base cases: C(n, 0) = 1 and C(n, n) = 1 for any n.\n for (let i = 0; i <= n; i++) {\n dp[i][0] = 1;\n if (i <= r) {\n // Only fill this if i <= r to avoid filling non-existent cells\n dp[i][i] = 1;\n }\n }\n\n // Fill the table using the relation C(n, r) = C(n-1, r-1) + C(n-1, r)\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, r); j++) { // Only compute up to the minimum of i and r\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n }\n }\n\n return dp[n][r];\n};\n\n/**\n * Combinations with repetitions (multi-choose):\n * - \"n\" is the number of things to choose from\n * - we choose \"r\" of them\n * - order doesn't matter\n * - repetition is allowed\n *\n * Formula:\n * --------\n * (r + n \u2212 1)! / r!(n \u2212 1)! = C(r + n \u2212 1, r) = C(r + n \u2212 1, n \u2212 1)\n *\n * Example:\n * --------\n * - Coins in your pocket (5, 5, 5, 10, 10).\n * - Let us say there are five flavors of ice cream: banana, chocolate, lemon, strawberry and vanilla.\u00E5\n * We can have three scoops. How many variations will there be?\n *\n * Tabulation (Bottom-Up Dynamic Programming).\n * Time Complexity: \uD835\uDC42((r + n) \u00D7 r)\n * Space Complexity: \uD835\uDC42((r + n) \u00D7 r)\n */\nexport const combinationsWithRepetition = (n: number, r: number) : number => {\n if (n < 0 || r < 0) {\n throw new Error('Both n and r should be non-negative integers.');\n }\n if (!Number.isInteger(n) || !Number.isInteger(r)) {\n throw new Error('Both n and r should be integers.');\n }\n\n if(n === 0) return 1;\n\n // Calculate adjusted values for indices in the DP table\n const totalItems = r + n - 1;\n const chooseItems = r;\n\n // Initialize DP table\n const dp: number[][] = Array.from({ length: totalItems + 1 }, () => Array(chooseItems + 1).fill(0));\n\n // Base case initialization: C(i, 0) = 1 for all i, because there's one way to choose nothing\n for (let i = 0; i <= totalItems; i++) {\n dp[i][0] = 1;\n }\n\n for (let i = 1; i <= totalItems; i++) {\n for (let j = 1; j <= Math.min(i, chooseItems); j++) {\n dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];\n }\n }\n\n return dp[totalItems][chooseItems];\n};\n\n"], + "mappings": ";;;;;;;qbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,GAAA,0BAAAC,GAAA,kBAAAC,GAAA,mBAAAC,GAAA,6BAAAC,GAAA,+BAAAC,GAAA,kCAAAC,GAAA,iBAAAC,EAAA,0BAAAC,GAAA,qBAAAC,GAAA,oBAAAC,GAAA,aAAAC,GAAA,aAAAC,GAAA,aAAAC,GAAA,aAAAC,GAAA,UAAAC,GAAA,UAAAC,GAAA,iBAAAC,GAAA,UAAAC,GAAA,UAAAC,GAAA,yBAAAC,GAAA,6BAAAC,GAAA,yBAAAC,GAAA,6BAAAC,GAAA,oBAAAC,GAAA,8BAAAC,GAAA,cAAAC,GAAA,uBAAAC,GAAA,sBAAAC,GAAA,uBAAAC,GAAA,sBAAAC,GAAA,iBAAAC,EAAA,sBAAAC,EAAA,mCAAAC,GAAA,2BAAAC,GAAA,mBAAAC,GAAA,4BAAAC,GAAA,+BAAAC,GAAA,cAAAC,GAAA,YAAAC,GAAA,cAAAC,EAAA,qBAAAC,GAAA,+BAAAC,GAAA,sBAAAC,GAAA,6BAAAC,GAAA,mCAAAC,GAAA,oCAAAC,GAAA,kCAAAC,GAAA,sBAAAC,GAAA,iBAAAC,GAAA,2BAAAC,GAAA,sBAAAC,GAAA,kBAAAC,GAAA,wBAAAC,GAAA,yBAAAC,GAAA,0BAAAC,GAAA,yBAAAC,GA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GC,GAAG,GAAK,EACPA,GAAK,IAELD,EAAGC,GAAGA,GAAK,GAKnB,QAASA,EAAI,EAAGA,GAAKN,EAAGM,IACpB,QAASC,EAAI,EAAGA,GAAK,KAAK,IAAID,EAAG,CAAC,EAAGC,IACjCF,EAAGC,GAAGC,GAAKF,EAAGC,EAAE,GAAGC,EAAE,GAAKF,EAAGC,EAAE,GAAGC,GAI1C,OAAOF,EAAGL,GAAG,EACjB,EAuBaQ,GAA6B,CAACR,EAAW,IAAuB,CACzE,GAAIA,EAAI,GAAK,EAAI,EACb,MAAM,IAAI,MAAM,+CAA+C,EAEnE,GAAI,CAAC,OAAO,UAAUA,CAAC,GAAK,CAAC,OAAO,UAAU,CAAC,EAC3C,MAAM,IAAI,MAAM,kCAAkC,EAGtD,GAAGA,IAAM,EAAG,MAAO,GAGnB,IAAMS,EAAa,EAAIT,EAAI,EACrBU,EAAc,EAGdL,EAAiB,MAAM,KAAK,CAAE,OAAQI,EAAa,CAAE,EAAG,IAAM,MAAMC,EAAc,CAAC,EAAE,KAAK,CAAC,CAAC,EAGlG,QAAS,EAAI,EAAG,GAAKD,EAAY,IAC7BJ,EAAG,GAAG,GAAK,EAGf,QAAS,EAAI,EAAG,GAAKI,EAAY,IAC7B,QAASF,EAAI,EAAGA,GAAK,KAAK,IAAI,EAAGG,CAAW,EAAGH,IAC3CF,EAAG,GAAGE,GAAKF,EAAG,EAAI,GAAGE,GAAKF,EAAG,EAAI,GAAGE,EAAI,GAIhD,OAAOF,EAAGI,GAAYC,EAC1B", + "names": ["index_esm_exports", "__export", "animate", "arithmeticSequenceSum", "circleCollide", "circleMovement", "circleMovementAfterMouse", "combinationsWithRepetition", "combinationsWithoutRepetition", "convertRange", "convexPolygonsCollide", "degreesToRadians", "doRangesOverlap", "dxArcCos", "dxArcCot", "dxArcSin", "dxArcTan", "dxCos", "dxCot", "dxPolynomial", "dxSin", "dxTan", "dxV2CubicBezierCurve", "dxV2QuadraticBezierCurve", "dxV3CubicBezierCurve", "dxV3QuadraticBezierCurve", "ellipseMovement", "ellipseMovementAfterMouse", "factorial", "factorialIterative", "factorialMemoized", "factorialRecursive", "getAnglesDistance", "getAnglesSub", "getArithmeticMean", "getArithmeticMeanFromFrequency", "getCircleCircumference", "getColorsDelta", "getEllipseCircumference", "getLinearEquationBy2Points", "getMedian", "getMode", "getRandom", "getRandomBoolean", "getRandomGrayscaleHSLColor", "getRandomHSLColor", "getRandomHSLColorWithHue", "getRandomHSLColorWithLightness", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithinRanges", "getRandomHexColor", "getRandomInt", "getRandomItemFromArray", "getRandomRGBColor", "getShiftedHue", "getShiftedLightness", "getShiftedSaturation", "getSquareInCircleSide", "getStandardDeviation", "getV2Angle", "getV2AngleBetween", "getV2AngleInEllipse", "getV3AngleBetween", "getVNAngleBetween", "getVariance", "getVariance1", "guid", "hexToRgb", "hslToHex", "hslToRgb", "identity2", "identity3", "identity4", "identityN", "isAngleBetween", "isAngleInCircleArc", "isClockwise", "isNumber", "isSingularMatrix", "labToRgb", "linearEquation", "linearEquationSystem2", "linearEquationSystem3", "linearEquationSystemN", "lissajousCurve", "m2Adjugate", "m2AppendRow", "m2DeepCopy", "m2Determinant", "m2DivideScalar", "m2Inverse", "m2MulScalar", "m2PrependRow", "m2ReflectionOrigin", "m2ReflectionOriginH", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m2ReflectionYmX", "m2Reset", "m2RotateAroundPointH", "m2Rotation", "m2RotationAroundPointH", "m2RotationH", "m2Scale", "m2ScaleAtPointH", "m2ScaleAtPointHMatrix", "m2ScaleH", "m2ScaleX", "m2ScaleXH", "m2ScaleY", "m2ScaleYH", "m2ShearingX", "m2ShearingY", "m2Sub", "m2Sum", "m2ToCSS", "m2Translation", "m2TranslationH", "m2Transpose", "m2hToCSS", "m2hToCSS3d", "m2x2", "m3Adjugate", "m3AppendRow", "m3DeepCopy", "m3Determinant", "m3DivideScalar", "m3Inverse", "m3MulScalar", "m3PrependRow", "m3ReflectionOrigin", "m3ReflectionOriginH", "m3ReflectionXY", "m3ReflectionXYH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionYZ", "m3ReflectionYZH", "m3Reset", "m3RotationX", "m3RotationXH", "m3RotationY", "m3RotationYH", "m3RotationZ", "m3RotationZH", "m3Scale", "m3ScaleH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m3Sub", "m3Sum", "m3Translation", "m3TranslationH", "m3Transpose", "m3hToCSS3d", "m3x3", "m4x4", "mAdjugate", "mAppendCol", "mAppendRow", "mDeepCopy", "mDelFirstColumn", "mDelFirstRow", "mDelLastColumn", "mDelLastRow", "mDeterminant", "mDivideScalar", "mEqual", "mGetColumn", "mGetFirstColumn", "mGetLastColumn", "mInverse", "mMinor", "mMul", "mMulScalar", "mMulVector", "mNxM", "mPrependCol", "mPrependRow", "mReset", "mSub", "mSum", "mTranspose", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mod", "naturalNumbersSequenceSum", "naturalNumbersSum1ToN", "naturalNumbersSumMToN", "newId", "percentToAngle", "permutationsWithRepetition", "permutationsWithoutRepetition", "polarToCartesian", "radiansToDegrees", "rectCollide", "rgbToHex", "rgbToHsl", "rgbToLab", "setDecimalPlaces", "setV2Angle", "sineWaveMovement", "stringToNumber", "v2", "v2CubicBezierBBox", "v2CubicBezierCurve", "v2CubicBezierCurveExtrema", "v2CubicBezierCurveNormal", "v2CubicBezierCurveTangent", "v2Distance", "v2DivideScalar", "v2DotProduct", "v2FromPolarCoords", "v2GetNormal", "v2Length", "v2MulScalar", "v2Normalize", "v2QuadraticBezierBBox", "v2QuadraticBezierCurve", "v2QuadraticBezierCurveExtrema", "v2QuadraticBezierCurveNormal", "v2QuadraticBezierCurveTangent", "v2Rotate", "v2RotateH", "v2Scale", "v2SetLength", "v2Sub", "v2Sum", "v3", "v3CrossProduct", "v3CubicBezierCurve", "v3CubicBezierCurveTangent", "v3Distance", "v3DivideScalar", "v3DotProduct", "v3Length", "v3MulScalar", "v3Normalize", "v3QuadraticBezierCurve", "v3QuadraticBezierCurveTangent", "v3RotateX", "v3RotateY", "v3RotateZ", "v3Scale", "v3Sub", "v3Sum", "v4", "vDistance", "vDivideScalar", "vDotProduct", "vEqual", "vLength", "vMulScalar", "vN", "vNormalize", "vSub", "vSum", "__toCommonJS", "setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "stringToNumber", "value", "defaultNumber", "_a", "res", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "x", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "guid", "c", "newId", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "naturalNumbersSequenceSum", "n", "arithmeticSequenceSum", "a", "d", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "naturalNumbersSum1ToN", "n", "naturalNumbersSumMToN", "m", "factorialIterative", "n", "start", "result", "i", "factorialRecursive", "factorialMemoized", "memo", "traverse", "num", "end", "_a", "factorial", "table", "permutationsWithRepetition", "n", "__pow", "permutationsWithoutRepetition", "factorial", "combinationsWithoutRepetition", "dp", "i", "j", "combinationsWithRepetition", "totalItems", "chooseItems"] } diff --git a/src/main/combinatorics/combinatorics.ts b/src/main/combinatorics/combinatorics.ts index 1ffde8c..00351b4 100644 --- a/src/main/combinatorics/combinatorics.ts +++ b/src/main/combinatorics/combinatorics.ts @@ -128,7 +128,7 @@ export const combinationsWithoutRepetition = (n: number, r: number) : number => }; /** - * Combinations with repetitions: + * Combinations with repetitions (multi-choose): * - "n" is the number of things to choose from * - we choose "r" of them * - order doesn't matter @@ -145,8 +145,8 @@ export const combinationsWithoutRepetition = (n: number, r: number) : number => * We can have three scoops. How many variations will there be? * * Tabulation (Bottom-Up Dynamic Programming). - * Time Complexity: - * Space Complexity: + * Time Complexity: 𝑂((r + n) × r) + * Space Complexity: 𝑂((r + n) × r) */ export const combinationsWithRepetition = (n: number, r: number) : number => { if (n < 0 || r < 0) { @@ -156,6 +156,26 @@ export const combinationsWithRepetition = (n: number, r: number) : number => { throw new Error('Both n and r should be integers.'); } + if(n === 0) return 1; + // Calculate adjusted values for indices in the DP table + const totalItems = r + n - 1; + const chooseItems = r; + + // Initialize DP table + const dp: number[][] = Array.from({ length: totalItems + 1 }, () => Array(chooseItems + 1).fill(0)); + + // Base case initialization: C(i, 0) = 1 for all i, because there's one way to choose nothing + for (let i = 0; i <= totalItems; i++) { + dp[i][0] = 1; + } + + for (let i = 1; i <= totalItems; i++) { + for (let j = 1; j <= Math.min(i, chooseItems); j++) { + dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1]; + } + } + + return dp[totalItems][chooseItems]; }; diff --git a/test/combinatorics.test.ts b/test/combinatorics.test.ts index 7882ddc..67ae674 100644 --- a/test/combinatorics.test.ts +++ b/test/combinatorics.test.ts @@ -1,4 +1,9 @@ -import { permutationsWithRepetition, permutationsWithoutRepetition, combinationsWithoutRepetition } from '../src/main/combinatorics/combinatorics'; +import { + permutationsWithRepetition, + permutationsWithoutRepetition, + combinationsWithoutRepetition, + combinationsWithRepetition, +} from '../src/main/combinatorics/combinatorics'; describe('Combinatorics', () => { @@ -69,4 +74,36 @@ describe('Combinatorics', () => { expect(() => combinationsWithoutRepetition(5, 2.7)).toThrow('Both n and r should be integers.'); }); }); + + describe('combinationsWithRepetition()', () => { + it('calculates simple combinations with repetition correctly', () => { + expect(combinationsWithRepetition(5, 3)).toBe(35); + expect(combinationsWithRepetition(3, 2)).toBe(6); // C(3+2-1, 2) = C(4, 2) = 6 + expect(combinationsWithRepetition(4, 3)).toBe(20); // C(4+3-1, 3) = C(6, 3) = 20 + }); + + it('returns 1 when r is 0, regardless of n', () => { + expect(combinationsWithRepetition(5, 0)).toBe(1); // C(5-1, 0) = C(4, 0) = 1 + expect(combinationsWithRepetition(10, 0)).toBe(1); // C(10-1, 0) = C(9, 0) = 1 + }); + + it('calculates combinations correctly when n is 1', () => { + expect(combinationsWithRepetition(1, 1)).toBe(1); + expect(combinationsWithRepetition(1, 5)).toBe(1); // C(1+5-1, 5) = C(5, 5) = 1 + }); + + it('throws an error if n or r are negative', () => { + expect(() => combinationsWithRepetition(-1, 3)).toThrow('Both n and r should be non-negative integers.'); + expect(() => combinationsWithRepetition(5, -1)).toThrow('Both n and r should be non-negative integers.'); + }); + + it('handles edge cases for large n and small r', () => { + expect(combinationsWithRepetition(100, 1)).toBe(100); // C(100+1-1, 1) = C(100, 1) = 100 + }); + + it('handles cases where n is 0', () => { + expect(combinationsWithRepetition(0, 0)).toBe(1); // C(0+0-1, 0) = C(-1, 0) = 1 (special handled) + expect(combinationsWithRepetition(0, 1)).toBe(1); // C(0+1-1, 1) = C(0, 1) = 1 (special handled) + }); + }); }); \ No newline at end of file