From 3816cade534256fd57523427e1617028bb49b2d1 Mon Sep 17 00:00:00 2001 From: Miriam Zusin Date: Wed, 21 Feb 2024 22:45:48 +0200 Subject: [PATCH] ml --- 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/ml.ts | 30 +++++++++++++++++++++------ src/types.ts | 8 +++++++- test/ml.test.ts | 43 ++++++++++++++++++++++++++++++++++++++- 9 files changed, 88 insertions(+), 23 deletions(-) diff --git a/dist/mz-math.esm.js b/dist/mz-math.esm.js index 2175a9cb..41af7438 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 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),fr=(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 L=(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)},J=(t,r,e=1/0)=>{let n=P(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},yr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},lr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},$t=(t,r,e=1/0)=>{let n=T(t),o=T(r),i=S(n,o),c=Math.acos(i);return s(c,e)},Ir=(t,r,e=1/0)=>{let n=d(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},dr=(t,r,e=1/0)=>$t(t,r,e),vr=(t,r,e)=>{let n=j(r,e),o=j(r,t),i=j(e,t),c=o+i;return Math.abs(c-n)<=.001},U=(t,r,e=0)=>(t=t%360,r=r%360,t=t),j=(t,r,e=1/0)=>{let n=Math.abs(l(t,360)-l(r,360));return s(n<=180?n:360-n,e)},Et=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Et(r,e,n);return U(r,e,n)?l(n+t*o/100,360):l(n-t*o/100,360)};var N=(t,r,e=1/0)=>{let n=[];for(let o=0;oN(t,r,e),Hr=(t,r,e=1/0)=>N(t,r,e),d=(t,r,e=1/0)=>{let n=[];for(let o=0;od(t,r,e),Br=(t,r,e=1/0)=>d(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),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),$r=(t,r,e=1/0)=>X(t,r,e),z=(t,r=1/0)=>{let e=0;for(let n=0;nz(t,r),Er=(t,r=1/0)=>z(t,r),qt=(t,r,e=1/0)=>{let n=L(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},qr=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},Ar=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},Nr=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},T=(t,r=1/0)=>{let e=z(t),n=[];for(let o=0;oT(t,r),g=(t,r=1/0)=>T(t,r),S=(t,r,e=1/0)=>{let n=0;for(let o=0;oS(t,r,e),Cr=(t,r,e=1/0)=>S(t,r,e),Xr=(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)],Yr=(t=0)=>[t,t],Dr=(t=0)=>[t,t,t],Gr=(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=qt(e,t),J(e,r)},et=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=w(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),Qr=(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),Wr=(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},_r=(t,r,e=1/0)=>ct(t,r,e),Kr=(t,r,e=1/0)=>ct(t,r,e),F=(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},At=(t,r,e=1/0)=>F(t,r,e),Jr=(t,r,e=1/0)=>F(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),Pr=t=>Y(t),st=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nst(t,r),re=(t,r=0)=>st(t,r),ee=(t=0)=>[[t,t],[t,t]],ne=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],oe=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],ie=(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]],se=()=>[[1,0,0],[0,1,0],[0,0,1]],ue=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],xe=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),xt=t=>I(t),ae=(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},pe=(t,r)=>{let e=ut(t);return e.push(r),e},Me=(t,r)=>{let e=xt(t);return e.push(r),e},he=(t,r)=>{let e=I(t);return e.unshift(r),e},be=(t,r)=>{let e=ut(t);return e.unshift(r),e},Ve=(t,r)=>{let e=xt(t);return e.unshift(r),e},ye=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},le=t=>{if(t.length<=0)return[];let r=I(t);return r.shift(),r},at=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=Nt(t,r,e);return D(o)},D=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]},Se=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return D(t)},Mt=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]]]},Re=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 Mt(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 D(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=pt(t);if(e===0)return null;let n=Mt(t);return n===null?null:At(n,e,r)},Vt=(t,r=1/0)=>Q(t,r),Q=(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=D(t),o=ht(t);return o===null?null:F(o,n,r)};var Le=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],c=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${c})`},Ee=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)`},qe=t=>`matrix3d( +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 l=(t,r)=>(t%r+r)%r,O=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,pr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),B=t=>!isNaN(parseFloat(t))&&isFinite(t),Mr=(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 L=(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)},J=(t,r,e=1/0)=>{let n=P(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)},Ir=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},$t=(t,r,e=1/0)=>{let n=T(t),o=T(r),i=S(n,o),c=Math.acos(i);return s(c,e)},vr=(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)=>$t(t,r,e),Sr=(t,r,e)=>{let n=j(r,e),o=j(r,t),i=j(e,t),c=o+i;return Math.abs(c-n)<=.001},U=(t,r,e=0)=>(t=t%360,r=r%360,t=t),j=(t,r,e=1/0)=>{let n=Math.abs(l(t,360)-l(r,360));return s(n<=180?n:360-n,e)},Et=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Et(r,e,n);return U(r,e,n)?l(n+t*o/100,360):l(n-t*o/100,360)};var N=(t,r,e=1/0)=>{let n=[];for(let o=0;oN(t,r,e),Tr=(t,r,e=1/0)=>N(t,r,e),I=(t,r,e=1/0)=>{let n=[];for(let o=0;oI(t,r,e),Lr=(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),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),qr=(t,r,e=1/0)=>X(t,r,e),z=(t,r=1/0)=>{let e=0;for(let n=0;nz(t,r),Ar=(t,r=1/0)=>z(t,r),qt=(t,r,e=1/0)=>{let n=L(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 z(n,e)},Cr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},Xr=(t,r,e=1/0)=>{let n=I(t,r);return z(n,e)},T=(t,r=1/0)=>{let e=z(t),n=[];for(let o=0;oT(t,r),g=(t,r=1/0)=>T(t,r),S=(t,r,e=1/0)=>{let n=0;for(let o=0;oS(t,r,e),Yr=(t,r,e=1/0)=>S(t,r,e),Dr=(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)],Gr=(t=0)=>[t,t],Or=(t=0)=>[t,t,t],jr=(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=qt(e,t),J(e,r)},et=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=w(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),_r=(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),Kr=(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},Jr=(t,r,e=1/0)=>ct(t,r,e),Ur=(t,r,e=1/0)=>ct(t,r,e),F=(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},At=(t,r,e=1/0)=>F(t,r,e),Pr=(t,r,e=1/0)=>F(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),re=t=>Y(t),st=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nst(t,r),ne=(t,r=0)=>st(t,r),oe=(t=0)=>[[t,t],[t,t]],ie=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],ce=(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]],xe=()=>[[1,0,0],[0,1,0],[0,0,1]],ae=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],me=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),xt=t=>d(t),fe=(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},he=(t,r)=>{let e=ut(t);return e.push(r),e},be=(t,r)=>{let e=xt(t);return e.push(r),e},Ve=(t,r)=>{let e=d(t);return e.unshift(r),e},ye=(t,r)=>{let e=ut(t);return e.unshift(r),e},le=(t,r)=>{let e=xt(t);return e.unshift(r),e},de=t=>{if(t.length<=0)return[];let r=d(t);return r.pop(),r},Ie=t=>{if(t.length<=0)return[];let r=d(t);return r.shift(),r},at=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=Nt(t,r,e);return D(o)},D=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]},we=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return D(t)},Mt=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]]]},ze=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 Mt(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 D(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=pt(t);if(e===0)return null;let n=Mt(t);return n===null?null:At(n,e,r)},Vt=(t,r=1/0)=>Q(t,r),Q=(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=D(t),o=ht(t);return o===null?null:F(o,n,r)};var Ee=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)`},qe=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})`},Ae=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)`},Ne=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]} - )`,Ae=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Ne=(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)]],G=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],Ce=(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]],Ct=(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]]},yt=(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]]},Xt=(t,r,e=!0,n=1/0)=>{let o=G(r,n),i=yt(t,e,n),c=G(k(r,-1),n),u=E(o,i);return E(u,c)},Xe=(t,r,e,n=!0,o=1/0)=>{let i=Xt(t,r,n,o);return b(i,e)},Ye=(t,r,e=!0,n=1/0)=>{let o=$(r);return b(Ct(t,e,n),o)},De=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(yt(t,e,n),o)},Yt=(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]]},Ge=(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]]},Oe=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Yt(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,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},je=(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]]},ke=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Dt(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?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Fe=(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]]},Qe=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Gt(t,e,n),o)},Ot=(t,r,e=1/0)=>{let n=G(r,e),o=kt(t),i=G(k(r,-1),e),c=E(n,o);return E(c,i)},Ze=(t,r,e,n=1/0)=>{let o=Ot(t,r,n);return b(o,e)},jt=t=>[[t[0],0],[0,t[1]]],We=(t,r)=>b(jt(t),r),kt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Ft=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],_e=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Ke=(t,r)=>b(Ft(t),r),Je=t=>[[t,0],[0,1]],Ue=t=>[[t,0,0],[0,1,0],[0,0,1]],Pe=t=>[[t,0,0],[0,1,0],[0,0,1]],tn=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],rn=t=>[[1,0,0],[0,t,0],[0,0,1]],en=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],nn=t=>[[1,0,0],[0,1,0],[0,0,t]],on=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],cn=t=>[[1,0],[0,t]],sn=t=>[[1,0,0],[0,t,0],[0,0,1]],un=()=>[[-1,0],[0,-1]],xn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],an=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],mn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],fn=()=>[[0,-1],[-1,0]],pn=()=>[[1,0],[0,-1]],Mn=()=>[[1,0,0],[0,-1,0],[0,0,1]],hn=()=>[[-1,0],[0,1]],bn=()=>[[-1,0,0],[0,1,0],[0,0,1]],Vn=()=>[[-1,0,0],[0,1,0],[0,0,1]],yn=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],ln=()=>[[1,0,0],[0,-1,0],[0,0,1]],In=()=>[[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]],vn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],gn=t=>[[1,t],[0,1]],Sn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),Qt=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),zn=()=>Math.random()<.5,Hn=t=>{let r=Qt(0,t.length-1);return t[r]};var Tn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var En=(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)},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)]},It=(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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},vt=(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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},qn=(t,r=1/0)=>s(Math.cos(t),r),An=(t,r=1/0)=>s(-Math.sin(t),r),Nn=(t,r=1/0)=>s(1/h(Math.cos(t),2),r),Cn=(t,r=1/0)=>s(-1/h(Math.sin(t),2),r),Xn=(t,r=1/0)=>s(1/Math.sqrt(1-h(t,2)),r),Yn=(t,r=1/0)=>s(-1/Math.sqrt(1-h(t,2)),r),Dn=(t,r=1/0)=>s(1/(1+h(t,2)),r),Gn=(t,r=1/0)=>s(-1/(1+h(t,2)),r);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:s(i/e,r)},Zn=(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 b(o,i,e)},Wn=(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 b(i,c,n)},_n=(t,r=1/0)=>{if(t.length<=0)return null;let e=at(t),n=Q(e);if(n===null)return null;let o=mt(t);return b(n,o,r)},Kn=(t,r)=>{let[e,n]=w(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 Z=(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 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,a=Math.sqrt(u);return[s((-n+a)/x,r),s((-n-a)/x,r)]};var Zt=(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)]},uo=(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)]},Wt=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},xo=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},_t=(t,r,e,n,o=1/0)=>{let i=lt(t,r,e,n);return $(i,o)},ao=(t,r,e,n,o=1/0)=>{let i=It(t,r,e,n);return g(i,o)},Kt=(t,r,e,n,o,i=1/0)=>{let c=dt(t,r,e,n,o);return $(c,i)},mo=(t,r,e,n,o,i=1/0)=>{let c=vt(t,r,e,n,o);return g(c,i)},fo=(t,r,e,n,o=1/0)=>{let i=_t(t,r,e,n,o);return[-i[1],i[0]]},po=(t,r,e,n,o,i=1/0)=>{let c=Kt(t,r,e,n,o,i);return[-c[1],c[0]]},Jt=(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),x=2*t[1]-4*r[1]+2*e[1],a=-2*t[1]+2*r[1],p=q([x,a,0],n),m=[];return B(u)&&m.push(u),B(p)&&m.push(p),m},Ut=(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],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],m=[a,f,p,0],M=Z(x,o).filter(y=>y>=0&&y<=1),v=Z(m,o).filter(y=>y>=0&&y<=1);return[...M,...v].length===2?[...M,...v]:null},Mo=(t,r,e,n=1/0)=>{let o=Jt(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let a of o){let f=Zt(a,t,r,e),p=f[0],m=f[1];i=Math.min(i,p),u=Math.max(u,p),c=Math.min(c,m),x=Math.max(x,m)}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}},ho=(t,r,e,n,o=1/0)=>{let i=Ut(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,a=-1/0;for(let f of i){let p=Wt(f,t,r,e,n),m=p[0],M=p[1];c=Math.min(c,m!=null?m:1/0),x=Math.max(x,m!=null?m:-1/0),u=Math.min(u,M!=null?M:1/0),a=Math.max(a,M!=null?M:-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),a=s(Math.max(a,t[1],n[1]),o),{x:c,y:u,w:Math.abs(x-c),h:Math.abs(a-u),x2:x,y2:a}};var Pt=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Io=(t,r,e)=>{let n=w(t,r),o=L(n);return o=O(o,0,Math.PI*2,0,Math.PI),Pt(r,o,e)},tr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),vo=(t,r,e)=>{let n=w(t,r),o=L(n);return o=O(o,0,Math.PI*2,0,Math.PI),tr(r,o,e[0],e[1])},go=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},So=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Bo=()=>{let t=St();return or(t)},To=()=>{let t=St();return ir(t)},St=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Lo=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},$o=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Eo=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},qo=()=>[0,0,V(0,100)],Ao=(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]},rr=t=>(t*=60,t<0&&(t+=360),t),er=(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),nr=(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?Rt(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),No=(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=Rt(e,n,o,i,c),x=nr(e,n,o,i,c,u),a=er(e,n,o,i,c);return a>360||x>100||u>100?[0,0,100]:a<0||x<0||u<0?[0,0,0]:[s(a,r),s(x,r),s(u,r)]},W=(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),or=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let M=o*255;return[M,M,M]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,a=e-.333,f=W(i,c,u),p=W(i,c,x),m=W(i,c,a);return f*=255,p*=255,m*=255,f>255||p>255||m>255?[255,255,255]:f<0||p<0||m<0?[0,0,0]:[s(f,r),s(p,r),s(m,r)]},ir=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,m,M)=>(M<0&&(M+=1),M>1&&(M-=1),M<.16666666666666666?p+(m-p)*6*M:M<.5?m:M<.6666666666666666?p+(m-p)*(.6666666666666666-M)*6:p),a=n<.5?n*(1+e):n+e-n*e,f=2*n-a;o=x(f,a,r+1/3),i=x(f,a,r),c=x(f,a,r-1/3)}let u=x=>{let a=Math.round(x*255).toString(16);return a.length===1?"0"+a:a};return`#${u(o)}${u(i)}${u(c)}`},Co=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Xo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,a,f)=>x+x+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),c=parseInt(n[3],16);return[o,i,c]},gt=(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)]},Yo=(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)]},Do=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=l(e,360)),[e,t[1],t[2]]},Go=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=l(e,100)),[t[0],t[1],e]},Oo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},jo=(t,r,e=1/0)=>{let n=gt(t,e),o=gt(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]),a=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=x-a,p=c*c+u*u-f*f;p=p<0?0:Math.sqrt(p);let m=1+.045*x,M=1+.015*x,v=i/1,H=f/m,y=p/M,A=v*v+H*H+y*y;return A<0?0:Math.sqrt(A)};var Fo=()=>"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 Ko=(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,Jo=(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},wt=t=>{let r=[];for(let e=0;e{let e=[];e.push(...wt(t)),e.push(...wt(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 ti=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)},a=()=>{x(),v()},f=()=>{c=!1},p=()=>{c=!0},m=R=>{e===void 0&&(e=R),o=R-e,c&&i!==R&&typeof t.callback=="function"&&t.callback(K()),o<=r?(i=R,n=window.requestAnimationFrame(m)):x()},M=(R,Lt)=>{a(),typeof t.resizeCallback=="function"&&t.resizeCallback(R,Lt)},v=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(M),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(m)},H=()=>o,y=()=>c,A=()=>e,Bt=()=>{if(!(r===1/0||o===void 0))return o*100/r},Tt=()=>u,K=()=>({start:v,stop:x,pause:f,resume:p,restart:a,isAnimating:y,getElapsedTime:H,getStartTime:A,getPercent:Bt,getResizeObserver:Tt});return K()};var ni=(t,r=1/0)=>s(2*Math.PI*t,r),oi=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),ii=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),ci=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var xi=t=>t*(t+1)/2,ai=(t,r,e)=>t/2*(2*r+(t-1)*e);var _=(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)},pi=(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)},Mi=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},cr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=_(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return s(n/t.length,r)},Ht=(t,r=1/0)=>{var n;let e=(n=cr(t))!=null?n:0;return s(Math.sqrt(e),r)};var li=(t,r=1/0)=>{let e=[...t],n=Math.min(...e),i=Math.max(...e)-n;if(i===0)return[0];for(let c=0;c{var i;let e=[...t],n=(i=_(e))!=null?i:0,o=Ht(e,r);return e.map(c=>(c-n)/o)};export{ti as animate,ai as arithmeticSequenceSum,Jo as circleCollide,Pt as circleMovement,Io as circleMovementAfterMouse,O as convertRange,Uo as convexPolygonsCollide,lr as degreesToRadians,mr as doRangesOverlap,Yn as dxArcCos,Gn as dxArcCot,Xn as dxArcSin,Dn as dxArcTan,An as dxCos,Cn as dxCot,En as dxPolynomial,qn as dxSin,Nn as dxTan,dt as dxV2CubicBezierCurve,lt as dxV2QuadraticBezierCurve,vt as dxV3CubicBezierCurve,It as dxV3QuadraticBezierCurve,tr as ellipseMovement,vo as ellipseMovementAfterMouse,Et as getAnglesDistance,j as getAnglesSub,_ as getArithmeticMean,ni as getCircleCircumference,jo as getColorsDelta,oi as getEllipseCircumference,Kn as getLinearEquationBy2Points,pi as getMedian,Mi as getMode,V as getRandom,zn as getRandomBoolean,qo as getRandomGrayscaleHSLColor,St as getRandomHSLColor,Lo as getRandomHSLColorWithHue,Eo as getRandomHSLColorWithLightness,$o as getRandomHSLColorWithSaturation,Ao as getRandomHSLColorWithinRanges,To as getRandomHexColor,Qt as getRandomInt,Hn as getRandomItemFromArray,Bo as getRandomRGBColor,Do as getShiftedHue,Go as getShiftedLightness,Oo as getShiftedSaturation,ci as getSquareInCircleSide,Ht as getStandardDeviation,L as getV2Angle,Ir as getV2AngleBetween,Vr as getV2AngleInEllipse,dr as getV3AngleBetween,$t as getVNAngleBetween,cr as getVariance,Fo as guid,Xo as hexToRgb,ir as hslToHex,or as hslToRgb,ce as identity2,se as identity3,ue as identity4,xe as identityN,vr as isAngleBetween,ii as isAngleInCircleArc,U as isClockwise,B as isNumber,we as isSingularMatrix,Yo as labToRgb,q as linearEquation,Zn as linearEquationSystem2,Wn as linearEquationSystem3,_n as linearEquationSystemN,So as lissajousCurve,Mt as m2Adjugate,pe as m2AppendRow,ut as m2DeepCopy,pt as m2Determinant,At as m2DivideScalar,bt as m2Inverse,_r as m2MulScalar,be as m2PrependRow,un as m2ReflectionOrigin,xn as m2ReflectionOriginH,pn as m2ReflectionX,Mn as m2ReflectionXH,hn as m2ReflectionY,bn as m2ReflectionYH,fn as m2ReflectionYmX,te as m2Reset,Xe as m2RotateAroundPointH,Ct as m2Rotation,Xt as m2RotationAroundPointH,yt as m2RotationH,jt as m2Scale,Ze as m2ScaleAtPointH,Ot as m2ScaleAtPointHMatrix,kt as m2ScaleH,Je as m2ScaleX,Ue as m2ScaleXH,cn as m2ScaleY,sn as m2ScaleYH,Sn as m2ShearingX,gn as m2ShearingY,Zr as m2Sub,Fr as m2Sum,Le as m2ToCSS,Ae as m2Translation,G as m2TranslationH,Ur as m2Transpose,$e as m2hToCSS,Ee as m2hToCSS3d,ee as m2x2,Re as m3Adjugate,Me as m3AppendRow,xt as m3DeepCopy,Se as m3Determinant,Jr as m3DivideScalar,Vt as m3Inverse,Kr as m3MulScalar,Ve as m3PrependRow,an as m3ReflectionOrigin,mn as m3ReflectionOriginH,dn as m3ReflectionXY,vn as m3ReflectionXYH,ln as m3ReflectionXZ,In as m3ReflectionXZH,Vn as m3ReflectionYZ,yn as m3ReflectionYZH,re as m3Reset,Yt as m3RotationX,Ge as m3RotationXH,Dt as m3RotationY,je as m3RotationYH,Gt as m3RotationZ,Fe as m3RotationZH,Ft as m3Scale,_e as m3ScaleH,Pe as m3ScaleX,tn as m3ScaleXH,rn as m3ScaleY,en as m3ScaleYH,nn as m3ScaleZ,on as m3ScaleZH,Wr as m3Sub,Qr as m3Sum,Ne as m3Translation,Ce as m3TranslationH,Pr as m3Transpose,qe as m3hToCSS3d,ne as m3x3,oe as m4x4,ht as mAdjugate,ae as mAppendCol,fe as mAppendRow,I as mDeepCopy,Ie as mDelFirstColumn,le as mDelFirstRow,at as mDelLastColumn,ye as mDelLastRow,D as mDeterminant,F as mDivideScalar,ge as mEqual,ve as mGetColumn,de as mGetFirstColumn,mt as mGetLastColumn,Q as mInverse,ft as mMinor,E as mMul,ct as mMulScalar,b as mMulVector,ie as mNxM,me as mPrependCol,he as mPrependRow,st as mReset,it as mSub,ot as mSum,Y as mTranspose,li as mlNormalize,Ii as mlStandardize,l as mod,xi as naturalNumbersSequenceSum,Qo as newId,gr as percentToAngle,fr as polarToCartesian,yr as radiansToDegrees,Ko as rectCollide,Co as rgbToHex,No as rgbToHsl,gt as rgbToLab,s as setDecimalPlaces,J as setV2Angle,go as sineWaveMovement,Tn as stringToNumber,Yr as v2,ho as v2CubicBezierBBox,Wt as v2CubicBezierCurve,Ut as v2CubicBezierCurveExtrema,po as v2CubicBezierCurveNormal,Kt as v2CubicBezierCurveTangent,Ar as v2Distance,Lr as v2DivideScalar,tt as v2DotProduct,Or as v2FromPolarCoords,nt as v2GetNormal,P as v2Length,Tr as v2MulScalar,$ as v2Normalize,Mo as v2QuadraticBezierBBox,Zt as v2QuadraticBezierCurve,Jt as v2QuadraticBezierCurveExtrema,fo as v2QuadraticBezierCurveNormal,_t as v2QuadraticBezierCurveTangent,Ye as v2Rotate,De as v2RotateH,We as v2Scale,qt as v2SetLength,w as v2Sub,zr as v2Sum,Dr as v3,Xr as v3CrossProduct,xo as v3CubicBezierCurve,mo as v3CubicBezierCurveTangent,Nr as v3Distance,$r as v3DivideScalar,Cr as v3DotProduct,Er as v3Length,k as v3MulScalar,g as v3Normalize,uo as v3QuadraticBezierCurve,ao as v3QuadraticBezierCurveTangent,Oe as v3RotateX,ke as v3RotateY,Qe as v3RotateZ,Ke as v3Scale,Br as v3Sub,Hr as v3Sum,Gr as v4,qr as vDistance,X as vDivideScalar,S as vDotProduct,et as vEqual,z as vLength,C as vMulScalar,rt as vN,T as vNormalize,d as vSub,N as vSum}; + )`,Ce=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Xe=(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)]],G=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],Ye=(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]],Ct=(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]]},yt=(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]]},Xt=(t,r,e=!0,n=1/0)=>{let o=G(r,n),i=yt(t,e,n),c=G(k(r,-1),n),u=E(o,i);return E(u,c)},De=(t,r,e,n=!0,o=1/0)=>{let i=Xt(t,r,n,o);return b(i,e)},Ge=(t,r,e=!0,n=1/0)=>{let o=$(r);return b(Ct(t,e,n),o)},Oe=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(yt(t,e,n),o)},Yt=(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]]},je=(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]]},ke=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Yt(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,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},Fe=(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]]},Qe=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Dt(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?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Ze=(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]]},_e=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Gt(t,e,n),o)},Ot=(t,r,e=1/0)=>{let n=G(r,e),o=kt(t),i=G(k(r,-1),e),c=E(n,o);return E(c,i)},We=(t,r,e,n=1/0)=>{let o=Ot(t,r,n);return b(o,e)},jt=t=>[[t[0],0],[0,t[1]]],Ke=(t,r)=>b(jt(t),r),kt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Ft=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Je=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Ue=(t,r)=>b(Ft(t),r),Pe=t=>[[t,0],[0,1]],tn=t=>[[t,0,0],[0,1,0],[0,0,1]],rn=t=>[[t,0,0],[0,1,0],[0,0,1]],en=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],nn=t=>[[1,0,0],[0,t,0],[0,0,1]],on=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],cn=t=>[[1,0,0],[0,1,0],[0,0,t]],sn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],un=t=>[[1,0],[0,t]],xn=t=>[[1,0,0],[0,t,0],[0,0,1]],an=()=>[[-1,0],[0,-1]],mn=()=>[[-1,0,0],[0,-1,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]],Mn=()=>[[0,-1],[-1,0]],hn=()=>[[1,0],[0,-1]],bn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Vn=()=>[[-1,0],[0,1]],yn=()=>[[-1,0,0],[0,1,0],[0,0,1]],ln=()=>[[-1,0,0],[0,1,0],[0,0,1]],dn=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],In=()=>[[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]],gn=()=>[[1,0,0],[0,1,0],[0,0,-1]],Sn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Rn=t=>[[1,t],[0,1]],wn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),Qt=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Bn=()=>Math.random()<.5,Tn=t=>{let r=Qt(0,t.length-1);return t[r]};var $n=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var An=(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)},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)]},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),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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},vt=(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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},Nn=(t,r=1/0)=>s(Math.cos(t),r),Cn=(t,r=1/0)=>s(-Math.sin(t),r),Xn=(t,r=1/0)=>s(1/h(Math.cos(t),2),r),Yn=(t,r=1/0)=>s(-1/h(Math.sin(t),2),r),Dn=(t,r=1/0)=>s(1/Math.sqrt(1-h(t,2)),r),Gn=(t,r=1/0)=>s(-1/Math.sqrt(1-h(t,2)),r),On=(t,r=1/0)=>s(1/(1+h(t,2)),r),jn=(t,r=1/0)=>s(-1/(1+h(t,2)),r);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:s(i/e,r)},Wn=(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 b(o,i,e)},Kn=(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 b(i,c,n)},Jn=(t,r=1/0)=>{if(t.length<=0)return null;let e=at(t),n=Q(e);if(n===null)return null;let o=mt(t);return b(n,o,r)},Un=(t,r)=>{let[e,n]=w(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 Z=(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 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,a=Math.sqrt(u);return[s((-n+a)/x,r),s((-n-a)/x,r)]};var Zt=(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)]},ao=(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)]},_t=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},mo=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},Wt=(t,r,e,n,o=1/0)=>{let i=lt(t,r,e,n);return $(i,o)},fo=(t,r,e,n,o=1/0)=>{let i=dt(t,r,e,n);return g(i,o)},Kt=(t,r,e,n,o,i=1/0)=>{let c=It(t,r,e,n,o);return $(c,i)},po=(t,r,e,n,o,i=1/0)=>{let c=vt(t,r,e,n,o);return g(c,i)},Mo=(t,r,e,n,o=1/0)=>{let i=Wt(t,r,e,n,o);return[-i[1],i[0]]},ho=(t,r,e,n,o,i=1/0)=>{let c=Kt(t,r,e,n,o,i);return[-c[1],c[0]]},Jt=(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),x=2*t[1]-4*r[1]+2*e[1],a=-2*t[1]+2*r[1],p=q([x,a,0],n),m=[];return B(u)&&m.push(u),B(p)&&m.push(p),m},Ut=(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],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],m=[a,f,p,0],M=Z(x,o).filter(y=>y>=0&&y<=1),v=Z(m,o).filter(y=>y>=0&&y<=1);return[...M,...v].length===2?[...M,...v]:null},bo=(t,r,e,n=1/0)=>{let o=Jt(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let a of o){let f=Zt(a,t,r,e),p=f[0],m=f[1];i=Math.min(i,p),u=Math.max(u,p),c=Math.min(c,m),x=Math.max(x,m)}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}},Vo=(t,r,e,n,o=1/0)=>{let i=Ut(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,a=-1/0;for(let f of i){let p=_t(f,t,r,e,n),m=p[0],M=p[1];c=Math.min(c,m!=null?m:1/0),x=Math.max(x,m!=null?m:-1/0),u=Math.min(u,M!=null?M:1/0),a=Math.max(a,M!=null?M:-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),a=s(Math.max(a,t[1],n[1]),o),{x:c,y:u,w:Math.abs(x-c),h:Math.abs(a-u),x2:x,y2:a}};var Pt=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),go=(t,r,e)=>{let n=w(t,r),o=L(n);return o=O(o,0,Math.PI*2,0,Math.PI),Pt(r,o,e)},tr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),So=(t,r,e)=>{let n=w(t,r),o=L(n);return o=O(o,0,Math.PI*2,0,Math.PI),tr(r,o,e[0],e[1])},Ro=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},wo=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Lo=()=>{let t=St();return or(t)},$o=()=>{let t=St();return ir(t)},St=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Eo=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},qo=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Ao=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},No=()=>[0,0,V(0,100)],Co=(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]},rr=t=>(t*=60,t<0&&(t+=360),t),er=(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),nr=(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?Rt(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),Xo=(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=Rt(e,n,o,i,c),x=nr(e,n,o,i,c,u),a=er(e,n,o,i,c);return a>360||x>100||u>100?[0,0,100]:a<0||x<0||u<0?[0,0,0]:[s(a,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),or=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let M=o*255;return[M,M,M]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,a=e-.333,f=_(i,c,u),p=_(i,c,x),m=_(i,c,a);return f*=255,p*=255,m*=255,f>255||p>255||m>255?[255,255,255]:f<0||p<0||m<0?[0,0,0]:[s(f,r),s(p,r),s(m,r)]},ir=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,m,M)=>(M<0&&(M+=1),M>1&&(M-=1),M<.16666666666666666?p+(m-p)*6*M:M<.5?m:M<.6666666666666666?p+(m-p)*(.6666666666666666-M)*6:p),a=n<.5?n*(1+e):n+e-n*e,f=2*n-a;o=x(f,a,r+1/3),i=x(f,a,r),c=x(f,a,r-1/3)}let u=x=>{let a=Math.round(x*255).toString(16);return a.length===1?"0"+a:a};return`#${u(o)}${u(i)}${u(c)}`},Yo=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Do=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,a,f)=>x+x+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),c=parseInt(n[3],16);return[o,i,c]},gt=(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)]},Go=(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)]},Oo=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=l(e,360)),[e,t[1],t[2]]},jo=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=l(e,100)),[t[0],t[1],e]},ko=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},Fo=(t,r,e=1/0)=>{let n=gt(t,e),o=gt(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]),a=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=x-a,p=c*c+u*u-f*f;p=p<0?0:Math.sqrt(p);let m=1+.045*x,M=1+.015*x,v=i/1,H=f/m,y=p/M,A=v*v+H*H+y*y;return A<0?0:Math.sqrt(A)};var Zo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),_o=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var Uo=(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},wt=t=>{let r=[];for(let e=0;e{let e=[];e.push(...wt(t)),e.push(...wt(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 ei=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)},a=()=>{x(),v()},f=()=>{c=!1},p=()=>{c=!0},m=R=>{e===void 0&&(e=R),o=R-e,c&&i!==R&&typeof t.callback=="function"&&t.callback(K()),o<=r?(i=R,n=window.requestAnimationFrame(m)):x()},M=(R,Lt)=>{a(),typeof t.resizeCallback=="function"&&t.resizeCallback(R,Lt)},v=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(M),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(m)},H=()=>o,y=()=>c,A=()=>e,Bt=()=>{if(!(r===1/0||o===void 0))return o*100/r},Tt=()=>u,K=()=>({start:v,stop:x,pause:f,resume:p,restart:a,isAnimating:y,getElapsedTime:H,getStartTime:A,getPercent:Bt,getResizeObserver:Tt});return K()};var ii=(t,r=1/0)=>s(2*Math.PI*t,r),ci=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),si=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),ui=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var mi=t=>t*(t+1)/2,fi=(t,r,e)=>t/2*(2*r+(t-1)*e);var W=(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)},hi=(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)},bi=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},cr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=W(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return s(n/t.length,r)},Ht=(t,r=1/0)=>{var n;let e=(n=cr(t))!=null?n:0;return s(Math.sqrt(e),r)};var Ii=(t,r=1/0)=>{let e=[...t],n=Math.min(...e),i=Math.max(...e)-n;if(i===0)return[0];for(let c=0;ce===0?0:s((t-r)/e,n),ur=(t,r,e,n=1/0)=>[...t].map(o=>sr(o,r,e,n)),vi=(t,r=1/0)=>{var i;let e=(i=W(t))!=null?i:0,n=Ht(t),o=ur(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}};export{ei as animate,fi as arithmeticSequenceSum,Po as circleCollide,Pt as circleMovement,go as circleMovementAfterMouse,O as convertRange,ti as convexPolygonsCollide,Ir as degreesToRadians,pr as doRangesOverlap,Gn as dxArcCos,jn as dxArcCot,Dn as dxArcSin,On as dxArcTan,Cn as dxCos,Yn as dxCot,An as dxPolynomial,Nn as dxSin,Xn as dxTan,It as dxV2CubicBezierCurve,lt as dxV2QuadraticBezierCurve,vt as dxV3CubicBezierCurve,dt as dxV3QuadraticBezierCurve,tr as ellipseMovement,So as ellipseMovementAfterMouse,Et as getAnglesDistance,j as getAnglesSub,W as getArithmeticMean,ii as getCircleCircumference,Fo as getColorsDelta,ci as getEllipseCircumference,Un as getLinearEquationBy2Points,hi as getMedian,bi as getMode,V as getRandom,Bn as getRandomBoolean,No as getRandomGrayscaleHSLColor,St as getRandomHSLColor,Eo as getRandomHSLColorWithHue,Ao as getRandomHSLColorWithLightness,qo as getRandomHSLColorWithSaturation,Co as getRandomHSLColorWithinRanges,$o as getRandomHexColor,Qt as getRandomInt,Tn as getRandomItemFromArray,Lo as getRandomRGBColor,Oo as getShiftedHue,jo as getShiftedLightness,ko as getShiftedSaturation,ui as getSquareInCircleSide,Ht as getStandardDeviation,L as getV2Angle,vr as getV2AngleBetween,lr as getV2AngleInEllipse,gr as getV3AngleBetween,$t as getVNAngleBetween,cr as getVariance,Zo as guid,Do as hexToRgb,ir as hslToHex,or as hslToRgb,ue as identity2,xe as identity3,ae as identity4,me as identityN,Sr as isAngleBetween,si as isAngleInCircleArc,U as isClockwise,B as isNumber,He as isSingularMatrix,Go as labToRgb,q as linearEquation,Wn as linearEquationSystem2,Kn as linearEquationSystem3,Jn as linearEquationSystemN,wo as lissajousCurve,Mt as m2Adjugate,he as m2AppendRow,ut as m2DeepCopy,pt as m2Determinant,At as m2DivideScalar,bt as m2Inverse,Jr as m2MulScalar,ye as m2PrependRow,an as m2ReflectionOrigin,mn as m2ReflectionOriginH,hn as m2ReflectionX,bn as m2ReflectionXH,Vn as m2ReflectionY,yn as m2ReflectionYH,Mn as m2ReflectionYmX,ee as m2Reset,De as m2RotateAroundPointH,Ct as m2Rotation,Xt as m2RotationAroundPointH,yt as m2RotationH,jt as m2Scale,We as m2ScaleAtPointH,Ot as m2ScaleAtPointHMatrix,kt as m2ScaleH,Pe as m2ScaleX,tn as m2ScaleXH,un as m2ScaleY,xn as m2ScaleYH,wn as m2ShearingX,Rn as m2ShearingY,Wr as m2Sub,Zr as m2Sum,Ee as m2ToCSS,Ce as m2Translation,G as m2TranslationH,te as m2Transpose,qe as m2hToCSS,Ae as m2hToCSS3d,oe as m2x2,ze as m3Adjugate,be as m3AppendRow,xt as m3DeepCopy,we as m3Determinant,Pr as m3DivideScalar,Vt as m3Inverse,Ur as m3MulScalar,le as m3PrependRow,fn as m3ReflectionOrigin,pn as m3ReflectionOriginH,gn as m3ReflectionXY,Sn as m3ReflectionXYH,In as m3ReflectionXZ,vn as m3ReflectionXZH,ln as m3ReflectionYZ,dn as m3ReflectionYZH,ne as m3Reset,Yt as m3RotationX,je as m3RotationXH,Dt as m3RotationY,Fe as m3RotationYH,Gt as m3RotationZ,Ze as m3RotationZH,Ft as m3Scale,Je as m3ScaleH,rn as m3ScaleX,en as m3ScaleXH,nn as m3ScaleY,on as m3ScaleYH,cn as m3ScaleZ,sn as m3ScaleZH,Kr as m3Sub,_r as m3Sum,Xe as m3Translation,Ye as m3TranslationH,re as m3Transpose,Ne as m3hToCSS3d,ie as m3x3,ce as m4x4,ht as mAdjugate,fe as mAppendCol,Me as mAppendRow,d as mDeepCopy,ve as mDelFirstColumn,Ie as mDelFirstRow,at as mDelLastColumn,de as mDelLastRow,D as mDeterminant,F as mDivideScalar,Re as mEqual,Se as mGetColumn,ge as mGetFirstColumn,mt as mGetLastColumn,Q as mInverse,ft as mMinor,E as mMul,ct as mMulScalar,b as mMulVector,se as mNxM,pe as mPrependCol,Ve as mPrependRow,st as mReset,it as mSub,ot as mSum,Y as mTranspose,Ii as mlNormalize,ur as mlStandardizeArray,vi as mlStandardizeTestData,sr as mlStandardizeValue,l as mod,mi as naturalNumbersSequenceSum,_o as newId,Rr as percentToAngle,Mr as polarToCartesian,dr as radiansToDegrees,Uo as rectCollide,Yo as rgbToHex,Xo as rgbToHsl,gt as rgbToLab,s as setDecimalPlaces,J as setV2Angle,Ro as sineWaveMovement,$n as stringToNumber,Gr as v2,Vo as v2CubicBezierBBox,_t as v2CubicBezierCurve,Ut as v2CubicBezierCurveExtrema,ho as v2CubicBezierCurveNormal,Kt as v2CubicBezierCurveTangent,Cr as v2Distance,Er as v2DivideScalar,tt as v2DotProduct,kr as v2FromPolarCoords,nt as v2GetNormal,P as v2Length,$r as v2MulScalar,$ as v2Normalize,bo as v2QuadraticBezierBBox,Zt as v2QuadraticBezierCurve,Jt as v2QuadraticBezierCurveExtrema,Mo as v2QuadraticBezierCurveNormal,Wt as v2QuadraticBezierCurveTangent,Ge as v2Rotate,Oe as v2RotateH,Ke as v2Scale,qt as v2SetLength,w as v2Sub,Br as v2Sum,Or as v3,Dr as v3CrossProduct,mo as v3CubicBezierCurve,po as v3CubicBezierCurveTangent,Xr as v3Distance,qr as v3DivideScalar,Yr as v3DotProduct,Ar as v3Length,k as v3MulScalar,g as v3Normalize,ao as v3QuadraticBezierCurve,fo as v3QuadraticBezierCurveTangent,ke as v3RotateX,Qe as v3RotateY,_e as v3RotateZ,Ue as v3Scale,Lr as v3Sub,Tr as v3Sum,jr as v4,Nr as vDistance,X as vDivideScalar,S as vDotProduct,et as vEqual,z as vLength,C as vMulScalar,rt as vN,T as vNormalize,I as vSub,N 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 c1396df0..8c2bbb69 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"], - "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)\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 * 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 */\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 - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\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';\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalize = (data: number[], decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n const min = Math.min(...copy);\n const max = Math.max(...copy);\n\n const diff = max - min;\n if(diff === 0) return [0];\n\n for(let i=0; i {\n const copy = [...data];\n const mean = getArithmeticMean(copy) ?? 0;\n const stdDev = getStandardDeviation(copy, decimalPlaces);\n return copy.map(val => (val - mean) / stdDev);\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,EAAGE,CAAC,GAAK,KAAK,IAAID,EAAGE,CAAC,EAI7BE,EAA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AAK,QAAU,EAAG,OAE9B,IAAMkB,EAAOnB,EAAkBC,CAAI,EACnC,GAAGkB,IAAS,OAAW,OAEvB,IAAMhB,EAAMF,EAAK,OAAO,CAACG,EAAKC,IAAQD,EAAQgB,EAAAf,EAAMc,EAAS,GAAI,CAAC,EAElE,OAAOb,EAAiBH,EAAMF,EAAK,OAAQC,CAAa,CAC5D,EAEamB,GAAuB,CAACpB,EAAgBC,EAAgB,MAAa,CA3FlF,IAAAoB,EA4FI,IAAMC,GAAWD,EAAAJ,GAAYjB,CAAI,IAAhB,KAAAqB,EAAqB,EACtC,OAAOhB,EAAiB,KAAK,KAAKiB,CAAQ,EAAGrB,CAAa,CAC9D,ECxFO,IAAMsB,GAAc,CAACC,EAAgBC,EAAgB,MAAuB,CAC/E,IAAMC,EAAO,CAAC,GAAGF,CAAI,EAEfG,EAAM,KAAK,IAAI,GAAGD,CAAI,EAGtBE,EAFM,KAAK,IAAI,GAAGF,CAAI,EAETC,EACnB,GAAGC,IAAS,EAAG,MAAO,CAAC,CAAC,EAExB,QAAQC,EAAE,EAAGA,EAAEH,EAAK,OAAQG,IACxBH,EAAKG,GAAKC,GAAkBJ,EAAKG,GAAKF,GAAOC,EAAMH,CAAa,EAGpE,OAAOC,CACX,EAKaK,GAAgB,CAACP,EAAgBC,EAAgB,MAAuB,CAzBrF,IAAAO,EA0BI,IAAMN,EAAO,CAAC,GAAGF,CAAI,EACfS,GAAOD,EAAAE,EAAkBR,CAAI,IAAtB,KAAAM,EAA2B,EAClCG,EAASC,GAAqBV,EAAMD,CAAa,EACvD,OAAOC,EAAK,IAAIW,IAAQA,EAAMJ,GAAQE,CAAM,CAChD", - "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", "getMedian", "copy", "num1", "num2", "mid", "getMode", "frequencyMap", "num", "maxFrequency", "modes", "frequency", "getVariance", "mean", "__pow", "getStandardDeviation", "_a", "variance", "mlNormalize", "data", "decimalPlaces", "copy", "min", "diff", "i", "setDecimalPlaces", "mlStandardize", "_a", "mean", "getArithmeticMean", "stdDev", "getStandardDeviation", "val"] + "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)\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 * 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 */\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 - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\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 { IMlStandardizeResult } from '../types';\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalize = (data: number[], decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n const min = Math.min(...copy);\n const max = Math.max(...copy);\n\n const diff = max - min;\n if(diff === 0) return [0];\n\n for(let i=0; i {\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),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,EAAKG,GAAKF,GAAOC,EAAMH,CAAa,EAGpE,OAAOC,CACX,EAKaK,GAAqB,CAACC,EAAeC,EAAcC,EAAgBT,EAAgB,MACzFS,IAAW,EAAU,EACjBJ,GAAkBE,EAAQC,GAAQC,EAAQT,CAAa,EAMrDU,GAAqB,CAACX,EAAgBS,EAAcC,EAAgBT,EAAgB,MACtF,CAAC,GAAGD,CAAI,EAAE,IAAIQ,GAASD,GAAmBC,EAAOC,EAAMC,EAAQT,CAAa,CAAC,EAG3EW,GAAwB,CAACZ,EAAgBC,EAAgB,MAAmC,CAtCzG,IAAAY,EAuCI,IAAMJ,GAAOI,EAAAC,EAAkBd,CAAI,IAAtB,KAAAa,EAA2B,EAClCH,EAASK,GAAqBf,CAAI,EAClCgB,EAAQL,GAAmBX,EAAMS,EAAMC,EAAQT,CAAa,EAElE,MAAO,CACH,KAAMK,EAAiBG,EAAMR,CAAa,EAC1C,OAAQK,EAAiBI,EAAQT,CAAa,EAC9C,KAAMe,CACV,CACJ", + "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", "getMedian", "copy", "num1", "num2", "mid", "getMode", "frequencyMap", "num", "maxFrequency", "modes", "frequency", "getVariance", "mean", "__pow", "getStandardDeviation", "_a", "variance", "mlNormalize", "data", "decimalPlaces", "copy", "min", "diff", "i", "setDecimalPlaces", "mlStandardizeValue", "value", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "_data"] } diff --git a/dist/mz-math.min.js b/dist/mz-math.min.js index 0832c9a8..f5071605 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 Kt=Object.defineProperty;var Wt=Object.getOwnPropertySymbols;var Br=Object.prototype.hasOwnProperty,Tr=Object.prototype.propertyIsEnumerable;var y=Math.pow,_t=(t,r,e)=>r in t?Kt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,h=(t,r)=>{for(var e in r||(r={}))Br.call(r,e)&&_t(t,e,r[e]);if(Wt)for(var e of Wt(r))Tr.call(r,e)&&_t(t,e,r[e]);return t};var b=(t,r)=>{for(var e in r)Kt(t,e,{get:r[e],enumerable:!0})};var ct={};b(ct,{v2:()=>Ur,v2Distance:()=>Wr,v2DivideScalar:()=>kr,v2DotProduct:()=>et,v2FromPolarCoords:()=>re,v2GetNormal:()=>it,v2Length:()=>rt,v2MulScalar:()=>jr,v2Normalize:()=>E,v2SetLength:()=>Pt,v2Sub:()=>z,v2Sum:()=>Gr,v3:()=>Pr,v3CrossProduct:()=>Jr,v3Distance:()=>_r,v3DivideScalar:()=>Fr,v3DotProduct:()=>Kr,v3Length:()=>Qr,v3MulScalar:()=>Q,v3Normalize:()=>S,v3Sub:()=>Or,v3Sum:()=>Dr,v4:()=>te,vDistance:()=>Zr,vDivideScalar:()=>Y,vDotProduct:()=>R,vEqual:()=>ot,vLength:()=>H,vMulScalar:()=>X,vN:()=>nt,vNormalize:()=>L,vSub:()=>g,vSum:()=>C});var K={};b(K,{setDecimalPlaces:()=>s});var s=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=y(10,r);return Math.round(t*e)/e};var tt={};b(tt,{degreesToRadians:()=>Ar,getAnglesDistance:()=>Ut,getAnglesSub:()=>F,getV2Angle:()=>$,getV2AngleBetween:()=>Nr,getV2AngleInEllipse:()=>Er,getV3AngleBetween:()=>Cr,getVNAngleBetween:()=>Jt,isAngleBetween:()=>Xr,isClockwise:()=>P,percentToAngle:()=>Yr,radiansToDegrees:()=>qr,setV2Angle:()=>U});var J={};b(J,{convertRange:()=>k,doRangesOverlap:()=>Lr,isNumber:()=>T,mod:()=>d,polarToCartesian:()=>$r});var d=(t,r)=>(t%r+r)%r,k=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Lr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),T=t=>!isNaN(parseFloat(t))&&isFinite(t),$r=(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,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return s(e,r)},Er=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return s(n,e)},U=(t,r,e=1/0)=>{let n=rt(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},qr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},Ar=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},Jt=(t,r,e=1/0)=>{let n=L(t),o=L(r),i=R(n,o),c=Math.acos(i);return s(c,e)},Nr=(t,r,e=1/0)=>{let n=g(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},Cr=(t,r,e=1/0)=>Jt(t,r,e),Xr=(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},P=(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)},Ut=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Ut(r,e,n);return P(r,e,n)?d(n+t*o/100,360):d(n-t*o/100,360)};var C=(t,r,e=1/0)=>{let n=[];for(let o=0;oC(t,r,e),Dr=(t,r,e=1/0)=>C(t,r,e),g=(t,r,e=1/0)=>{let n=[];for(let o=0;og(t,r,e),Or=(t,r,e=1/0)=>g(t,r,e),X=(t,r,e=1/0)=>{let n=[];for(let o=0;oX(t,r,e),Q=(t,r,e=1/0)=>X(t,r,e),Y=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oY(t,r,e),Fr=(t,r,e=1/0)=>Y(t,r,e),H=(t,r=1/0)=>{let e=0;for(let n=0;nH(t,r),Qr=(t,r=1/0)=>H(t,r),Pt=(t,r,e=1/0)=>{let n=$(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Zr=(t,r,e=1/0)=>{let n=g(t,r);return H(n,e)},Wr=(t,r,e=1/0)=>{let n=g(t,r);return H(n,e)},_r=(t,r,e=1/0)=>{let n=g(t,r);return H(n,e)},L=(t,r=1/0)=>{let e=H(t),n=[];for(let o=0;oL(t,r),S=(t,r=1/0)=>L(t,r),R=(t,r,e=1/0)=>{let n=0;for(let o=0;oR(t,r,e),Kr=(t,r,e=1/0)=>R(t,r,e),Jr=(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)],Ur=(t=0)=>[t,t],Pr=(t=0)=>[t,t,t],te=(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=Pt(e,t),U(e,r)},ot=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=z(r,t);return[-s(n[1],e),s(n[0],e)]};var It={};b(It,{identity2:()=>Ve,identity3:()=>le,identity4:()=>ye,identityN:()=>de,isSingularMatrix:()=>Xe,m2Adjugate:()=>Vt,m2AppendRow:()=>Se,m2DeepCopy:()=>at,m2Determinant:()=>bt,m2DivideScalar:()=>tr,m2Inverse:()=>yt,m2MulScalar:()=>ce,m2PrependRow:()=>ze,m2Reset:()=>ae,m2Sub:()=>oe,m2Sum:()=>ee,m2Transpose:()=>xe,m2x2:()=>pe,m3Adjugate:()=>Ce,m3AppendRow:()=>we,m3DeepCopy:()=>ft,m3Determinant:()=>Ne,m3DivideScalar:()=>ue,m3Inverse:()=>dt,m3MulScalar:()=>se,m3PrependRow:()=>He,m3Reset:()=>fe,m3Sub:()=>ie,m3Sum:()=>ne,m3Transpose:()=>me,m3x3:()=>Me,m4x4:()=>he,mAdjugate:()=>lt,mAppendCol:()=>Ie,mAppendRow:()=>ge,mDeepCopy:()=>I,mDelFirstColumn:()=>Le,mDelFirstRow:()=>Te,mDelLastColumn:()=>pt,mDelLastRow:()=>Be,mDeterminant:()=>D,mDivideScalar:()=>Z,mEqual:()=>qe,mGetColumn:()=>Ee,mGetFirstColumn:()=>$e,mGetLastColumn:()=>Mt,mInverse:()=>W,mMinor:()=>ht,mMul:()=>q,mMulScalar:()=>xt,mMulVector:()=>V,mNxM:()=>be,mPrependCol:()=>ve,mPrependRow:()=>Re,mReset:()=>mt,mSub:()=>ut,mSum:()=>st,mTranspose:()=>G});var st=(t,r,e=1/0)=>{let n=[];for(let o=0;ost(t,r,e),ne=(t,r,e=1/0)=>st(t,r,e),ut=(t,r,e=1/0)=>{let n=[];for(let o=0;out(t,r,e),ie=(t,r,e=1/0)=>ut(t,r,e),xt=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(X(o,r,e));return n},ce=(t,r,e=1/0)=>xt(t,r,e),se=(t,r,e=1/0)=>xt(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(Y(o,r,e));return n},tr=(t,r,e=1/0)=>Z(t,r,e),ue=(t,r,e=1/0)=>Z(t,r,e),G=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;oG(t),me=t=>G(t),mt=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nmt(t,r),fe=(t,r=0)=>mt(t,r),pe=(t=0)=>[[t,t],[t,t]],Me=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],he=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],be=(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]],le=()=>[[1,0,0],[0,1,0],[0,0,1]],ye=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],de=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),Ie=(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},Se=(t,r)=>{let e=at(t);return e.push(r),e},we=(t,r)=>{let e=ft(t);return e.push(r),e},Re=(t,r)=>{let e=I(t);return e.unshift(r),e},ze=(t,r)=>{let e=at(t);return e.unshift(r),e},He=(t,r)=>{let e=ft(t);return e.unshift(r),e},Be=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},Te=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=Ae(t,r,e);return D(o)},D=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 bt(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]},Ne=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return D(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]]]},Ce=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 D(t)===0},yt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=bt(t);if(e===0)return null;let n=Vt(t);return n===null?null:tr(n,e,r)},dt=(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=D(t),o=lt(t);return o===null?null:Z(o,n,r)};var gt={};b(gt,{m2ReflectionOrigin:()=>bn,m2ReflectionOriginH:()=>Vn,m2ReflectionX:()=>In,m2ReflectionXH:()=>vn,m2ReflectionY:()=>gn,m2ReflectionYH:()=>Sn,m2ReflectionYmX:()=>dn,m2RotateAroundPointH:()=>Qe,m2Rotation:()=>rr,m2RotationAroundPointH:()=>er,m2RotationH:()=>vt,m2Scale:()=>sr,m2ScaleAtPointH:()=>rn,m2ScaleAtPointHMatrix:()=>cr,m2ScaleH:()=>ur,m2ScaleX:()=>cn,m2ScaleXH:()=>sn,m2ScaleY:()=>Mn,m2ScaleYH:()=>hn,m2ShearingX:()=>$n,m2ShearingY:()=>Ln,m2ToCSS:()=>Ye,m2Translation:()=>je,m2TranslationH:()=>O,m2hToCSS:()=>Ge,m2hToCSS3d:()=>De,m3ReflectionOrigin:()=>ln,m3ReflectionOriginH:()=>yn,m3ReflectionXY:()=>Bn,m3ReflectionXYH:()=>Tn,m3ReflectionXZ:()=>zn,m3ReflectionXZH:()=>Hn,m3ReflectionYZ:()=>wn,m3ReflectionYZH:()=>Rn,m3RotationX:()=>nr,m3RotationXH:()=>_e,m3RotationY:()=>or,m3RotationYH:()=>Je,m3RotationZ:()=>ir,m3RotationZH:()=>Pe,m3Scale:()=>xr,m3ScaleH:()=>nn,m3ScaleX:()=>un,m3ScaleXH:()=>xn,m3ScaleY:()=>mn,m3ScaleYH:()=>an,m3ScaleZ:()=>fn,m3ScaleZH:()=>pn,m3Translation:()=>ke,m3TranslationH:()=>Fe,m3hToCSS3d:()=>Oe,v2Rotate:()=>Ze,v2RotateH:()=>We,v2Scale:()=>en,v3RotateX:()=>Ke,v3RotateY:()=>Ue,v3RotateZ:()=>tn,v3Scale:()=>on});var Ye=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)`},Ge=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})`},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`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${c}, 0, 1)`},Oe=t=>`matrix3d( +(()=>{var Kt=Object.defineProperty;var Wt=Object.getOwnPropertySymbols;var Lr=Object.prototype.hasOwnProperty,$r=Object.prototype.propertyIsEnumerable;var y=Math.pow,_t=(t,r,e)=>r in t?Kt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,h=(t,r)=>{for(var e in r||(r={}))Lr.call(r,e)&&_t(t,e,r[e]);if(Wt)for(var e of Wt(r))$r.call(r,e)&&_t(t,e,r[e]);return t};var b=(t,r)=>{for(var e in r)Kt(t,e,{get:r[e],enumerable:!0})};var ct={};b(ct,{v2:()=>te,v2Distance:()=>Kr,v2DivideScalar:()=>Qr,v2DotProduct:()=>et,v2FromPolarCoords:()=>ne,v2GetNormal:()=>it,v2Length:()=>rt,v2MulScalar:()=>Fr,v2Normalize:()=>E,v2SetLength:()=>Pt,v2Sub:()=>z,v2Sum:()=>Or,v3:()=>re,v3CrossProduct:()=>Pr,v3Distance:()=>Jr,v3DivideScalar:()=>Zr,v3DotProduct:()=>Ur,v3Length:()=>Wr,v3MulScalar:()=>Q,v3Normalize:()=>S,v3Sub:()=>kr,v3Sum:()=>jr,v4:()=>ee,vDistance:()=>_r,vDivideScalar:()=>Y,vDotProduct:()=>R,vEqual:()=>ot,vLength:()=>H,vMulScalar:()=>X,vN:()=>nt,vNormalize:()=>L,vSub:()=>g,vSum:()=>C});var K={};b(K,{setDecimalPlaces:()=>s});var s=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=y(10,r);return Math.round(t*e)/e};var tt={};b(tt,{degreesToRadians:()=>Cr,getAnglesDistance:()=>Ut,getAnglesSub:()=>F,getV2Angle:()=>$,getV2AngleBetween:()=>Xr,getV2AngleInEllipse:()=>Ar,getV3AngleBetween:()=>Yr,getVNAngleBetween:()=>Jt,isAngleBetween:()=>Dr,isClockwise:()=>P,percentToAngle:()=>Gr,radiansToDegrees:()=>Nr,setV2Angle:()=>U});var J={};b(J,{convertRange:()=>k,doRangesOverlap:()=>Er,isNumber:()=>T,mod:()=>d,polarToCartesian:()=>qr});var d=(t,r)=>(t%r+r)%r,k=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Er=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),T=t=>!isNaN(parseFloat(t))&&isFinite(t),qr=(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,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return s(e,r)},Ar=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return s(n,e)},U=(t,r,e=1/0)=>{let n=rt(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},Nr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},Cr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},Jt=(t,r,e=1/0)=>{let n=L(t),o=L(r),i=R(n,o),c=Math.acos(i);return s(c,e)},Xr=(t,r,e=1/0)=>{let n=g(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},Yr=(t,r,e=1/0)=>Jt(t,r,e),Dr=(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},P=(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)},Ut=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Ut(r,e,n);return P(r,e,n)?d(n+t*o/100,360):d(n-t*o/100,360)};var C=(t,r,e=1/0)=>{let n=[];for(let o=0;oC(t,r,e),jr=(t,r,e=1/0)=>C(t,r,e),g=(t,r,e=1/0)=>{let n=[];for(let o=0;og(t,r,e),kr=(t,r,e=1/0)=>g(t,r,e),X=(t,r,e=1/0)=>{let n=[];for(let o=0;oX(t,r,e),Q=(t,r,e=1/0)=>X(t,r,e),Y=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oY(t,r,e),Zr=(t,r,e=1/0)=>Y(t,r,e),H=(t,r=1/0)=>{let e=0;for(let n=0;nH(t,r),Wr=(t,r=1/0)=>H(t,r),Pt=(t,r,e=1/0)=>{let n=$(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},_r=(t,r,e=1/0)=>{let n=g(t,r);return H(n,e)},Kr=(t,r,e=1/0)=>{let n=g(t,r);return H(n,e)},Jr=(t,r,e=1/0)=>{let n=g(t,r);return H(n,e)},L=(t,r=1/0)=>{let e=H(t),n=[];for(let o=0;oL(t,r),S=(t,r=1/0)=>L(t,r),R=(t,r,e=1/0)=>{let n=0;for(let o=0;oR(t,r,e),Ur=(t,r,e=1/0)=>R(t,r,e),Pr=(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)],te=(t=0)=>[t,t],re=(t=0)=>[t,t,t],ee=(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=Pt(e,t),U(e,r)},ot=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=z(r,t);return[-s(n[1],e),s(n[0],e)]};var It={};b(It,{identity2:()=>ye,identity3:()=>de,identity4:()=>Ie,identityN:()=>ve,isSingularMatrix:()=>De,m2Adjugate:()=>Vt,m2AppendRow:()=>Re,m2DeepCopy:()=>at,m2Determinant:()=>bt,m2DivideScalar:()=>tr,m2Inverse:()=>yt,m2MulScalar:()=>ue,m2PrependRow:()=>Be,m2Reset:()=>pe,m2Sub:()=>ce,m2Sum:()=>oe,m2Transpose:()=>ae,m2x2:()=>he,m3Adjugate:()=>Ye,m3AppendRow:()=>ze,m3DeepCopy:()=>ft,m3Determinant:()=>Xe,m3DivideScalar:()=>me,m3Inverse:()=>dt,m3MulScalar:()=>xe,m3PrependRow:()=>Te,m3Reset:()=>Me,m3Sub:()=>se,m3Sum:()=>ie,m3Transpose:()=>fe,m3x3:()=>be,m4x4:()=>Ve,mAdjugate:()=>lt,mAppendCol:()=>ge,mAppendRow:()=>we,mDeepCopy:()=>I,mDelFirstColumn:()=>Ee,mDelFirstRow:()=>$e,mDelLastColumn:()=>pt,mDelLastRow:()=>Le,mDeterminant:()=>G,mDivideScalar:()=>Z,mEqual:()=>Ne,mGetColumn:()=>Ae,mGetFirstColumn:()=>qe,mGetLastColumn:()=>Mt,mInverse:()=>W,mMinor:()=>ht,mMul:()=>q,mMulScalar:()=>xt,mMulVector:()=>V,mNxM:()=>le,mPrependCol:()=>Se,mPrependRow:()=>He,mReset:()=>mt,mSub:()=>ut,mSum:()=>st,mTranspose:()=>D});var st=(t,r,e=1/0)=>{let n=[];for(let o=0;ost(t,r,e),ie=(t,r,e=1/0)=>st(t,r,e),ut=(t,r,e=1/0)=>{let n=[];for(let o=0;out(t,r,e),se=(t,r,e=1/0)=>ut(t,r,e),xt=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(X(o,r,e));return n},ue=(t,r,e=1/0)=>xt(t,r,e),xe=(t,r,e=1/0)=>xt(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(Y(o,r,e));return n},tr=(t,r,e=1/0)=>Z(t,r,e),me=(t,r,e=1/0)=>Z(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),fe=t=>D(t),mt=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nmt(t,r),Me=(t,r=0)=>mt(t,r),he=(t=0)=>[[t,t],[t,t]],be=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],Ve=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],le=(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]],de=()=>[[1,0,0],[0,1,0],[0,0,1]],Ie=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],ve=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),ge=(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},Re=(t,r)=>{let e=at(t);return e.push(r),e},ze=(t,r)=>{let e=ft(t);return e.push(r),e},He=(t,r)=>{let e=I(t);return e.unshift(r),e},Be=(t,r)=>{let e=at(t);return e.unshift(r),e},Te=(t,r)=>{let e=ft(t);return e.unshift(r),e},Le=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},$e=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=Ce(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 bt(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]},Xe=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]]]},Ye=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},yt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=bt(t);if(e===0)return null;let n=Vt(t);return n===null?null:tr(n,e,r)},dt=(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=G(t),o=lt(t);return o===null?null:Z(o,n,r)};var gt={};b(gt,{m2ReflectionOrigin:()=>ln,m2ReflectionOriginH:()=>yn,m2ReflectionX:()=>gn,m2ReflectionXH:()=>Sn,m2ReflectionY:()=>wn,m2ReflectionYH:()=>Rn,m2ReflectionYmX:()=>vn,m2RotateAroundPointH:()=>We,m2Rotation:()=>rr,m2RotationAroundPointH:()=>er,m2RotationH:()=>vt,m2Scale:()=>sr,m2ScaleAtPointH:()=>nn,m2ScaleAtPointHMatrix:()=>cr,m2ScaleH:()=>ur,m2ScaleX:()=>un,m2ScaleXH:()=>xn,m2ScaleY:()=>bn,m2ScaleYH:()=>Vn,m2ShearingX:()=>qn,m2ShearingY:()=>En,m2ToCSS:()=>Ge,m2Translation:()=>Fe,m2TranslationH:()=>O,m2hToCSS:()=>Oe,m2hToCSS3d:()=>je,m3ReflectionOrigin:()=>dn,m3ReflectionOriginH:()=>In,m3ReflectionXY:()=>Ln,m3ReflectionXYH:()=>$n,m3ReflectionXZ:()=>Bn,m3ReflectionXZH:()=>Tn,m3ReflectionYZ:()=>zn,m3ReflectionYZH:()=>Hn,m3RotationX:()=>nr,m3RotationXH:()=>Je,m3RotationY:()=>or,m3RotationYH:()=>Pe,m3RotationZ:()=>ir,m3RotationZH:()=>rn,m3Scale:()=>xr,m3ScaleH:()=>cn,m3ScaleX:()=>mn,m3ScaleXH:()=>an,m3ScaleY:()=>fn,m3ScaleYH:()=>pn,m3ScaleZ:()=>Mn,m3ScaleZH:()=>hn,m3Translation:()=>Qe,m3TranslationH:()=>Ze,m3hToCSS3d:()=>ke,v2Rotate:()=>_e,v2RotateH:()=>Ke,v2Scale:()=>on,v3RotateX:()=>Ue,v3RotateY:()=>tn,v3RotateZ:()=>en,v3Scale:()=>sn});var Ge=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)`},Oe=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})`},je=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)`},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],[s(t[0],r),s(t[1],r)]],ke=(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)]],O=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],Fe=(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]],rr=(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]]},vt=(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]]},er=(t,r,e=!0,n=1/0)=>{let o=O(r,n),i=vt(t,e,n),c=O(Q(r,-1),n),u=q(o,i);return q(u,c)},Qe=(t,r,e,n=!0,o=1/0)=>{let i=er(t,r,n,o);return V(i,e)},Ze=(t,r,e=!0,n=1/0)=>{let o=E(r);return V(rr(t,e,n),o)},We=(t,r,e=!0,n=1/0)=>{let o=S(r);return V(vt(t,e,n),o)},nr=(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]]},Ke=(t,r,e=!0,n=1/0)=>{let o=S(r);return V(nr(t,e,n),o)},or=(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]]},Je=(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=S(r);return V(or(t,e,n),o)},ir=(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]]},Pe=(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]]},tn=(t,r,e=!0,n=1/0)=>{let o=S(r);return V(ir(t,e,n),o)},cr=(t,r,e=1/0)=>{let n=O(r,e),o=ur(t),i=O(Q(r,-1),e),c=q(n,o);return q(c,i)},rn=(t,r,e,n=1/0)=>{let o=cr(t,r,n);return V(o,e)},sr=t=>[[t[0],0],[0,t[1]]],en=(t,r)=>V(sr(t),r),ur=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],xr=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],nn=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],on=(t,r)=>V(xr(t),r),cn=t=>[[t,0],[0,1]],sn=t=>[[t,0,0],[0,1,0],[0,0,1]],un=t=>[[t,0,0],[0,1,0],[0,0,1]],xn=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],mn=t=>[[1,0,0],[0,t,0],[0,0,1]],an=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],fn=t=>[[1,0,0],[0,1,0],[0,0,t]],pn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],Mn=t=>[[1,0],[0,t]],hn=t=>[[1,0,0],[0,t,0],[0,0,1]],bn=()=>[[-1,0],[0,-1]],Vn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],ln=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],yn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],dn=()=>[[0,-1],[-1,0]],In=()=>[[1,0],[0,-1]],vn=()=>[[1,0,0],[0,-1,0],[0,0,1]],gn=()=>[[-1,0],[0,1]],Sn=()=>[[-1,0,0],[0,1,0],[0,0,1]],wn=()=>[[-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]],Hn=()=>[[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]],Tn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Ln=t=>[[1,t],[0,1]],$n=t=>[[1,0],[t,1]];var St={};b(St,{getRandom:()=>l,getRandomBoolean:()=>En,getRandomInt:()=>mr,getRandomItemFromArray:()=>qn});var l=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),mr=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),En=()=>Math.random()<.5,qn=t=>{let r=mr(0,t.length-1);return t[r]};var wt={};b(wt,{stringToNumber:()=>An});var An=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Et={};b(Et,{v2CubicBezierBBox:()=>eo,v2CubicBezierCurve:()=>fr,v2CubicBezierCurveExtrema:()=>br,v2CubicBezierCurveNormal:()=>to,v2CubicBezierCurveTangent:()=>Mr,v2QuadraticBezierBBox:()=>ro,v2QuadraticBezierCurve:()=>ar,v2QuadraticBezierCurveExtrema:()=>hr,v2QuadraticBezierCurveNormal:()=>Pn,v2QuadraticBezierCurveTangent:()=>pr,v3CubicBezierCurve:()=>Kn,v3CubicBezierCurveTangent:()=>Un,v3QuadraticBezierCurve:()=>_n,v3QuadraticBezierCurveTangent:()=>Jn});var Tt={};b(Tt,{dxArcCos:()=>On,dxArcCot:()=>kn,dxArcSin:()=>Dn,dxArcTan:()=>jn,dxCos:()=>Xn,dxCot:()=>Gn,dxPolynomial:()=>Nn,dxSin:()=>Cn,dxTan:()=>Yn,dxV2CubicBezierCurve:()=>Ht,dxV2QuadraticBezierCurve:()=>Rt,dxV3CubicBezierCurve:()=>Bt,dxV3QuadraticBezierCurve:()=>zt});var Nn=(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)},Rt=(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)]},zt=(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)]},Ht=(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)]},Bt=(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)]},Cn=(t,r=1/0)=>s(Math.cos(t),r),Xn=(t,r=1/0)=>s(-Math.sin(t),r),Yn=(t,r=1/0)=>s(1/y(Math.cos(t),2),r),Gn=(t,r=1/0)=>s(-1/y(Math.sin(t),2),r),Dn=(t,r=1/0)=>s(1/Math.sqrt(1-y(t,2)),r),On=(t,r=1/0)=>s(-1/Math.sqrt(1-y(t,2)),r),jn=(t,r=1/0)=>s(1/(1+y(t,2)),r),kn=(t,r=1/0)=>s(-1/(1+y(t,2)),r);var Lt={};b(Lt,{getLinearEquationBy2Points:()=>Wn,linearEquation:()=>A,linearEquationSystem2:()=>Fn,linearEquationSystem3:()=>Qn,linearEquationSystemN:()=>Zn});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:s(i/e,r)},Fn=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=yt(n);if(o===null)return null;let i=[t[2],r[2]];return V(o,i,e)},Qn=(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=dt(o);if(i===null)return null;let c=[t[3],r[3],e[3]];return V(i,c,n)},Zn=(t,r=1/0)=>{if(t.length<=0)return null;let e=pt(t),n=W(e);if(n===null)return null;let o=Mt(t);return V(n,o,r)},Wn=(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 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 $t=(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 T(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 ar=(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)]},fr=(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)]},Kn=(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)]},pr=(t,r,e,n,o=1/0)=>{let i=Rt(t,r,e,n);return E(i,o)},Jn=(t,r,e,n,o=1/0)=>{let i=zt(t,r,e,n);return S(i,o)},Mr=(t,r,e,n,o,i=1/0)=>{let c=Ht(t,r,e,n,o);return E(c,i)},Un=(t,r,e,n,o,i=1/0)=>{let c=Bt(t,r,e,n,o);return S(c,i)},Pn=(t,r,e,n,o=1/0)=>{let i=pr(t,r,e,n,o);return[-i[1],i[0]]},to=(t,r,e,n,o,i=1/0)=>{let c=Mr(t,r,e,n,o,i);return[-c[1],c[0]]},hr=(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),x=2*t[1]-4*r[1]+2*e[1],m=-2*t[1]+2*r[1],p=A([x,m,0],n),a=[];return T(u)&&a.push(u),T(p)&&a.push(p),a},br=(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],M=$t(x,o).filter(v=>v>=0&&v<=1),w=$t(a,o).filter(v=>v>=0&&v<=1);return[...M,...w].length===2?[...M,...w]:null},ro=(t,r,e,n=1/0)=>{let o=hr(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=ar(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}},eo=(t,r,e,n,o=1/0)=>{let i=br(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=fr(f,t,r,e,n),a=p[0],M=p[1];c=Math.min(c,a!=null?a:1/0),x=Math.max(x,a!=null?a:-1/0),u=Math.min(u,M!=null?M:1/0),m=Math.max(m,M!=null?M:-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 qt={};b(qt,{circleMovement:()=>Vr,circleMovementAfterMouse:()=>no,ellipseMovement:()=>lr,ellipseMovementAfterMouse:()=>oo,lissajousCurve:()=>co,sineWaveMovement:()=>io});var Vr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),no=(t,r,e)=>{let n=z(t,r),o=$(n);return o=k(o,0,Math.PI*2,0,Math.PI),Vr(r,o,e)},lr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),oo=(t,r,e)=>{let n=z(t,r),o=$(n);return o=k(o,0,Math.PI*2,0,Math.PI),lr(r,o,e[0],e[1])},io=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},co=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Xt={};b(Xt,{getColorsDelta:()=>wo,getRandomGrayscaleHSLColor:()=>fo,getRandomHSLColor:()=>Ct,getRandomHSLColorWithHue:()=>xo,getRandomHSLColorWithLightness:()=>ao,getRandomHSLColorWithSaturation:()=>mo,getRandomHSLColorWithinRanges:()=>po,getRandomHexColor:()=>uo,getRandomRGBColor:()=>so,getShiftedHue:()=>vo,getShiftedLightness:()=>go,getShiftedSaturation:()=>So,hexToRgb:()=>yo,hslToHex:()=>Ir,hslToRgb:()=>dr,labToRgb:()=>Io,rgbToHex:()=>lo,rgbToHsl:()=>Vo,rgbToLab:()=>Nt});var so=()=>{let t=Ct();return dr(t)},uo=()=>{let t=Ct();return Ir(t)},Ct=()=>{let t=l(1,360),r=l(0,100),e=l(0,100);return[t,r,e]},xo=t=>{let r=l(0,100),e=l(0,100);return[t,r,e]},mo=t=>{let r=l(1,360),e=l(0,100);return[r,t,e]},ao=t=>{let r=l(1,360),e=l(0,100);return[r,e,t]},fo=()=>[0,0,l(0,100)],po=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let c=l(t,r),u=l(e,n),x=l(o,i);return[c,u,x]},Mo=t=>(t*=60,t<0&&(t+=360),t),ho=(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),bo=(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?yr(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),Vo=(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=yr(e,n,o,i,c),x=bo(e,n,o,i,c,u),m=ho(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)]},At=(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),dr=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let M=o*255;return[M,M,M]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,m=e-.333,f=At(i,c,u),p=At(i,c,x),a=At(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)]},Ir=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,M)=>(M<0&&(M+=1),M>1&&(M-=1),M<.16666666666666666?p+(a-p)*6*M:M<.5?a:M<.6666666666666666?p+(a-p)*(.6666666666666666-M)*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)}`},lo=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},yo=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]},Nt=(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)]},vo=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=d(e,360)),[e,t[1],t[2]]},go=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=d(e,100)),[t[0],t[1],e]},So=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},wo=(t,r,e=1/0)=>{let n=Nt(t,e),o=Nt(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,M=1+.015*x,w=i/1,N=f/a,v=p/M,j=w*w+N*N+v*v;return j<0?0:Math.sqrt(j)};var vr={};var Yt={};b(Yt,{guid:()=>Ro,newId:()=>zo});var Ro=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),zo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var Gt={};b(Gt,{circleCollide:()=>Bo,convexPolygonsCollide:()=>To,rectCollide:()=>Ho});var Ho=(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,Bo=(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},gr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...gr(t)),e.push(...gr(r));for(let n of e){let o=it(n[0],n[1]),i=Sr(t,o),c=Sr(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},Sr=(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 Dt={};b(Dt,{animate:()=>Lo});var Lo=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(),w()},f=()=>{c=!1},p=()=>{c=!0},a=B=>{e===void 0&&(e=B),o=B-e,c&&i!==B&&typeof t.callback=="function"&&t.callback(Zt()),o<=r?(i=B,n=window.requestAnimationFrame(a)):x()},M=(B,Hr)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(B,Hr)},w=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(M),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(a)},N=()=>o,v=()=>c,j=()=>e,Rr=()=>{if(!(r===1/0||o===void 0))return o*100/r},zr=()=>u,Zt=()=>({start:w,stop:x,pause:f,resume:p,restart:m,isAnimating:v,getElapsedTime:N,getStartTime:j,getPercent:Rr,getResizeObserver:zr});return Zt()};var Ot={};b(Ot,{getCircleCircumference:()=>$o,getEllipseCircumference:()=>Eo,getSquareInCircleSide:()=>Ao,isAngleInCircleArc:()=>qo});var $o=(t,r=1/0)=>s(2*Math.PI*t,r),Eo=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((y(t,2)+y(r,2))/2),e),qo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Ao=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var jt={};b(jt,{arithmeticSequenceSum:()=>Co,naturalNumbersSequenceSum:()=>No});var No=t=>t*(t+1)/2,Co=(t,r,e)=>t/2*(2*r+(t-1)*e);var Ft={};b(Ft,{getArithmeticMean:()=>_,getMedian:()=>Xo,getMode:()=>Yo,getStandardDeviation:()=>kt,getVariance:()=>wr});var _=(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)},Xo=(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)},Yo=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},wr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=_(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+y(i-e,2),0);return s(n/t.length,r)},kt=(t,r=1/0)=>{var n;let e=(n=wr(t))!=null?n:0;return s(Math.sqrt(e),r)};var Qt={};b(Qt,{mlNormalize:()=>Go,mlStandardize:()=>Do});var Go=(t,r=1/0)=>{let e=[...t],n=Math.min(...e),i=Math.max(...e)-n;if(i===0)return[0];for(let c=0;c{var i;let e=[...t],n=(i=_(e))!=null?i:0,o=kt(e,r);return e.map(c=>(c-n)/o)};var Oo=h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h({},ct),It),gt),K),tt),St),J),wt),Et),Lt),qt),Xt),vr),Yt),Tt),Gt),Dt),Ot),jt),Ft),Qt);window.mzMath=window.mzMath||Oo;})(); + )`,Fe=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Qe=(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)]],O=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],Ze=(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]],rr=(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]]},vt=(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]]},er=(t,r,e=!0,n=1/0)=>{let o=O(r,n),i=vt(t,e,n),c=O(Q(r,-1),n),u=q(o,i);return q(u,c)},We=(t,r,e,n=!0,o=1/0)=>{let i=er(t,r,n,o);return V(i,e)},_e=(t,r,e=!0,n=1/0)=>{let o=E(r);return V(rr(t,e,n),o)},Ke=(t,r,e=!0,n=1/0)=>{let o=S(r);return V(vt(t,e,n),o)},nr=(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]]},Je=(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]]},Ue=(t,r,e=!0,n=1/0)=>{let o=S(r);return V(nr(t,e,n),o)},or=(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]]},Pe=(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]]},tn=(t,r,e=!0,n=1/0)=>{let o=S(r);return V(or(t,e,n),o)},ir=(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]]},rn=(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]]},en=(t,r,e=!0,n=1/0)=>{let o=S(r);return V(ir(t,e,n),o)},cr=(t,r,e=1/0)=>{let n=O(r,e),o=ur(t),i=O(Q(r,-1),e),c=q(n,o);return q(c,i)},nn=(t,r,e,n=1/0)=>{let o=cr(t,r,n);return V(o,e)},sr=t=>[[t[0],0],[0,t[1]]],on=(t,r)=>V(sr(t),r),ur=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],xr=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],cn=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],sn=(t,r)=>V(xr(t),r),un=t=>[[t,0],[0,1]],xn=t=>[[t,0,0],[0,1,0],[0,0,1]],mn=t=>[[t,0,0],[0,1,0],[0,0,1]],an=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],fn=t=>[[1,0,0],[0,t,0],[0,0,1]],pn=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]],hn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],bn=t=>[[1,0],[0,t]],Vn=t=>[[1,0,0],[0,t,0],[0,0,1]],ln=()=>[[-1,0],[0,-1]],yn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],dn=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],In=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],vn=()=>[[0,-1],[-1,0]],gn=()=>[[1,0],[0,-1]],Sn=()=>[[1,0,0],[0,-1,0],[0,0,1]],wn=()=>[[-1,0],[0,1]],Rn=()=>[[-1,0,0],[0,1,0],[0,0,1]],zn=()=>[[-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]],Bn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Tn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[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]],En=t=>[[1,t],[0,1]],qn=t=>[[1,0],[t,1]];var St={};b(St,{getRandom:()=>l,getRandomBoolean:()=>An,getRandomInt:()=>mr,getRandomItemFromArray:()=>Nn});var l=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),mr=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),An=()=>Math.random()<.5,Nn=t=>{let r=mr(0,t.length-1);return t[r]};var wt={};b(wt,{stringToNumber:()=>Cn});var Cn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Et={};b(Et,{v2CubicBezierBBox:()=>oo,v2CubicBezierCurve:()=>fr,v2CubicBezierCurveExtrema:()=>br,v2CubicBezierCurveNormal:()=>eo,v2CubicBezierCurveTangent:()=>Mr,v2QuadraticBezierBBox:()=>no,v2QuadraticBezierCurve:()=>ar,v2QuadraticBezierCurveExtrema:()=>hr,v2QuadraticBezierCurveNormal:()=>ro,v2QuadraticBezierCurveTangent:()=>pr,v3CubicBezierCurve:()=>Un,v3CubicBezierCurveTangent:()=>to,v3QuadraticBezierCurve:()=>Jn,v3QuadraticBezierCurveTangent:()=>Pn});var Tt={};b(Tt,{dxArcCos:()=>kn,dxArcCot:()=>Qn,dxArcSin:()=>jn,dxArcTan:()=>Fn,dxCos:()=>Dn,dxCot:()=>On,dxPolynomial:()=>Xn,dxSin:()=>Yn,dxTan:()=>Gn,dxV2CubicBezierCurve:()=>Ht,dxV2QuadraticBezierCurve:()=>Rt,dxV3CubicBezierCurve:()=>Bt,dxV3QuadraticBezierCurve:()=>zt});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)},Rt=(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)]},zt=(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)]},Ht=(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)]},Bt=(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),Dn=(t,r=1/0)=>s(-Math.sin(t),r),Gn=(t,r=1/0)=>s(1/y(Math.cos(t),2),r),On=(t,r=1/0)=>s(-1/y(Math.sin(t),2),r),jn=(t,r=1/0)=>s(1/Math.sqrt(1-y(t,2)),r),kn=(t,r=1/0)=>s(-1/Math.sqrt(1-y(t,2)),r),Fn=(t,r=1/0)=>s(1/(1+y(t,2)),r),Qn=(t,r=1/0)=>s(-1/(1+y(t,2)),r);var Lt={};b(Lt,{getLinearEquationBy2Points:()=>Kn,linearEquation:()=>A,linearEquationSystem2:()=>Zn,linearEquationSystem3:()=>Wn,linearEquationSystemN:()=>_n});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:s(i/e,r)},Zn=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=yt(n);if(o===null)return null;let i=[t[2],r[2]];return V(o,i,e)},Wn=(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=dt(o);if(i===null)return null;let c=[t[3],r[3],e[3]];return V(i,c,n)},_n=(t,r=1/0)=>{if(t.length<=0)return null;let e=pt(t),n=W(e);if(n===null)return null;let o=Mt(t);return V(n,o,r)},Kn=(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 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 $t=(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 T(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 ar=(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)]},Jn=(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)]},fr=(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)]},Un=(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)]},pr=(t,r,e,n,o=1/0)=>{let i=Rt(t,r,e,n);return E(i,o)},Pn=(t,r,e,n,o=1/0)=>{let i=zt(t,r,e,n);return S(i,o)},Mr=(t,r,e,n,o,i=1/0)=>{let c=Ht(t,r,e,n,o);return E(c,i)},to=(t,r,e,n,o,i=1/0)=>{let c=Bt(t,r,e,n,o);return S(c,i)},ro=(t,r,e,n,o=1/0)=>{let i=pr(t,r,e,n,o);return[-i[1],i[0]]},eo=(t,r,e,n,o,i=1/0)=>{let c=Mr(t,r,e,n,o,i);return[-c[1],c[0]]},hr=(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),x=2*t[1]-4*r[1]+2*e[1],m=-2*t[1]+2*r[1],p=A([x,m,0],n),a=[];return T(u)&&a.push(u),T(p)&&a.push(p),a},br=(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],M=$t(x,o).filter(v=>v>=0&&v<=1),w=$t(a,o).filter(v=>v>=0&&v<=1);return[...M,...w].length===2?[...M,...w]:null},no=(t,r,e,n=1/0)=>{let o=hr(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=ar(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}},oo=(t,r,e,n,o=1/0)=>{let i=br(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=fr(f,t,r,e,n),a=p[0],M=p[1];c=Math.min(c,a!=null?a:1/0),x=Math.max(x,a!=null?a:-1/0),u=Math.min(u,M!=null?M:1/0),m=Math.max(m,M!=null?M:-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 qt={};b(qt,{circleMovement:()=>Vr,circleMovementAfterMouse:()=>io,ellipseMovement:()=>lr,ellipseMovementAfterMouse:()=>co,lissajousCurve:()=>uo,sineWaveMovement:()=>so});var Vr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),io=(t,r,e)=>{let n=z(t,r),o=$(n);return o=k(o,0,Math.PI*2,0,Math.PI),Vr(r,o,e)},lr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),co=(t,r,e)=>{let n=z(t,r),o=$(n);return o=k(o,0,Math.PI*2,0,Math.PI),lr(r,o,e[0],e[1])},so=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},uo=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Xt={};b(Xt,{getColorsDelta:()=>zo,getRandomGrayscaleHSLColor:()=>Mo,getRandomHSLColor:()=>Ct,getRandomHSLColorWithHue:()=>ao,getRandomHSLColorWithLightness:()=>po,getRandomHSLColorWithSaturation:()=>fo,getRandomHSLColorWithinRanges:()=>ho,getRandomHexColor:()=>mo,getRandomRGBColor:()=>xo,getShiftedHue:()=>So,getShiftedLightness:()=>wo,getShiftedSaturation:()=>Ro,hexToRgb:()=>vo,hslToHex:()=>Ir,hslToRgb:()=>dr,labToRgb:()=>go,rgbToHex:()=>Io,rgbToHsl:()=>yo,rgbToLab:()=>Nt});var xo=()=>{let t=Ct();return dr(t)},mo=()=>{let t=Ct();return Ir(t)},Ct=()=>{let t=l(1,360),r=l(0,100),e=l(0,100);return[t,r,e]},ao=t=>{let r=l(0,100),e=l(0,100);return[t,r,e]},fo=t=>{let r=l(1,360),e=l(0,100);return[r,t,e]},po=t=>{let r=l(1,360),e=l(0,100);return[r,e,t]},Mo=()=>[0,0,l(0,100)],ho=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let c=l(t,r),u=l(e,n),x=l(o,i);return[c,u,x]},bo=t=>(t*=60,t<0&&(t+=360),t),Vo=(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),lo=(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?yr(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),yo=(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=yr(e,n,o,i,c),x=lo(e,n,o,i,c,u),m=Vo(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)]},At=(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),dr=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let M=o*255;return[M,M,M]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,m=e-.333,f=At(i,c,u),p=At(i,c,x),a=At(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)]},Ir=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,M)=>(M<0&&(M+=1),M>1&&(M-=1),M<.16666666666666666?p+(a-p)*6*M:M<.5?a:M<.6666666666666666?p+(a-p)*(.6666666666666666-M)*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)}`},Io=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},vo=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]},Nt=(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)]},go=(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)]},So=(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]},Ro=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},zo=(t,r,e=1/0)=>{let n=Nt(t,e),o=Nt(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,M=1+.015*x,w=i/1,N=f/a,v=p/M,j=w*w+N*N+v*v;return j<0?0:Math.sqrt(j)};var vr={};var Yt={};b(Yt,{guid:()=>Ho,newId:()=>Bo});var Ho=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),Bo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var Dt={};b(Dt,{circleCollide:()=>Lo,convexPolygonsCollide:()=>$o,rectCollide:()=>To});var To=(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,Lo=(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},gr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...gr(t)),e.push(...gr(r));for(let n of e){let o=it(n[0],n[1]),i=Sr(t,o),c=Sr(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},Sr=(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={};b(Gt,{animate:()=>Eo});var Eo=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(),w()},f=()=>{c=!1},p=()=>{c=!0},a=B=>{e===void 0&&(e=B),o=B-e,c&&i!==B&&typeof t.callback=="function"&&t.callback(Zt()),o<=r?(i=B,n=window.requestAnimationFrame(a)):x()},M=(B,Tr)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(B,Tr)},w=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(M),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(a)},N=()=>o,v=()=>c,j=()=>e,Hr=()=>{if(!(r===1/0||o===void 0))return o*100/r},Br=()=>u,Zt=()=>({start:w,stop:x,pause:f,resume:p,restart:m,isAnimating:v,getElapsedTime:N,getStartTime:j,getPercent:Hr,getResizeObserver:Br});return Zt()};var Ot={};b(Ot,{getCircleCircumference:()=>qo,getEllipseCircumference:()=>Ao,getSquareInCircleSide:()=>Co,isAngleInCircleArc:()=>No});var qo=(t,r=1/0)=>s(2*Math.PI*t,r),Ao=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((y(t,2)+y(r,2))/2),e),No=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Co=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var jt={};b(jt,{arithmeticSequenceSum:()=>Yo,naturalNumbersSequenceSum:()=>Xo});var Xo=t=>t*(t+1)/2,Yo=(t,r,e)=>t/2*(2*r+(t-1)*e);var Ft={};b(Ft,{getArithmeticMean:()=>_,getMedian:()=>Do,getMode:()=>Go,getStandardDeviation:()=>kt,getVariance:()=>wr});var _=(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)},Do=(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)},Go=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},wr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=_(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+y(i-e,2),0);return s(n/t.length,r)},kt=(t,r=1/0)=>{var n;let e=(n=wr(t))!=null?n:0;return s(Math.sqrt(e),r)};var Qt={};b(Qt,{mlNormalize:()=>Oo,mlStandardizeArray:()=>zr,mlStandardizeTestData:()=>jo,mlStandardizeValue:()=>Rr});var Oo=(t,r=1/0)=>{let e=[...t],n=Math.min(...e),i=Math.max(...e)-n;if(i===0)return[0];for(let c=0;ce===0?0:s((t-r)/e,n),zr=(t,r,e,n=1/0)=>[...t].map(o=>Rr(o,r,e,n)),jo=(t,r=1/0)=>{var i;let e=(i=_(t))!=null?i:0,n=kt(t),o=zr(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}};var ko=h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h({},ct),It),gt),K),tt),St),J),wt),Et),Lt),qt),Xt),vr),Yt),Tt),Dt),Gt),Ot),jt),Ft),Qt);window.mzMath=window.mzMath||ko;})(); //# sourceMappingURL=mz-math.min.js.map diff --git a/dist/mz-math.min.js.map b/dist/mz-math.min.js.map index 432d5cc4..9027900f 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/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)\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 * 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 */\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 - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\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';\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalize = (data: number[], decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n const min = Math.min(...copy);\n const max = Math.max(...copy);\n\n const diff = max - min;\n if(diff === 0) return [0];\n\n for(let i=0; i {\n const copy = [...data];\n const mean = getArithmeticMean(copy) ?? 0;\n const stdDev = getStandardDeviation(copy, decimalPlaces);\n return copy.map(val => (val - mean) / stdDev);\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';\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};\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';"], - "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,gB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A,EAAEH,EAAK,OAAQG,IACxBH,EAAKG,GAAKC,GAAkBJ,EAAKG,GAAKF,GAAOC,EAAMH,CAAa,EAGpE,OAAOC,CACX,EAKaK,GAAgB,CAACP,EAAgBC,EAAgB,MAAuB,CAzBrF,IAAAO,EA0BI,IAAMN,EAAO,CAAC,GAAGF,CAAI,EACfS,GAAOD,EAAAE,EAAkBR,CAAI,IAAtB,KAAAM,EAA2B,EAClCG,EAASC,GAAqBV,EAAMD,CAAa,EACvD,OAAOC,EAAK,IAAIW,IAAQA,EAAMJ,GAAQE,CAAM,CAChD,ECRA,IAAMG,GAAMC,0CAAA,GACLC,IACAC,IACAC,IACAC,GACAC,IACAC,IACAC,GACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IASP,OAAO,OAAS,OAAO,QAAUtB", - "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", "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", "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", "getMedian", "getMode", "getStandardDeviation", "getVariance", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getMedian", "copy", "num1", "num2", "mid", "getMode", "frequencyMap", "num", "maxFrequency", "modes", "frequency", "getVariance", "mean", "__pow", "getStandardDeviation", "_a", "variance", "ml_exports", "__export", "mlNormalize", "mlStandardize", "mlNormalize", "data", "decimalPlaces", "copy", "min", "diff", "i", "setDecimalPlaces", "mlStandardize", "_a", "mean", "getArithmeticMean", "stdDev", "getStandardDeviation", "val", "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"] + "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)\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 * 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 */\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 - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\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 { IMlStandardizeResult } from '../types';\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalize = (data: number[], decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n const min = Math.min(...copy);\n const max = Math.max(...copy);\n\n const diff = max - min;\n if(diff === 0) return [0];\n\n for(let i=0; i {\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};", "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';\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};\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';"], + "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,OAA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,EACnB,GAAGC,IAAS,EAAG,MAAO,CAAC,CAAC,EAExB,QAAQC,EAAE,EAAGA,EAAEH,EAAK,OAAQG,IACxBH,EAAKG,GAAKC,GAAkBJ,EAAKG,GAAKF,GAAOC,EAAMH,CAAa,EAGpE,OAAOC,CACX,EAKaK,GAAqB,CAACC,EAAeC,EAAcC,EAAgBT,EAAgB,MACzFS,IAAW,EAAU,EACjBJ,GAAkBE,EAAQC,GAAQC,EAAQT,CAAa,EAMrDU,GAAqB,CAACX,EAAgBS,EAAcC,EAAgBT,EAAgB,MACtF,CAAC,GAAGD,CAAI,EAAE,IAAIQ,GAASD,GAAmBC,EAAOC,EAAMC,EAAQT,CAAa,CAAC,EAG3EW,GAAwB,CAACZ,EAAgBC,EAAgB,MAAmC,CAtCzG,IAAAY,EAuCI,IAAMJ,GAAOI,EAAAC,EAAkBd,CAAI,IAAtB,KAAAa,EAA2B,EAClCH,EAASK,GAAqBf,CAAI,EAClCgB,EAAQL,GAAmBX,EAAMS,EAAMC,EAAQT,CAAa,EAElE,MAAO,CACH,KAAMK,EAAiBG,EAAMR,CAAa,EAC1C,OAAQK,EAAiBI,EAAQT,CAAa,EAC9C,KAAMe,CACV,CACJ,EC1BA,IAAMC,GAAMC,0CAAA,GACLC,IACAC,IACAC,IACAC,GACAC,IACAC,IACAC,GACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IASP,OAAO,OAAS,OAAO,QAAUtB", + "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", "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", "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", "getMedian", "getMode", "getStandardDeviation", "getVariance", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getMedian", "copy", "num1", "num2", "mid", "getMode", "frequencyMap", "num", "maxFrequency", "modes", "frequency", "getVariance", "mean", "__pow", "getStandardDeviation", "_a", "variance", "ml_exports", "__export", "mlNormalize", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeValue", "mlNormalize", "data", "decimalPlaces", "copy", "min", "diff", "i", "setDecimalPlaces", "mlStandardizeValue", "value", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "_data", "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"] } diff --git a/dist/mz-math.node.cjs b/dist/mz-math.node.cjs index 37230866..cbed7878 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 or=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var cr=Object.prototype.hasOwnProperty;var V=Math.pow;var sr=(t,r)=>{for(var e in r)W(t,e,{get:r[e],enumerable:!0})},ur=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ir(r))!cr.call(t,o)&&o!==e&&W(t,o,{get:()=>r[o],enumerable:!(n=or(r,o))||n.enumerable});return t};var xr=t=>ur(W({},"__esModule",{value:!0}),t);var Io={};sr(Io,{animate:()=>xo,arithmeticSequenceSum:()=>ho,circleCollide:()=>so,circleMovement:()=>Zt,circleMovementAfterMouse:()=>Nn,convertRange:()=>O,convexPolygonsCollide:()=>uo,degreesToRadians:()=>Mr,doRangesOverlap:()=>ar,dxArcCos:()=>dn,dxArcCot:()=>gn,dxArcSin:()=>In,dxArcTan:()=>vn,dxCos:()=>Vn,dxCot:()=>ln,dxPolynomial:()=>hn,dxSin:()=>bn,dxTan:()=>yn,dxV2CubicBezierCurve:()=>lt,dxV2QuadraticBezierCurve:()=>Vt,dxV3CubicBezierCurve:()=>It,dxV3QuadraticBezierCurve:()=>yt,ellipseMovement:()=>Wt,ellipseMovementAfterMouse:()=>Cn,getAnglesDistance:()=>Ht,getAnglesSub:()=>j,getArithmeticMean:()=>Z,getCircleCircumference:()=>ao,getColorsDelta:()=>no,getEllipseCircumference:()=>mo,getLinearEquationBy2Points:()=>zn,getMedian:()=>bo,getMode:()=>Vo,getRandom:()=>b,getRandomBoolean:()=>fn,getRandomGrayscaleHSLColor:()=>Fn,getRandomHSLColor:()=>St,getRandomHSLColorWithHue:()=>On,getRandomHSLColorWithLightness:()=>kn,getRandomHSLColorWithSaturation:()=>jn,getRandomHSLColorWithinRanges:()=>Qn,getRandomHexColor:()=>Gn,getRandomInt:()=>Dt,getRandomItemFromArray:()=>pn,getRandomRGBColor:()=>Dn,getShiftedHue:()=>to,getShiftedLightness:()=>ro,getShiftedSaturation:()=>eo,getSquareInCircleSide:()=>po,getStandardDeviation:()=>Rt,getV2Angle:()=>T,getV2AngleBetween:()=>hr,getV2AngleInEllipse:()=>fr,getV3AngleBetween:()=>br,getVNAngleBetween:()=>zt,getVariance:()=>tr,guid:()=>oo,hexToRgb:()=>Un,hslToHex:()=>Jt,hslToRgb:()=>Kt,identity2:()=>Kr,identity3:()=>Jr,identity4:()=>Ur,identityN:()=>Pr,isAngleBetween:()=>Vr,isAngleInCircleArc:()=>fo,isClockwise:()=>K,isNumber:()=>H,isSingularMatrix:()=>Ve,labToRgb:()=>Pn,linearEquation:()=>E,linearEquationSystem2:()=>Sn,linearEquationSystem3:()=>Rn,linearEquationSystemN:()=>wn,lissajousCurve:()=>Yn,m2Adjugate:()=>ft,m2AppendRow:()=>ne,m2DeepCopy:()=>ct,m2Determinant:()=>mt,m2DivideScalar:()=>Tt,m2Inverse:()=>Mt,m2MulScalar:()=>Yr,m2PrependRow:()=>ce,m2ReflectionOrigin:()=>We,m2ReflectionOriginH:()=>_e,m2ReflectionX:()=>Pe,m2ReflectionXH:()=>tn,m2ReflectionY:()=>rn,m2ReflectionYH:()=>en,m2ReflectionYmX:()=>Ue,m2Reset:()=>kr,m2RotateAroundPointH:()=>Re,m2Rotation:()=>Lt,m2RotationAroundPointH:()=>$t,m2RotationH:()=>bt,m2Scale:()=>Ct,m2ScaleAtPointH:()=>qe,m2ScaleAtPointHMatrix:()=>Nt,m2ScaleH:()=>Xt,m2ScaleX:()=>Xe,m2ScaleXH:()=>Ye,m2ScaleY:()=>Qe,m2ScaleYH:()=>Ze,m2ShearingX:()=>mn,m2ShearingY:()=>an,m2Sub:()=>Cr,m2Sum:()=>Ar,m2ToCSS:()=>ye,m2Translation:()=>ve,m2TranslationH:()=>D,m2Transpose:()=>Or,m2hToCSS:()=>le,m2hToCSS3d:()=>Ie,m2x2:()=>Qr,m3Adjugate:()=>be,m3AppendRow:()=>oe,m3DeepCopy:()=>st,m3Determinant:()=>he,m3DivideScalar:()=>Gr,m3Inverse:()=>ht,m3MulScalar:()=>Dr,m3PrependRow:()=>se,m3ReflectionOrigin:()=>Ke,m3ReflectionOriginH:()=>Je,m3ReflectionXY:()=>un,m3ReflectionXYH:()=>xn,m3ReflectionXZ:()=>cn,m3ReflectionXZH:()=>sn,m3ReflectionYZ:()=>nn,m3ReflectionYZH:()=>on,m3Reset:()=>Fr,m3RotationX:()=>Et,m3RotationXH:()=>He,m3RotationY:()=>qt,m3RotationYH:()=>Te,m3RotationZ:()=>At,m3RotationZH:()=>$e,m3Scale:()=>Yt,m3ScaleH:()=>Ne,m3ScaleX:()=>De,m3ScaleXH:()=>Ge,m3ScaleY:()=>Oe,m3ScaleYH:()=>je,m3ScaleZ:()=>ke,m3ScaleZH:()=>Fe,m3Sub:()=>Xr,m3Sum:()=>Nr,m3Translation:()=>ge,m3TranslationH:()=>Se,m3Transpose:()=>jr,m3hToCSS3d:()=>de,m3x3:()=>Zr,m4x4:()=>Wr,mAdjugate:()=>pt,mAppendCol:()=>te,mAppendRow:()=>ee,mDeepCopy:()=>l,mDelFirstColumn:()=>ae,mDelFirstRow:()=>xe,mDelLastColumn:()=>ut,mDelLastRow:()=>ue,mDeterminant:()=>Y,mDivideScalar:()=>F,mEqual:()=>pe,mGetColumn:()=>fe,mGetFirstColumn:()=>me,mGetLastColumn:()=>xt,mInverse:()=>Q,mMinor:()=>at,mMul:()=>$,mMulScalar:()=>ot,mMulVector:()=>h,mNxM:()=>_r,mPrependCol:()=>re,mPrependRow:()=>ie,mReset:()=>it,mSub:()=>nt,mSum:()=>et,mTranspose:()=>X,mlNormalize:()=>yo,mlStandardize:()=>lo,mod:()=>y,naturalNumbersSequenceSum:()=>Mo,newId:()=>io,percentToAngle:()=>yr,polarToCartesian:()=>mr,radiansToDegrees:()=>pr,rectCollide:()=>co,rgbToHex:()=>Jn,rgbToHsl:()=>Kn,rgbToLab:()=>gt,setDecimalPlaces:()=>s,setV2Angle:()=>_,sineWaveMovement:()=>Xn,stringToNumber:()=>Mn,v2:()=>Lr,v2CubicBezierBBox:()=>An,v2CubicBezierCurve:()=>Ot,v2CubicBezierCurveExtrema:()=>Qt,v2CubicBezierCurveNormal:()=>En,v2CubicBezierCurveTangent:()=>kt,v2Distance:()=>zr,v2DivideScalar:()=>gr,v2DotProduct:()=>U,v2FromPolarCoords:()=>qr,v2GetNormal:()=>rt,v2Length:()=>J,v2MulScalar:()=>vr,v2Normalize:()=>L,v2QuadraticBezierBBox:()=>qn,v2QuadraticBezierCurve:()=>Gt,v2QuadraticBezierCurveExtrema:()=>Ft,v2QuadraticBezierCurveNormal:()=>$n,v2QuadraticBezierCurveTangent:()=>jt,v2Rotate:()=>we,v2RotateH:()=>ze,v2Scale:()=>Ae,v2SetLength:()=>Bt,v2Sub:()=>R,v2Sum:()=>lr,v3:()=>$r,v3CrossProduct:()=>Tr,v3CubicBezierCurve:()=>Bn,v3CubicBezierCurveTangent:()=>Ln,v3Distance:()=>Hr,v3DivideScalar:()=>Sr,v3DotProduct:()=>Br,v3Length:()=>Rr,v3MulScalar:()=>k,v3Normalize:()=>v,v3QuadraticBezierCurve:()=>Hn,v3QuadraticBezierCurveTangent:()=>Tn,v3RotateX:()=>Be,v3RotateY:()=>Le,v3RotateZ:()=>Ee,v3Scale:()=>Ce,v3Sub:()=>dr,v3Sum:()=>Ir,v4:()=>Er,vDistance:()=>wr,vDivideScalar:()=>C,vDotProduct:()=>S,vEqual:()=>tt,vLength:()=>w,vMulScalar:()=>N,vN:()=>P,vNormalize:()=>B,vSub:()=>d,vSum:()=>A});module.exports=xr(Io);var s=(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 y=(t,r)=>(t%r+r)%r,O=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,ar=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),H=t=>!isNaN(parseFloat(t))&&isFinite(t),mr=(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)},fr=(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=J(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},pr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},Mr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},zt=(t,r,e=1/0)=>{let n=B(t),o=B(r),i=S(n,o),c=Math.acos(i);return s(c,e)},hr=(t,r,e=1/0)=>{let n=d(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},br=(t,r,e=1/0)=>zt(t,r,e),Vr=(t,r,e)=>{let n=j(r,e),o=j(r,t),i=j(e,t),c=o+i;return Math.abs(c-n)<=.001},K=(t,r,e=0)=>(t=t%360,r=r%360,t=t),j=(t,r,e=1/0)=>{let n=Math.abs(y(t,360)-y(r,360));return s(n<=180?n:360-n,e)},Ht=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Ht(r,e,n);return K(r,e,n)?y(n+t*o/100,360):y(n-t*o/100,360)};var A=(t,r,e=1/0)=>{let n=[];for(let o=0;oA(t,r,e),Ir=(t,r,e=1/0)=>A(t,r,e),d=(t,r,e=1/0)=>{let n=[];for(let o=0;od(t,r,e),dr=(t,r,e=1/0)=>d(t,r,e),N=(t,r,e=1/0)=>{let n=[];for(let o=0;oN(t,r,e),k=(t,r,e=1/0)=>N(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),Sr=(t,r,e=1/0)=>C(t,r,e),w=(t,r=1/0)=>{let e=0;for(let n=0;nw(t,r),Rr=(t,r=1/0)=>w(t,r),Bt=(t,r,e=1/0)=>{let n=T(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},wr=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},zr=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},Hr=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},B=(t,r=1/0)=>{let e=w(t),n=[];for(let o=0;oB(t,r),v=(t,r=1/0)=>B(t,r),S=(t,r,e=1/0)=>{let n=0;for(let o=0;oS(t,r,e),Br=(t,r,e=1/0)=>S(t,r,e),Tr=(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)],Lr=(t=0)=>[t,t],$r=(t=0)=>[t,t,t],Er=(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=Bt(e,t),_(e,r)},tt=(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 et=(t,r,e=1/0)=>{let n=[];for(let o=0;oet(t,r,e),Nr=(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),Xr=(t,r,e=1/0)=>nt(t,r,e),ot=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(N(o,r,e));return n},Yr=(t,r,e=1/0)=>ot(t,r,e),Dr=(t,r,e=1/0)=>ot(t,r,e),F=(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},Tt=(t,r,e=1/0)=>F(t,r,e),Gr=(t,r,e=1/0)=>F(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),jr=t=>X(t),it=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nit(t,r),Fr=(t,r=0)=>it(t,r),Qr=(t=0)=>[[t,t],[t,t]],Zr=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],Wr=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],_r=(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]],Jr=()=>[[1,0,0],[0,1,0],[0,0,1]],Ur=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Pr=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;el(t),st=t=>l(t),te=(t,r)=>{if(t.length<=0)return[];let e=l(t);for(let n=0;n{if(t.length<=0)return[];let e=l(t);for(let n=0;n{let e=l(t);return e.push(r),e},ne=(t,r)=>{let e=ct(t);return e.push(r),e},oe=(t,r)=>{let e=st(t);return e.push(r),e},ie=(t,r)=>{let e=l(t);return e.unshift(r),e},ce=(t,r)=>{let e=ct(t);return e.unshift(r),e},se=(t,r)=>{let e=st(t);return e.unshift(r),e},ue=t=>{if(t.length<=0)return[];let r=l(t);return r.pop(),r},xe=t=>{if(t.length<=0)return[];let r=l(t);return r.shift(),r},ut=t=>{if(t.length<=0)return[];let r=l(t);for(let e=0;e{if(t.length<=0)return[];let r=l(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=Me(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 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]},he=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(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]]]},be=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 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=mt(t);if(e===0)return null;let n=ft(t);return n===null?null:Tt(n,e,r)},ht=(t,r=1/0)=>Q(t,r),Q=(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=pt(t);return o===null?null:F(o,n,r)};var ye=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)`},le=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})`},Ie=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)`},de=t=>`matrix3d( +var _=Object.defineProperty;var cr=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ur=Object.prototype.hasOwnProperty;var V=Math.pow;var xr=(t,r)=>{for(var e in r)_(t,e,{get:r[e],enumerable:!0})},ar=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of sr(r))!ur.call(t,o)&&o!==e&&_(t,o,{get:()=>r[o],enumerable:!(n=cr(r,o))||n.enumerable});return t};var mr=t=>ar(_({},"__esModule",{value:!0}),t);var go={};xr(go,{animate:()=>mo,arithmeticSequenceSum:()=>Vo,circleCollide:()=>xo,circleMovement:()=>Zt,circleMovementAfterMouse:()=>Xn,convertRange:()=>O,convexPolygonsCollide:()=>ao,degreesToRadians:()=>br,doRangesOverlap:()=>fr,dxArcCos:()=>gn,dxArcCot:()=>Rn,dxArcSin:()=>vn,dxArcTan:()=>Sn,dxCos:()=>ln,dxCot:()=>In,dxPolynomial:()=>Vn,dxSin:()=>yn,dxTan:()=>dn,dxV2CubicBezierCurve:()=>lt,dxV2QuadraticBezierCurve:()=>Vt,dxV3CubicBezierCurve:()=>dt,dxV3QuadraticBezierCurve:()=>yt,ellipseMovement:()=>_t,ellipseMovementAfterMouse:()=>Yn,getAnglesDistance:()=>Ht,getAnglesSub:()=>j,getArithmeticMean:()=>Z,getCircleCircumference:()=>fo,getColorsDelta:()=>io,getEllipseCircumference:()=>po,getLinearEquationBy2Points:()=>Bn,getMedian:()=>yo,getMode:()=>lo,getRandom:()=>b,getRandomBoolean:()=>Mn,getRandomGrayscaleHSLColor:()=>Zn,getRandomHSLColor:()=>St,getRandomHSLColorWithHue:()=>kn,getRandomHSLColorWithLightness:()=>Qn,getRandomHSLColorWithSaturation:()=>Fn,getRandomHSLColorWithinRanges:()=>_n,getRandomHexColor:()=>jn,getRandomInt:()=>Dt,getRandomItemFromArray:()=>hn,getRandomRGBColor:()=>On,getShiftedHue:()=>eo,getShiftedLightness:()=>no,getShiftedSaturation:()=>oo,getSquareInCircleSide:()=>ho,getStandardDeviation:()=>Rt,getV2Angle:()=>T,getV2AngleBetween:()=>Vr,getV2AngleInEllipse:()=>Mr,getV3AngleBetween:()=>yr,getVNAngleBetween:()=>zt,getVariance:()=>tr,guid:()=>co,hexToRgb:()=>to,hslToHex:()=>Jt,hslToRgb:()=>Kt,identity2:()=>Ur,identity3:()=>Pr,identity4:()=>te,identityN:()=>re,isAngleBetween:()=>lr,isAngleInCircleArc:()=>Mo,isClockwise:()=>K,isNumber:()=>H,isSingularMatrix:()=>le,labToRgb:()=>ro,linearEquation:()=>E,linearEquationSystem2:()=>wn,linearEquationSystem3:()=>zn,linearEquationSystemN:()=>Hn,lissajousCurve:()=>Gn,m2Adjugate:()=>ft,m2AppendRow:()=>ie,m2DeepCopy:()=>ct,m2Determinant:()=>mt,m2DivideScalar:()=>Tt,m2Inverse:()=>Mt,m2MulScalar:()=>Gr,m2PrependRow:()=>ue,m2ReflectionOrigin:()=>Ke,m2ReflectionOriginH:()=>Je,m2ReflectionX:()=>rn,m2ReflectionXH:()=>en,m2ReflectionY:()=>nn,m2ReflectionYH:()=>on,m2ReflectionYmX:()=>tn,m2Reset:()=>Qr,m2RotateAroundPointH:()=>ze,m2Rotation:()=>Lt,m2RotationAroundPointH:()=>$t,m2RotationH:()=>bt,m2Scale:()=>Ct,m2ScaleAtPointH:()=>Ne,m2ScaleAtPointHMatrix:()=>Nt,m2ScaleH:()=>Xt,m2ScaleX:()=>De,m2ScaleXH:()=>Ge,m2ScaleY:()=>_e,m2ScaleYH:()=>We,m2ShearingX:()=>pn,m2ShearingY:()=>fn,m2Sub:()=>Yr,m2Sum:()=>Cr,m2ToCSS:()=>de,m2Translation:()=>Se,m2TranslationH:()=>D,m2Transpose:()=>kr,m2hToCSS:()=>Ie,m2hToCSS3d:()=>ve,m2x2:()=>_r,m3Adjugate:()=>ye,m3AppendRow:()=>ce,m3DeepCopy:()=>st,m3Determinant:()=>Ve,m3DivideScalar:()=>jr,m3Inverse:()=>ht,m3MulScalar:()=>Or,m3PrependRow:()=>xe,m3ReflectionOrigin:()=>Ue,m3ReflectionOriginH:()=>Pe,m3ReflectionXY:()=>an,m3ReflectionXYH:()=>mn,m3ReflectionXZ:()=>un,m3ReflectionXZH:()=>xn,m3ReflectionYZ:()=>cn,m3ReflectionYZH:()=>sn,m3Reset:()=>Zr,m3RotationX:()=>Et,m3RotationXH:()=>Te,m3RotationY:()=>qt,m3RotationYH:()=>$e,m3RotationZ:()=>At,m3RotationZH:()=>qe,m3Scale:()=>Yt,m3ScaleH:()=>Xe,m3ScaleX:()=>Oe,m3ScaleXH:()=>je,m3ScaleY:()=>ke,m3ScaleYH:()=>Fe,m3ScaleZ:()=>Qe,m3ScaleZH:()=>Ze,m3Sub:()=>Dr,m3Sum:()=>Xr,m3Translation:()=>Re,m3TranslationH:()=>we,m3Transpose:()=>Fr,m3hToCSS3d:()=>ge,m3x3:()=>Wr,m4x4:()=>Kr,mAdjugate:()=>pt,mAppendCol:()=>ee,mAppendRow:()=>oe,mDeepCopy:()=>l,mDelFirstColumn:()=>fe,mDelFirstRow:()=>me,mDelLastColumn:()=>ut,mDelLastRow:()=>ae,mDeterminant:()=>Y,mDivideScalar:()=>F,mEqual:()=>he,mGetColumn:()=>Me,mGetFirstColumn:()=>pe,mGetLastColumn:()=>xt,mInverse:()=>Q,mMinor:()=>at,mMul:()=>$,mMulScalar:()=>ot,mMulVector:()=>h,mNxM:()=>Jr,mPrependCol:()=>ne,mPrependRow:()=>se,mReset:()=>it,mSub:()=>nt,mSum:()=>et,mTranspose:()=>X,mlNormalize:()=>Io,mlStandardizeArray:()=>er,mlStandardizeTestData:()=>vo,mlStandardizeValue:()=>rr,mod:()=>y,naturalNumbersSequenceSum:()=>bo,newId:()=>so,percentToAngle:()=>dr,polarToCartesian:()=>pr,radiansToDegrees:()=>hr,rectCollide:()=>uo,rgbToHex:()=>Pn,rgbToHsl:()=>Un,rgbToLab:()=>gt,setDecimalPlaces:()=>s,setV2Angle:()=>W,sineWaveMovement:()=>Dn,stringToNumber:()=>bn,v2:()=>Er,v2CubicBezierBBox:()=>Cn,v2CubicBezierCurve:()=>Ot,v2CubicBezierCurveExtrema:()=>Qt,v2CubicBezierCurveNormal:()=>An,v2CubicBezierCurveTangent:()=>kt,v2Distance:()=>Br,v2DivideScalar:()=>Rr,v2DotProduct:()=>U,v2FromPolarCoords:()=>Nr,v2GetNormal:()=>rt,v2Length:()=>J,v2MulScalar:()=>Sr,v2Normalize:()=>L,v2QuadraticBezierBBox:()=>Nn,v2QuadraticBezierCurve:()=>Gt,v2QuadraticBezierCurveExtrema:()=>Ft,v2QuadraticBezierCurveNormal:()=>qn,v2QuadraticBezierCurveTangent:()=>jt,v2Rotate:()=>He,v2RotateH:()=>Be,v2Scale:()=>Ce,v2SetLength:()=>Bt,v2Sub:()=>R,v2Sum:()=>Ir,v3:()=>qr,v3CrossProduct:()=>$r,v3CubicBezierCurve:()=>Ln,v3CubicBezierCurveTangent:()=>En,v3Distance:()=>Tr,v3DivideScalar:()=>wr,v3DotProduct:()=>Lr,v3Length:()=>zr,v3MulScalar:()=>k,v3Normalize:()=>v,v3QuadraticBezierCurve:()=>Tn,v3QuadraticBezierCurveTangent:()=>$n,v3RotateX:()=>Le,v3RotateY:()=>Ee,v3RotateZ:()=>Ae,v3Scale:()=>Ye,v3Sub:()=>gr,v3Sum:()=>vr,v4:()=>Ar,vDistance:()=>Hr,vDivideScalar:()=>C,vDotProduct:()=>S,vEqual:()=>tt,vLength:()=>w,vMulScalar:()=>N,vN:()=>P,vNormalize:()=>B,vSub:()=>I,vSum:()=>A});module.exports=mr(go);var s=(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 y=(t,r)=>(t%r+r)%r,O=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,fr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),H=t=>!isNaN(parseFloat(t))&&isFinite(t),pr=(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)},Mr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return s(n,e)},W=(t,r,e=1/0)=>{let n=J(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},hr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},br=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},zt=(t,r,e=1/0)=>{let n=B(t),o=B(r),i=S(n,o),c=Math.acos(i);return s(c,e)},Vr=(t,r,e=1/0)=>{let n=I(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},yr=(t,r,e=1/0)=>zt(t,r,e),lr=(t,r,e)=>{let n=j(r,e),o=j(r,t),i=j(e,t),c=o+i;return Math.abs(c-n)<=.001},K=(t,r,e=0)=>(t=t%360,r=r%360,t=t),j=(t,r,e=1/0)=>{let n=Math.abs(y(t,360)-y(r,360));return s(n<=180?n:360-n,e)},Ht=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Ht(r,e,n);return K(r,e,n)?y(n+t*o/100,360):y(n-t*o/100,360)};var A=(t,r,e=1/0)=>{let n=[];for(let o=0;oA(t,r,e),vr=(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),gr=(t,r,e=1/0)=>I(t,r,e),N=(t,r,e=1/0)=>{let n=[];for(let o=0;oN(t,r,e),k=(t,r,e=1/0)=>N(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),wr=(t,r,e=1/0)=>C(t,r,e),w=(t,r=1/0)=>{let e=0;for(let n=0;nw(t,r),zr=(t,r=1/0)=>w(t,r),Bt=(t,r,e=1/0)=>{let n=T(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Hr=(t,r,e=1/0)=>{let n=I(t,r);return w(n,e)},Br=(t,r,e=1/0)=>{let n=I(t,r);return w(n,e)},Tr=(t,r,e=1/0)=>{let n=I(t,r);return w(n,e)},B=(t,r=1/0)=>{let e=w(t),n=[];for(let o=0;oB(t,r),v=(t,r=1/0)=>B(t,r),S=(t,r,e=1/0)=>{let n=0;for(let o=0;oS(t,r,e),Lr=(t,r,e=1/0)=>S(t,r,e),$r=(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)],Er=(t=0)=>[t,t],qr=(t=0)=>[t,t,t],Ar=(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=Bt(e,t),W(e,r)},tt=(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 et=(t,r,e=1/0)=>{let n=[];for(let o=0;oet(t,r,e),Xr=(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),Dr=(t,r,e=1/0)=>nt(t,r,e),ot=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(N(o,r,e));return n},Gr=(t,r,e=1/0)=>ot(t,r,e),Or=(t,r,e=1/0)=>ot(t,r,e),F=(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},Tt=(t,r,e=1/0)=>F(t,r,e),jr=(t,r,e=1/0)=>F(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),Fr=t=>X(t),it=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nit(t,r),Zr=(t,r=0)=>it(t,r),_r=(t=0)=>[[t,t],[t,t]],Wr=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],Kr=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],Jr=(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]],Pr=()=>[[1,0,0],[0,1,0],[0,0,1]],te=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],re=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;el(t),st=t=>l(t),ee=(t,r)=>{if(t.length<=0)return[];let e=l(t);for(let n=0;n{if(t.length<=0)return[];let e=l(t);for(let n=0;n{let e=l(t);return e.push(r),e},ie=(t,r)=>{let e=ct(t);return e.push(r),e},ce=(t,r)=>{let e=st(t);return e.push(r),e},se=(t,r)=>{let e=l(t);return e.unshift(r),e},ue=(t,r)=>{let e=ct(t);return e.unshift(r),e},xe=(t,r)=>{let e=st(t);return e.unshift(r),e},ae=t=>{if(t.length<=0)return[];let r=l(t);return r.pop(),r},me=t=>{if(t.length<=0)return[];let r=l(t);return r.shift(),r},ut=t=>{if(t.length<=0)return[];let r=l(t);for(let e=0;e{if(t.length<=0)return[];let r=l(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=be(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 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]},Ve=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(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]]]},ye=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 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=mt(t);if(e===0)return null;let n=ft(t);return n===null?null:Tt(n,e,r)},ht=(t,r=1/0)=>Q(t,r),Q=(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=pt(t);return o===null?null:F(o,n,r)};var de=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)`},Ie=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})`},ve=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)`},ge=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]} - )`,ve=(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)]],D=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],Se=(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]],Lt=(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]]},bt=(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]]},$t=(t,r,e=!0,n=1/0)=>{let o=D(r,n),i=bt(t,e,n),c=D(k(r,-1),n),u=$(o,i);return $(u,c)},Re=(t,r,e,n=!0,o=1/0)=>{let i=$t(t,r,n,o);return h(i,e)},we=(t,r,e=!0,n=1/0)=>{let o=L(r);return h(Lt(t,e,n),o)},ze=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(bt(t,e,n),o)},Et=(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]]},He=(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]]},Be=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(Et(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?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},Te=(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]]},Le=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(qt(t,e,n),o)},At=(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]]},$e=(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]]},Ee=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(At(t,e,n),o)},Nt=(t,r,e=1/0)=>{let n=D(r,e),o=Xt(t),i=D(k(r,-1),e),c=$(n,o);return $(c,i)},qe=(t,r,e,n=1/0)=>{let o=Nt(t,r,n);return h(o,e)},Ct=t=>[[t[0],0],[0,t[1]]],Ae=(t,r)=>h(Ct(t),r),Xt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Yt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Ne=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Ce=(t,r)=>h(Yt(t),r),Xe=t=>[[t,0],[0,1]],Ye=t=>[[t,0,0],[0,1,0],[0,0,1]],De=t=>[[t,0,0],[0,1,0],[0,0,1]],Ge=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Oe=t=>[[1,0,0],[0,t,0],[0,0,1]],je=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],ke=t=>[[1,0,0],[0,1,0],[0,0,t]],Fe=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],Qe=t=>[[1,0],[0,t]],Ze=t=>[[1,0,0],[0,t,0],[0,0,1]],We=()=>[[-1,0],[0,-1]],_e=()=>[[-1,0,0],[0,-1,0],[0,0,1]],Ke=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],Je=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],Ue=()=>[[0,-1],[-1,0]],Pe=()=>[[1,0],[0,-1]],tn=()=>[[1,0,0],[0,-1,0],[0,0,1]],rn=()=>[[-1,0],[0,1]],en=()=>[[-1,0,0],[0,1,0],[0,0,1]],nn=()=>[[-1,0,0],[0,1,0],[0,0,1]],on=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],cn=()=>[[1,0,0],[0,-1,0],[0,0,1]],sn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],un=()=>[[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]],an=t=>[[1,t],[0,1]],mn=t=>[[1,0],[t,1]];var b=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),Dt=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),fn=()=>Math.random()<.5,pn=t=>{let r=Dt(0,t.length-1);return t[r]};var Mn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var hn=(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)]},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)]},lt=(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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},bn=(t,r=1/0)=>s(Math.cos(t),r),Vn=(t,r=1/0)=>s(-Math.sin(t),r),yn=(t,r=1/0)=>s(1/V(Math.cos(t),2),r),ln=(t,r=1/0)=>s(-1/V(Math.sin(t),2),r),In=(t,r=1/0)=>s(1/Math.sqrt(1-V(t,2)),r),dn=(t,r=1/0)=>s(-1/Math.sqrt(1-V(t,2)),r),vn=(t,r=1/0)=>s(1/(1+V(t,2)),r),gn=(t,r=1/0)=>s(-1/(1+V(t,2)),r);var E=(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)},Sn=(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 h(o,i,e)},Rn=(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 h(i,c,n)},wn=(t,r=1/0)=>{if(t.length<=0)return null;let e=ut(t),n=Q(e);if(n===null)return null;let o=xt(t);return h(n,o,r)},zn=(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 dt=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=E([n,o,i],r);return H(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,a=Math.sqrt(u);return[s((-n+a)/x,r),s((-n-a)/x,r)]};var Gt=(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)]},Hn=(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)]},Ot=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},Bn=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},jt=(t,r,e,n,o=1/0)=>{let i=Vt(t,r,e,n);return L(i,o)},Tn=(t,r,e,n,o=1/0)=>{let i=yt(t,r,e,n);return v(i,o)},kt=(t,r,e,n,o,i=1/0)=>{let c=lt(t,r,e,n,o);return L(c,i)},Ln=(t,r,e,n,o,i=1/0)=>{let c=It(t,r,e,n,o);return v(c,i)},$n=(t,r,e,n,o=1/0)=>{let i=jt(t,r,e,n,o);return[-i[1],i[0]]},En=(t,r,e,n,o,i=1/0)=>{let c=kt(t,r,e,n,o,i);return[-c[1],c[0]]},Ft=(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=E([o,i,0],n),x=2*t[1]-4*r[1]+2*e[1],a=-2*t[1]+2*r[1],p=E([x,a,0],n),m=[];return H(u)&&m.push(u),H(p)&&m.push(p),m},Qt=(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],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],m=[a,f,p,0],M=dt(x,o).filter(I=>I>=0&&I<=1),g=dt(m,o).filter(I=>I>=0&&I<=1);return[...M,...g].length===2?[...M,...g]:null},qn=(t,r,e,n=1/0)=>{let o=Ft(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let a of o){let f=Gt(a,t,r,e),p=f[0],m=f[1];i=Math.min(i,p),u=Math.max(u,p),c=Math.min(c,m),x=Math.max(x,m)}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}},An=(t,r,e,n,o=1/0)=>{let i=Qt(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,a=-1/0;for(let f of i){let p=Ot(f,t,r,e,n),m=p[0],M=p[1];c=Math.min(c,m!=null?m:1/0),x=Math.max(x,m!=null?m:-1/0),u=Math.min(u,M!=null?M:1/0),a=Math.max(a,M!=null?M:-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),a=s(Math.max(a,t[1],n[1]),o),{x:c,y:u,w:Math.abs(x-c),h:Math.abs(a-u),x2:x,y2:a}};var Zt=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Nn=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),Zt(r,o,e)},Wt=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),Cn=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),Wt(r,o,e[0],e[1])},Xn=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},Yn=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Dn=()=>{let t=St();return Kt(t)},Gn=()=>{let t=St();return Jt(t)},St=()=>{let t=b(1,360),r=b(0,100),e=b(0,100);return[t,r,e]},On=t=>{let r=b(0,100),e=b(0,100);return[t,r,e]},jn=t=>{let r=b(1,360),e=b(0,100);return[r,t,e]},kn=t=>{let r=b(1,360),e=b(0,100);return[r,e,t]},Fn=()=>[0,0,b(0,100)],Qn=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let c=b(t,r),u=b(e,n),x=b(o,i);return[c,u,x]},Zn=t=>(t*=60,t<0&&(t+=360),t),Wn=(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),_n=(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?_t(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),Kn=(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=_t(e,n,o,i,c),x=_n(e,n,o,i,c,u),a=Wn(e,n,o,i,c);return a>360||x>100||u>100?[0,0,100]:a<0||x<0||u<0?[0,0,0]:[s(a,r),s(x,r),s(u,r)]},vt=(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),Kt=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let M=o*255;return[M,M,M]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,a=e-.333,f=vt(i,c,u),p=vt(i,c,x),m=vt(i,c,a);return f*=255,p*=255,m*=255,f>255||p>255||m>255?[255,255,255]:f<0||p<0||m<0?[0,0,0]:[s(f,r),s(p,r),s(m,r)]},Jt=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,m,M)=>(M<0&&(M+=1),M>1&&(M-=1),M<.16666666666666666?p+(m-p)*6*M:M<.5?m:M<.6666666666666666?p+(m-p)*(.6666666666666666-M)*6:p),a=n<.5?n*(1+e):n+e-n*e,f=2*n-a;o=x(f,a,r+1/3),i=x(f,a,r),c=x(f,a,r-1/3)}let u=x=>{let a=Math.round(x*255).toString(16);return a.length===1?"0"+a:a};return`#${u(o)}${u(i)}${u(c)}`},Jn=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Un=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,a,f)=>x+x+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),c=parseInt(n[3],16);return[o,i,c]},gt=(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)]},Pn=(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)]},to=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=y(e,360)),[e,t[1],t[2]]},ro=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=y(e,100)),[t[0],t[1],e]},eo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},no=(t,r,e=1/0)=>{let n=gt(t,e),o=gt(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]),a=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=x-a,p=c*c+u*u-f*f;p=p<0?0:Math.sqrt(p);let m=1+.045*x,M=1+.015*x,g=i/1,q=f/m,I=p/M,G=g*g+q*q+I*I;return G<0?0:Math.sqrt(G)};var oo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),io=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);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,so=(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},Ut=t=>{let r=[];for(let e=0;e{let e=[];e.push(...Ut(t)),e.push(...Ut(r));for(let n of e){let o=rt(n[0],n[1]),i=Pt(t,o),c=Pt(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},Pt=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=U(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var xo=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)},a=()=>{x(),g()},f=()=>{c=!1},p=()=>{c=!0},m=z=>{e===void 0&&(e=z),o=z-e,c&&i!==z&&typeof t.callback=="function"&&t.callback(wt()),o<=r?(i=z,n=window.requestAnimationFrame(m)):x()},M=(z,nr)=>{a(),typeof t.resizeCallback=="function"&&t.resizeCallback(z,nr)},g=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(M),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(m)},q=()=>o,I=()=>c,G=()=>e,rr=()=>{if(!(r===1/0||o===void 0))return o*100/r},er=()=>u,wt=()=>({start:g,stop:x,pause:f,resume:p,restart:a,isAnimating:I,getElapsedTime:q,getStartTime:G,getPercent:rr,getResizeObserver:er});return wt()};var ao=(t,r=1/0)=>s(2*Math.PI*t,r),mo=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((V(t,2)+V(r,2))/2),e),fo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),po=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var Mo=t=>t*(t+1)/2,ho=(t,r,e)=>t/2*(2*r+(t-1)*e);var Z=(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)},bo=(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)},Vo=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},tr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=Z(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i-e,2),0);return s(n/t.length,r)},Rt=(t,r=1/0)=>{var n;let e=(n=tr(t))!=null?n:0;return s(Math.sqrt(e),r)};var yo=(t,r=1/0)=>{let e=[...t],n=Math.min(...e),i=Math.max(...e)-n;if(i===0)return[0];for(let c=0;c{var i;let e=[...t],n=(i=Z(e))!=null?i:0,o=Rt(e,r);return e.map(c=>(c-n)/o)};0&&(module.exports={animate,arithmeticSequenceSum,circleCollide,circleMovement,circleMovementAfterMouse,convertRange,convexPolygonsCollide,degreesToRadians,doRangesOverlap,dxArcCos,dxArcCot,dxArcSin,dxArcTan,dxCos,dxCot,dxPolynomial,dxSin,dxTan,dxV2CubicBezierCurve,dxV2QuadraticBezierCurve,dxV3CubicBezierCurve,dxV3QuadraticBezierCurve,ellipseMovement,ellipseMovementAfterMouse,getAnglesDistance,getAnglesSub,getArithmeticMean,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,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,mlNormalize,mlStandardize,mod,naturalNumbersSequenceSum,newId,percentToAngle,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}); + )`,Se=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Re=(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)]],D=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],we=(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]],Lt=(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]]},bt=(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]]},$t=(t,r,e=!0,n=1/0)=>{let o=D(r,n),i=bt(t,e,n),c=D(k(r,-1),n),u=$(o,i);return $(u,c)},ze=(t,r,e,n=!0,o=1/0)=>{let i=$t(t,r,n,o);return h(i,e)},He=(t,r,e=!0,n=1/0)=>{let o=L(r);return h(Lt(t,e,n),o)},Be=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(bt(t,e,n),o)},Et=(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]]},Te=(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]]},Le=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(Et(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?[[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]]},Ee=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(qt(t,e,n),o)},At=(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]]},qe=(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]]},Ae=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(At(t,e,n),o)},Nt=(t,r,e=1/0)=>{let n=D(r,e),o=Xt(t),i=D(k(r,-1),e),c=$(n,o);return $(c,i)},Ne=(t,r,e,n=1/0)=>{let o=Nt(t,r,n);return h(o,e)},Ct=t=>[[t[0],0],[0,t[1]]],Ce=(t,r)=>h(Ct(t),r),Xt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Yt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Xe=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Ye=(t,r)=>h(Yt(t),r),De=t=>[[t,0],[0,1]],Ge=t=>[[t,0,0],[0,1,0],[0,0,1]],Oe=t=>[[t,0,0],[0,1,0],[0,0,1]],je=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],ke=t=>[[1,0,0],[0,t,0],[0,0,1]],Fe=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],Qe=t=>[[1,0,0],[0,1,0],[0,0,t]],Ze=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],_e=t=>[[1,0],[0,t]],We=t=>[[1,0,0],[0,t,0],[0,0,1]],Ke=()=>[[-1,0],[0,-1]],Je=()=>[[-1,0,0],[0,-1,0],[0,0,1]],Ue=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],Pe=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],tn=()=>[[0,-1],[-1,0]],rn=()=>[[1,0],[0,-1]],en=()=>[[1,0,0],[0,-1,0],[0,0,1]],nn=()=>[[-1,0],[0,1]],on=()=>[[-1,0,0],[0,1,0],[0,0,1]],cn=()=>[[-1,0,0],[0,1,0],[0,0,1]],sn=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],un=()=>[[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]],an=()=>[[1,0,0],[0,1,0],[0,0,-1]],mn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],fn=t=>[[1,t],[0,1]],pn=t=>[[1,0],[t,1]];var b=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),Dt=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Mn=()=>Math.random()<.5,hn=t=>{let r=Dt(0,t.length-1);return t[r]};var bn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Vn=(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)]},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)]},lt=(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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},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,a=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},yn=(t,r=1/0)=>s(Math.cos(t),r),ln=(t,r=1/0)=>s(-Math.sin(t),r),dn=(t,r=1/0)=>s(1/V(Math.cos(t),2),r),In=(t,r=1/0)=>s(-1/V(Math.sin(t),2),r),vn=(t,r=1/0)=>s(1/Math.sqrt(1-V(t,2)),r),gn=(t,r=1/0)=>s(-1/Math.sqrt(1-V(t,2)),r),Sn=(t,r=1/0)=>s(1/(1+V(t,2)),r),Rn=(t,r=1/0)=>s(-1/(1+V(t,2)),r);var E=(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)},wn=(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 h(o,i,e)},zn=(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 h(i,c,n)},Hn=(t,r=1/0)=>{if(t.length<=0)return null;let e=ut(t),n=Q(e);if(n===null)return null;let o=xt(t);return h(n,o,r)},Bn=(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 It=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=E([n,o,i],r);return H(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,a=Math.sqrt(u);return[s((-n+a)/x,r),s((-n-a)/x,r)]};var Gt=(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)]},Tn=(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)]},Ot=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i)]},Ln=(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,a=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+a*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+a*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+a*o[2],i)]},jt=(t,r,e,n,o=1/0)=>{let i=Vt(t,r,e,n);return L(i,o)},$n=(t,r,e,n,o=1/0)=>{let i=yt(t,r,e,n);return v(i,o)},kt=(t,r,e,n,o,i=1/0)=>{let c=lt(t,r,e,n,o);return L(c,i)},En=(t,r,e,n,o,i=1/0)=>{let c=dt(t,r,e,n,o);return v(c,i)},qn=(t,r,e,n,o=1/0)=>{let i=jt(t,r,e,n,o);return[-i[1],i[0]]},An=(t,r,e,n,o,i=1/0)=>{let c=kt(t,r,e,n,o,i);return[-c[1],c[0]]},Ft=(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=E([o,i,0],n),x=2*t[1]-4*r[1]+2*e[1],a=-2*t[1]+2*r[1],p=E([x,a,0],n),m=[];return H(u)&&m.push(u),H(p)&&m.push(p),m},Qt=(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],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],m=[a,f,p,0],M=It(x,o).filter(d=>d>=0&&d<=1),g=It(m,o).filter(d=>d>=0&&d<=1);return[...M,...g].length===2?[...M,...g]:null},Nn=(t,r,e,n=1/0)=>{let o=Ft(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let a of o){let f=Gt(a,t,r,e),p=f[0],m=f[1];i=Math.min(i,p),u=Math.max(u,p),c=Math.min(c,m),x=Math.max(x,m)}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}},Cn=(t,r,e,n,o=1/0)=>{let i=Qt(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,a=-1/0;for(let f of i){let p=Ot(f,t,r,e,n),m=p[0],M=p[1];c=Math.min(c,m!=null?m:1/0),x=Math.max(x,m!=null?m:-1/0),u=Math.min(u,M!=null?M:1/0),a=Math.max(a,M!=null?M:-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),a=s(Math.max(a,t[1],n[1]),o),{x:c,y:u,w:Math.abs(x-c),h:Math.abs(a-u),x2:x,y2:a}};var Zt=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Xn=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),Zt(r,o,e)},_t=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),Yn=(t,r,e)=>{let n=R(t,r),o=T(n);return o=O(o,0,Math.PI*2,0,Math.PI),_t(r,o,e[0],e[1])},Dn=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},Gn=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var On=()=>{let t=St();return Kt(t)},jn=()=>{let t=St();return Jt(t)},St=()=>{let t=b(1,360),r=b(0,100),e=b(0,100);return[t,r,e]},kn=t=>{let r=b(0,100),e=b(0,100);return[t,r,e]},Fn=t=>{let r=b(1,360),e=b(0,100);return[r,t,e]},Qn=t=>{let r=b(1,360),e=b(0,100);return[r,e,t]},Zn=()=>[0,0,b(0,100)],_n=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let c=b(t,r),u=b(e,n),x=b(o,i);return[c,u,x]},Wn=t=>(t*=60,t<0&&(t+=360),t),Kn=(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),Jn=(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?Wt(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),Un=(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=Wt(e,n,o,i,c),x=Jn(e,n,o,i,c,u),a=Kn(e,n,o,i,c);return a>360||x>100||u>100?[0,0,100]:a<0||x<0||u<0?[0,0,0]:[s(a,r),s(x,r),s(u,r)]},vt=(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),Kt=(t,r=1/0)=>{let e=t[0]/100,n=t[1]/100,o=t[2]/100;if(n===0){let M=o*255;return[M,M,M]}let i=o<.5?o*(1+n):o+n-o*n,c=2*o-i,u=e+.333,x=e,a=e-.333,f=vt(i,c,u),p=vt(i,c,x),m=vt(i,c,a);return f*=255,p*=255,m*=255,f>255||p>255||m>255?[255,255,255]:f<0||p<0||m<0?[0,0,0]:[s(f,r),s(p,r),s(m,r)]},Jt=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,m,M)=>(M<0&&(M+=1),M>1&&(M-=1),M<.16666666666666666?p+(m-p)*6*M:M<.5?m:M<.6666666666666666?p+(m-p)*(.6666666666666666-M)*6:p),a=n<.5?n*(1+e):n+e-n*e,f=2*n-a;o=x(f,a,r+1/3),i=x(f,a,r),c=x(f,a,r-1/3)}let u=x=>{let a=Math.round(x*255).toString(16);return a.length===1?"0"+a:a};return`#${u(o)}${u(i)}${u(c)}`},Pn=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},to=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,a,f)=>x+x+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),c=parseInt(n[3],16);return[o,i,c]},gt=(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)]},ro=(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)]},eo=(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]},oo=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},io=(t,r,e=1/0)=>{let n=gt(t,e),o=gt(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]),a=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=x-a,p=c*c+u*u-f*f;p=p<0?0:Math.sqrt(p);let m=1+.045*x,M=1+.015*x,g=i/1,q=f/m,d=p/M,G=g*g+q*q+d*d;return G<0?0:Math.sqrt(G)};var co=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),so=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var uo=(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,xo=(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},Ut=t=>{let r=[];for(let e=0;e{let e=[];e.push(...Ut(t)),e.push(...Ut(r));for(let n of e){let o=rt(n[0],n[1]),i=Pt(t,o),c=Pt(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},Pt=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=U(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var mo=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)},a=()=>{x(),g()},f=()=>{c=!1},p=()=>{c=!0},m=z=>{e===void 0&&(e=z),o=z-e,c&&i!==z&&typeof t.callback=="function"&&t.callback(wt()),o<=r?(i=z,n=window.requestAnimationFrame(m)):x()},M=(z,ir)=>{a(),typeof t.resizeCallback=="function"&&t.resizeCallback(z,ir)},g=()=>{e=void 0,o=void 0,i=void 0,c=!0,t.restartOnResize&&window.ResizeObserver&&u===void 0?(u=new ResizeObserver(M),u.observe(document.body,{box:"border-box"})):n=window.requestAnimationFrame(m)},q=()=>o,d=()=>c,G=()=>e,nr=()=>{if(!(r===1/0||o===void 0))return o*100/r},or=()=>u,wt=()=>({start:g,stop:x,pause:f,resume:p,restart:a,isAnimating:d,getElapsedTime:q,getStartTime:G,getPercent:nr,getResizeObserver:or});return wt()};var fo=(t,r=1/0)=>s(2*Math.PI*t,r),po=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((V(t,2)+V(r,2))/2),e),Mo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),ho=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var bo=t=>t*(t+1)/2,Vo=(t,r,e)=>t/2*(2*r+(t-1)*e);var Z=(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)},yo=(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)},lo=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},tr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=Z(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i-e,2),0);return s(n/t.length,r)},Rt=(t,r=1/0)=>{var n;let e=(n=tr(t))!=null?n:0;return s(Math.sqrt(e),r)};var Io=(t,r=1/0)=>{let e=[...t],n=Math.min(...e),i=Math.max(...e)-n;if(i===0)return[0];for(let c=0;ce===0?0:s((t-r)/e,n),er=(t,r,e,n=1/0)=>[...t].map(o=>rr(o,r,e,n)),vo=(t,r=1/0)=>{var i;let e=(i=Z(t))!=null?i:0,n=Rt(t),o=er(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}};0&&(module.exports={animate,arithmeticSequenceSum,circleCollide,circleMovement,circleMovementAfterMouse,convertRange,convexPolygonsCollide,degreesToRadians,doRangesOverlap,dxArcCos,dxArcCot,dxArcSin,dxArcTan,dxCos,dxCot,dxPolynomial,dxSin,dxTan,dxV2CubicBezierCurve,dxV2QuadraticBezierCurve,dxV3CubicBezierCurve,dxV3QuadraticBezierCurve,ellipseMovement,ellipseMovementAfterMouse,getAnglesDistance,getAnglesSub,getArithmeticMean,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,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,mlNormalize,mlStandardizeArray,mlStandardizeTestData,mlStandardizeValue,mod,naturalNumbersSequenceSum,newId,percentToAngle,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 85a2274e..7d4271f9 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"], - "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';", "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)\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 * 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 */\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 - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\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';\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalize = (data: number[], decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n const min = Math.min(...copy);\n const max = Math.max(...copy);\n\n const diff = max - min;\n if(diff === 0) return [0];\n\n for(let i=0; i {\n const copy = [...data];\n const mean = getArithmeticMean(copy) ?? 0;\n const stdDev = getStandardDeviation(copy, decimalPlaces);\n return copy.map(val => (val - mean) / stdDev);\n};"], - "mappings": ";;;;;;;qbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,GAAA,0BAAAC,GAAA,kBAAAC,GAAA,mBAAAC,GAAA,6BAAAC,GAAA,iBAAAC,EAAA,0BAAAC,GAAA,qBAAAC,GAAA,oBAAAC,GAAA,aAAAC,GAAA,aAAAC,GAAA,aAAAC,GA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AACA,EAAM,EAAE,EAAIA,CAC7C,EAaaE,GAAc,CAACjB,EAAgBC,EAAgB,MAAgC,CACxF,GAAG,CAACD,GAAQA,EAAK,QAAU,EAAG,OAE9B,IAAMkB,EAAOnB,EAAkBC,CAAI,EACnC,GAAGkB,IAAS,OAAW,OAEvB,IAAMhB,EAAMF,EAAK,OAAO,CAACG,EAAKC,IAAQD,EAAQgB,EAAAf,EAAMc,EAAS,GAAI,CAAC,EAElE,OAAOb,EAAiBH,EAAMF,EAAK,OAAQC,CAAa,CAC5D,EAEamB,GAAuB,CAACpB,EAAgBC,EAAgB,MAAa,CA3FlF,IAAAoB,EA4FI,IAAMC,GAAWD,EAAAJ,GAAYjB,CAAI,IAAhB,KAAAqB,EAAqB,EACtC,OAAOhB,EAAiB,KAAK,KAAKiB,CAAQ,EAAGrB,CAAa,CAC9D,ECxFO,IAAMsB,GAAc,CAACC,EAAgBC,EAAgB,MAAuB,CAC/E,IAAMC,EAAO,CAAC,GAAGF,CAAI,EAEfG,EAAM,KAAK,IAAI,GAAGD,CAAI,EAGtBE,EAFM,KAAK,IAAI,GAAGF,CAAI,EAETC,EACnB,GAAGC,IAAS,EAAG,MAAO,CAAC,CAAC,EAExB,QAAQC,EAAE,EAAGA,EAAEH,EAAK,OAAQG,IACxBH,EAAKG,GAAKC,GAAkBJ,EAAKG,GAAKF,GAAOC,EAAMH,CAAa,EAGpE,OAAOC,CACX,EAKaK,GAAgB,CAACP,EAAgBC,EAAgB,MAAuB,CAzBrF,IAAAO,EA0BI,IAAMN,EAAO,CAAC,GAAGF,CAAI,EACfS,GAAOD,EAAAE,EAAkBR,CAAI,IAAtB,KAAAM,EAA2B,EAClCG,EAASC,GAAqBV,EAAMD,CAAa,EACvD,OAAOC,EAAK,IAAIW,IAAQA,EAAMJ,GAAQE,CAAM,CAChD", - "names": ["index_esm_exports", "__export", "animate", "arithmeticSequenceSum", "circleCollide", "circleMovement", "circleMovementAfterMouse", "convertRange", "convexPolygonsCollide", "degreesToRadians", "doRangesOverlap", "dxArcCos", "dxArcCot", "dxArcSin", "dxArcTan", "dxCos", "dxCot", "dxPolynomial", "dxSin", "dxTan", "dxV2CubicBezierCurve", "dxV2QuadraticBezierCurve", "dxV3CubicBezierCurve", "dxV3QuadraticBezierCurve", "ellipseMovement", "ellipseMovementAfterMouse", "getAnglesDistance", "getAnglesSub", "getArithmeticMean", "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", "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", "mlNormalize", "mlStandardize", "mod", "naturalNumbersSequenceSum", "newId", "percentToAngle", "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", "getMedian", "copy", "num1", "num2", "mid", "getMode", "frequencyMap", "num", "maxFrequency", "modes", "frequency", "getVariance", "mean", "__pow", "getStandardDeviation", "_a", "variance", "mlNormalize", "data", "decimalPlaces", "copy", "min", "diff", "i", "setDecimalPlaces", "mlStandardize", "_a", "mean", "getArithmeticMean", "stdDev", "getStandardDeviation", "val"] + "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';", "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)\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 * 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 */\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 - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\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 { IMlStandardizeResult } from '../types';\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalize = (data: number[], decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n const min = Math.min(...copy);\n const max = Math.max(...copy);\n\n const diff = max - min;\n if(diff === 0) return [0];\n\n for(let i=0; i {\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};"], + "mappings": ";;;;;;;qbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,GAAA,0BAAAC,GAAA,kBAAAC,GAAA,mBAAAC,GAAA,6BAAAC,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,sB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R,CAAa,EAC1C,OAAQK,EAAiBI,EAAQT,CAAa,EAC9C,KAAMe,CACV,CACJ", + "names": ["index_esm_exports", "__export", "animate", "arithmeticSequenceSum", "circleCollide", "circleMovement", "circleMovementAfterMouse", "convertRange", "convexPolygonsCollide", "degreesToRadians", "doRangesOverlap", "dxArcCos", "dxArcCot", "dxArcSin", "dxArcTan", "dxCos", "dxCot", "dxPolynomial", "dxSin", "dxTan", "dxV2CubicBezierCurve", "dxV2QuadraticBezierCurve", "dxV3CubicBezierCurve", "dxV3QuadraticBezierCurve", "ellipseMovement", "ellipseMovementAfterMouse", "getAnglesDistance", "getAnglesSub", "getArithmeticMean", "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", "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", "mlNormalize", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeValue", "mod", "naturalNumbersSequenceSum", "newId", "percentToAngle", "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", "getMedian", "copy", "num1", "num2", "mid", "getMode", "frequencyMap", "num", "maxFrequency", "modes", "frequency", "getVariance", "mean", "__pow", "getStandardDeviation", "_a", "variance", "mlNormalize", "data", "decimalPlaces", "copy", "min", "diff", "i", "setDecimalPlaces", "mlStandardizeValue", "value", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "_data"] } diff --git a/src/main/ml.ts b/src/main/ml.ts index 67426d6a..cca00020 100644 --- a/src/main/ml.ts +++ b/src/main/ml.ts @@ -1,5 +1,6 @@ import { setDecimalPlaces } from './format'; import { getArithmeticMean, getStandardDeviation } from './statistics'; +import { IMlStandardizeResult } from '../types'; /** * Returns a copy of array, where each value will be in the range [0, 1]. @@ -21,11 +22,28 @@ export const mlNormalize = (data: number[], decimalPlaces = Infinity): number[] }; /** - * Returns a copy of array, where each value will be in the range [-1, 1] + * Changes value to be in the range [-1, 1]. */ -export const mlStandardize = (data: number[], decimalPlaces = Infinity): number[] => { - const copy = [...data]; - const mean = getArithmeticMean(copy) ?? 0; - const stdDev = getStandardDeviation(copy, decimalPlaces); - return copy.map(val => (val - mean) / stdDev); +export const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => { + if(stdDev === 0) return 0; + return setDecimalPlaces((value - mean) / stdDev, decimalPlaces); +}; + +/** + * Returns a copy of array, where each value will be in the range [-1, 1]. + */ +export const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => { + return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces)); +}; + +export const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => { + const mean = getArithmeticMean(data) ?? 0; + const stdDev = getStandardDeviation(data); + const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces); + + return { + mean: setDecimalPlaces(mean, decimalPlaces), + stdDev: setDecimalPlaces(stdDev, decimalPlaces), + data: _data, + }; }; \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 60ae62fa..06e97b6b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -34,4 +34,10 @@ export interface ICircle { r: number; } -export type IPolygon = Vector2[]; \ No newline at end of file +export type IPolygon = Vector2[]; + +export interface IMlStandardizeResult { + mean: number; + stdDev: number; + data: number[]; +} \ No newline at end of file diff --git a/test/ml.test.ts b/test/ml.test.ts index 61281f4b..2ef42970 100644 --- a/test/ml.test.ts +++ b/test/ml.test.ts @@ -1,4 +1,4 @@ -import { mlNormalize } from '../src/main/ml'; +import { mlNormalize, mlStandardizeTestData } from '../src/main/ml'; describe('ML', () => { @@ -24,4 +24,45 @@ describe('ML', () => { expect(mlNormalize([1, 1, 2, 3, 4], 2)).toStrictEqual([0, 0, 0.33, 0.67, 1]); }); }); + + describe('Standardize', () => { + it('returns an object with mean and standard deviation of 0 when data is empty', () => { + const result = mlStandardizeTestData([]); + expect(result.mean).toBe(0); + expect(result.stdDev).toBe(0); + expect(result.data).toStrictEqual([]); + }); + + it('returns an object with mean and standard deviation when data contains only one element', () => { + const result = mlStandardizeTestData([5]); + expect(result.mean).toBe(5); + expect(result.stdDev).toBe(0); + expect(result.data).toStrictEqual([0]); + }); + + it('returns the correct mean, standard deviation, and standardized data', () => { + const data = [2, 4, 4, 4, 5, 5, 7, 9]; + + // Expected mean and standard deviation (calculated manually) + const expectedMean = 5; + const expectedStdDev = 2; + + // Expected standardized data (calculated manually) + const expectedData = [-1.5, -0.5, -0.5, -0.5, 0, 0, 1, 2]; + + // Call the function + const result = mlStandardizeTestData(data); + + // Assert the mean, standard deviation, and standardized data + expect(result.mean).toBe(expectedMean); + expect(result.stdDev).toBe(expectedStdDev); + expect(result.data).toEqual(expectedData); + }); + + it('returns the mean and standard deviation with specified decimal places', () => { + const result = mlStandardizeTestData([1, 2, 3, 4, 5], 2); + expect(result.mean).toStrictEqual(3); + expect(result.stdDev).toStrictEqual(1.41); + }); + }); }); \ No newline at end of file