From cdc3612672cfc9916fad6636860441c1b6f8e038 Mon Sep 17 00:00:00 2001 From: Miriam Zusin Date: Sat, 16 Mar 2024 12:30:27 +0200 Subject: [PATCH] Series --- README.md | 2 + dist/index.d.ts | 2 + dist/mz-math.esm.js | 6 +- dist/mz-math.esm.js.map | 8 +- dist/mz-math.min.js | 6 +- dist/mz-math.min.js.map | 8 +- dist/mz-math.node.cjs | 6 +- dist/mz-math.node.cjs.map | 8 +- ...494664434.css => styles.1710585004234.css} | 0 docs/index.html | 6 +- ...710494664434.js => index.1710585004234.js} | 2 +- ...4434.js.map => index.1710585004234.js.map} | 0 docs/pages/Check-if-value-is-number.html | 8 +- docs/pages/adjugate-matrix.html | 8 +- docs/pages/angle-between-vectors.html | 8 +- docs/pages/angles-distance.html | 8 +- docs/pages/animation.html | 8 +- docs/pages/append-or-prepend-column.html | 8 +- docs/pages/append-or-prepend-row.html | 8 +- docs/pages/arithmetic-sequence-sum.html | 8 +- docs/pages/bezier-curves.html | 8 +- docs/pages/bounding-box.html | 8 +- docs/pages/browser-usage.html | 8 +- docs/pages/check-if-ranges-overlap.html | 8 +- docs/pages/circle-movement.html | 8 +- docs/pages/circles-collision.html | 8 +- docs/pages/circumference.html | 8 +- docs/pages/color.html | 8 +- docs/pages/convert-colors.html | 8 +- docs/pages/convert-range.html | 8 +- docs/pages/convert-string-to-number.html | 8 +- docs/pages/convex-polygons-collision.html | 8 +- docs/pages/cross-product.html | 8 +- docs/pages/degrees-and-radians.html | 8 +- docs/pages/distance-between-vectors.html | 8 +- docs/pages/divide-by-scalar.html | 8 +- docs/pages/divide-vector-by-scalar.html | 8 +- docs/pages/dot-product.html | 8 +- docs/pages/ellipse-movement.html | 8 +- docs/pages/extrema.html | 8 +- docs/pages/general-case.html | 8 +- docs/pages/get-animation-data.html | 8 +- docs/pages/get-column.html | 8 +- .../get-linear-equation-by-2-points.html | 8 +- docs/pages/get-matrix-minor.html | 8 +- docs/pages/get-normal.html | 8 +- .../get-point-on-cubic-bezier-curve.html | 8 +- .../get-point-on-quadratic-bezier-curve.html | 8 +- docs/pages/get-random-boolean.html | 8 +- docs/pages/get-random-integer.html | 8 +- docs/pages/get-random-item-from-array.html | 8 +- docs/pages/get-random-number-in-range.html | 8 +- docs/pages/inverse-matrix.html | 8 +- docs/pages/is-angle-between.html | 8 +- docs/pages/is-angle-in-circle-arc.html | 8 +- docs/pages/is-clockwise.html | 8 +- docs/pages/lerp.html | 8 +- docs/pages/linear-equation.html | 8 +- docs/pages/lissajous-curve.html | 8 +- docs/pages/matrix-deep-copy.html | 8 +- docs/pages/matrix-determinant.html | 8 +- docs/pages/matrix-equality.html | 8 +- docs/pages/matrix-initialization.html | 8 +- docs/pages/matrix-multiplication.html | 8 +- docs/pages/matrix-singularity.html | 8 +- docs/pages/matrix-subtraction.html | 8 +- docs/pages/matrix-sum.html | 8 +- docs/pages/matrix-to-CSS-transform.html | 8 +- docs/pages/matrix-transposition.html | 8 +- docs/pages/matrix.html | 8 +- docs/pages/modulo.html | 8 +- docs/pages/multiply-by-scalar.html | 8 +- docs/pages/multiply-matrix-by-vector.html | 8 +- docs/pages/multiply-vector-by-scalar.html | 8 +- docs/pages/natural-numbers-sequence-sum.html | 8 +- docs/pages/nodejs-usage.html | 8 +- docs/pages/normal.html | 8 +- docs/pages/normalize-vector.html | 8 +- docs/pages/percent-to-angle.html | 8 +- docs/pages/polar-to-cartesian.html | 8 +- docs/pages/polynomial.html | 8 +- docs/pages/quadratic-equation.html | 8 +- docs/pages/random-color.html | 8 +- docs/pages/random-id-or-GUID.html | 8 +- docs/pages/rectangles-collision.html | 8 +- docs/pages/reflection-matrix.html | 8 +- docs/pages/remove-row-or-column.html | 8 +- docs/pages/reset-matrix.html | 8 +- docs/pages/rotate-around-point.html | 8 +- docs/pages/rotation-matrix.html | 8 +- docs/pages/scale-and-stretch-matrix.html | 8 +- docs/pages/scale-around-point.html | 8 +- docs/pages/series.html | 275 ++++++++++++++++++ docs/pages/set-decimal-places.html | 8 +- docs/pages/shearing-matrix.html | 8 +- docs/pages/shift-colors.html | 8 +- docs/pages/similar-colors.html | 8 +- docs/pages/sine-wave-movement.html | 8 +- docs/pages/square-in-circle.html | 8 +- docs/pages/system-of-linear-equations.html | 8 +- docs/pages/tangent.html | 8 +- docs/pages/temperature-conversion.html | 25 +- docs/pages/translation-matrix.html | 8 +- docs/pages/trigonometric-functions.html | 8 +- docs/pages/typescript-usage.html | 8 +- docs/pages/vector-angle.html | 8 +- docs/pages/vector-initialization.html | 8 +- docs/pages/vector-length.html | 8 +- docs/pages/vectors-equality.html | 8 +- docs/pages/vectors-subtraction.html | 8 +- docs/pages/vectors-sum.html | 8 +- docs/pages/vectors.html | 8 +- docs/sitemap.txt | 1 + package.json | 2 +- src/docs/data/pages/1000-other/10-series.md | 15 + src/index-esm.ts | 3 +- src/index.ts | 5 +- src/main/series.ts | 14 + test/series.test.ts | 31 ++ 119 files changed, 784 insertions(+), 425 deletions(-) rename docs/css/{styles.1710494664434.css => styles.1710585004234.css} (100%) rename docs/js/{index.1710494664434.js => index.1710585004234.js} (99%) rename docs/js/{index.1710494664434.js.map => index.1710585004234.js.map} (100%) create mode 100644 docs/pages/series.html create mode 100644 src/docs/data/pages/1000-other/10-series.md create mode 100644 src/main/series.ts create mode 100644 test/series.test.ts diff --git a/README.md b/README.md index fa693a11..4571bc92 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ This project is a collection of TypeScript math helpers and utilities for the br - [Check If Value Is Number](https://math.mzsoft.org/pages/check-if-value-is-number.html) - [Polar To Cartesian](https://math.mzsoft.org/pages/polar-to-cartesian.html) - [Temperature Conversion](https://math.mzsoft.org/pages/temperature-conversion.html) +- [Series](https://math.mzsoft.org/pages/series.html) ------------------------------ @@ -701,6 +702,7 @@ This project is a collection of TypeScript math helpers and utilities for the br + ``` diff --git a/dist/index.d.ts b/dist/index.d.ts index b487ef85..99d1c7d2 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -370,4 +370,6 @@ declare module 'mz-math' { export const kelvinToCelsius: (kelvin: number, decimalPlaces?: number) => number; export const kelvinToFahrenheit: (kelvin: number, decimalPlaces?: number) => number; + export const naturalNumbersSum1ToN: (n: number) => number; + export const naturalNumbersSumMToN: (m: number, n: number) => number; } \ No newline at end of file diff --git a/dist/mz-math.esm.js b/dist/mz-math.esm.js index 2766f18f..44fc778a 100644 --- a/dist/mz-math.esm.js +++ b/dist/mz-math.esm.js @@ -1,14 +1,14 @@ /* -mzMath v3.0.24 +mzMath v3.0.25 A collection of TypeScript-based math helpers. 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 y=(t,r)=>(t%r+r)%r,j=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,hr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),B=t=>!isNaN(parseFloat(t))&&isFinite(t),br=(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)},dr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return s(n,e)},K=(t,r,e=1/0)=>{let n=P(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},vr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},gr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},qt=(t,r,e=1/0)=>{let n=T(t),o=T(r),i=S(n,o),c=Math.acos(i);return s(c,e)},Sr=(t,r,e=1/0)=>{let n=d(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},Rr=(t,r,e=1/0)=>qt(t,r,e),wr=(t,r,e)=>{let n=k(r,e),o=k(r,t),i=k(e,t),c=o+i;return Math.abs(c-n)<=.001},J=(t,r,e=0)=>(t=t%360,r=r%360,t=t),k=(t,r,e=1/0)=>{let n=Math.abs(y(t,360)-y(r,360));return s(n<=180?n:360-n,e)},At=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=At(r,e,n);return J(r,e,n)?y(n+t*o/100,360):y(n-t*o/100,360)};var N=(t,r,e=1/0)=>{let n=[];for(let o=0;oN(t,r,e),$r=(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),Er=(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),F=(t,r,e=1/0)=>C(t,r,e),D=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oD(t,r,e),Nr=(t,r,e=1/0)=>D(t,r,e),z=(t,r=1/0)=>{let e=0;for(let n=0;nz(t,r),Cr=(t,r=1/0)=>z(t,r),Nt=(t,r,e=1/0)=>{let n=L(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Dr=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},Xr=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},Yr=(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),Gr=(t,r,e=1/0)=>S(t,r,e),Or=(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)],jr=(t=0)=>[t,t],kr=(t=0)=>[t,t,t],Fr=(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=Nt(e,t),K(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),Ur=(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),Jr=(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},Pr=(t,r,e=1/0)=>ct(t,r,e),te=(t,r,e=1/0)=>ct(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(D(o,r,e));return n},Ct=(t,r,e=1/0)=>Q(t,r,e),re=(t,r,e=1/0)=>Q(t,r,e),X=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oX(t),ne=t=>X(t),st=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nst(t,r),ie=(t,r=0)=>st(t,r),ce=(t=0)=>[[t,t],[t,t]],se=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],ue=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],xe=(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]],ae=()=>[[1,0,0],[0,1,0],[0,0,1]],fe=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],pe=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),Me=(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},Ve=(t,r)=>{let e=ut(t);return e.push(r),e},le=(t,r)=>{let e=xt(t);return e.push(r),e},ye=(t,r)=>{let e=I(t);return e.unshift(r),e},Ie=(t,r)=>{let e=ut(t);return e.unshift(r),e},de=(t,r)=>{let e=xt(t);return e.unshift(r),e},ve=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},ge=t=>{if(t.length<=0)return[];let r=I(t);return r.shift(),r},mt=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=Dt(t,r,e);return Y(o)},Y=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return pt(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},He=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(t)},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]]]},Be=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 Y(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:Ct(n,e,r)},Vt=(t,r=1/0)=>Z(t,r),Z=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=Y(t),o=ht(t);return o===null?null:Q(o,n,r)};var Ae=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)`},Ne=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})`},Ce=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 b=Math.pow;var s=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=b(10,r);return Math.round(t*e)/e};var y=(t,r)=>(t%r+r)%r,j=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,br=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),T=t=>!isNaN(parseFloat(t))&&isFinite(t),hr=(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)},dr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return s(n,e)},K=(t,r,e=1/0)=>{let n=P(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},vr=(t,r=1/0)=>{let e=t*(180/Math.PI);return s(e,r)},gr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},qt=(t,r,e=1/0)=>{let n=B(t),o=B(r),i=S(n,o),c=Math.acos(i);return s(c,e)},Sr=(t,r,e=1/0)=>{let n=d(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},Rr=(t,r,e=1/0)=>qt(t,r,e),wr=(t,r,e)=>{let n=k(r,e),o=k(r,t),i=k(e,t),c=o+i;return Math.abs(c-n)<=.001},J=(t,r,e=0)=>(t=t%360,r=r%360,t=t),k=(t,r,e=1/0)=>{let n=Math.abs(y(t,360)-y(r,360));return s(n<=180?n:360-n,e)},At=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=At(r,e,n);return J(r,e,n)?y(n+t*o/100,360):y(n-t*o/100,360)};var N=(t,r,e=1/0)=>{let n=[];for(let o=0;oN(t,r,e),$r=(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),Er=(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),F=(t,r,e=1/0)=>C(t,r,e),D=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oD(t,r,e),Nr=(t,r,e=1/0)=>D(t,r,e),z=(t,r=1/0)=>{let e=0;for(let n=0;nz(t,r),Cr=(t,r=1/0)=>z(t,r),Nt=(t,r,e=1/0)=>{let n=L(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Dr=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},Xr=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},Yr=(t,r,e=1/0)=>{let n=d(t,r);return z(n,e)},B=(t,r=1/0)=>{let e=z(t),n=[];for(let o=0;oB(t,r),g=(t,r=1/0)=>B(t,r),S=(t,r,e=1/0)=>{let n=0;for(let o=0;oS(t,r,e),Gr=(t,r,e=1/0)=>S(t,r,e),Or=(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)],jr=(t=0)=>[t,t],kr=(t=0)=>[t,t,t],Fr=(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=Nt(e,t),K(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),Ur=(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),Jr=(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},Pr=(t,r,e=1/0)=>ct(t,r,e),te=(t,r,e=1/0)=>ct(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(D(o,r,e));return n},Ct=(t,r,e=1/0)=>Q(t,r,e),re=(t,r,e=1/0)=>Q(t,r,e),X=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oX(t),ne=t=>X(t),st=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nst(t,r),ie=(t,r=0)=>st(t,r),ce=(t=0)=>[[t,t],[t,t]],se=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],ue=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],xe=(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]],ae=()=>[[1,0,0],[0,1,0],[0,0,1]],fe=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],pe=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),Me=(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},Ve=(t,r)=>{let e=ut(t);return e.push(r),e},le=(t,r)=>{let e=xt(t);return e.push(r),e},ye=(t,r)=>{let e=I(t);return e.unshift(r),e},Ie=(t,r)=>{let e=ut(t);return e.unshift(r),e},de=(t,r)=>{let e=xt(t);return e.unshift(r),e},ve=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},ge=t=>{if(t.length<=0)return[];let r=I(t);return r.shift(),r},mt=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=Dt(t,r,e);return Y(o)},Y=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return pt(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},He=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return Y(t)},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]]]},Te=t=>bt(t),bt=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 Y(t)===0},ht=(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:Ct(n,e,r)},Vt=(t,r=1/0)=>Z(t,r),Z=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=Y(t),o=bt(t);return o===null?null:Q(o,n,r)};var Ae=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)`},Ne=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})`},Ce=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( ${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]} - )`,Xe=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Ye=(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]],Ge=(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]],Xt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},lt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Yt=(t,r,e=!0,n=1/0)=>{let o=G(r,n),i=lt(t,e,n),c=G(F(r,-1),n),u=E(o,i);return E(u,c)},Oe=(t,r,e,n=!0,o=1/0)=>{let i=Yt(t,r,n,o);return b(i,e)},je=(t,r,e=!0,n=1/0)=>{let o=$(r);return b(Xt(t,e,n),o)},ke=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(lt(t,e,n),o)},Gt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},Fe=(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]]},Qe=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Gt(t,e,n),o)},Ot=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},Ze=(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]]},_e=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(Ot(t,e,n),o)},jt=(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]]},We=(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]]},Ue=(t,r,e=!0,n=1/0)=>{let o=g(r);return b(jt(t,e,n),o)},kt=(t,r,e=1/0)=>{let n=G(r,e),o=Qt(t),i=G(F(r,-1),e),c=E(n,o);return E(c,i)},Ke=(t,r,e,n=1/0)=>{let o=kt(t,r,n);return b(o,e)},Ft=t=>[[t[0],0],[0,t[1]]],Je=(t,r)=>b(Ft(t),r),Qt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Zt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Pe=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],tn=(t,r)=>b(Zt(t),r),rn=t=>[[t,0],[0,1]],en=t=>[[t,0,0],[0,1,0],[0,0,1]],nn=t=>[[t,0,0],[0,1,0],[0,0,1]],on=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],cn=t=>[[1,0,0],[0,t,0],[0,0,1]],sn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],un=t=>[[1,0,0],[0,1,0],[0,0,t]],xn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],mn=t=>[[1,0],[0,t]],an=t=>[[1,0,0],[0,t,0],[0,0,1]],fn=()=>[[-1,0],[0,-1]],pn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],Mn=()=>[[-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=()=>[[0,-1],[-1,0]],Vn=()=>[[1,0],[0,-1]],ln=()=>[[1,0,0],[0,-1,0],[0,0,1]],yn=()=>[[-1,0],[0,1]],In=()=>[[-1,0,0],[0,1,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=()=>[[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=()=>[[1,0,0],[0,1,0],[0,0,-1]],wn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],zn=t=>[[1,t],[0,1]],Hn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),_t=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Ln=()=>Math.random()<.5,$n=t=>{let r=_t(0,t.length-1);return t[r]};var qn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Cn=(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)},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)]},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,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)]},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,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)]},Dn=(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/h(Math.cos(t),2),r),Gn=(t,r=1/0)=>s(-1/h(Math.sin(t),2),r),On=(t,r=1/0)=>s(1/Math.sqrt(1-h(t,2)),r),jn=(t,r=1/0)=>s(-1/Math.sqrt(1-h(t,2)),r),kn=(t,r=1/0)=>s(1/(1+h(t,2)),r),Fn=(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)},Kn=(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)},Jn=(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)},Pn=(t,r=1/0)=>{if(t.length<=0)return null;let e=mt(t),n=Z(e);if(n===null)return null;let o=at(t);return b(n,o,r)},to=(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 _=(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,m=Math.sqrt(u);return[s((-n+m)/x,r),s((-n-m)/x,r)]};var Wt=(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)]},fo=(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)]},Ut=(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)]},po=(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)]},Kt=(t,r,e,n,o=1/0)=>{let i=yt(t,r,e,n);return $(i,o)},Mo=(t,r,e,n,o=1/0)=>{let i=It(t,r,e,n);return g(i,o)},Jt=(t,r,e,n,o,i=1/0)=>{let c=dt(t,r,e,n,o);return $(c,i)},ho=(t,r,e,n,o,i=1/0)=>{let c=vt(t,r,e,n,o);return g(c,i)},bo=(t,r,e,n,o=1/0)=>{let i=Kt(t,r,e,n,o);return[-i[1],i[0]]},Vo=(t,r,e,n,o,i=1/0)=>{let c=Jt(t,r,e,n,o,i);return[-c[1],c[0]]},Pt=(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],m=-2*t[1]+2*r[1],p=q([x,m,0],n),a=[];return B(u)&&a.push(u),B(p)&&a.push(p),a},tr=(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=_(x,o).filter(l=>l>=0&&l<=1),v=_(a,o).filter(l=>l>=0&&l<=1);return[...M,...v].length===2?[...M,...v]:null},lo=(t,r,e,n=1/0)=>{let o=Pt(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=Wt(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}},yo=(t,r,e,n,o=1/0)=>{let i=tr(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=Ut(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 rr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Ro=(t,r,e)=>{let n=w(t,r),o=L(n);return o=j(o,0,Math.PI*2,0,Math.PI),rr(r,o,e)},er=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),wo=(t,r,e)=>{let n=w(t,r),o=L(n);return o=j(o,0,Math.PI*2,0,Math.PI),er(r,o,e[0],e[1])},zo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},Ho=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Eo=()=>{let t=St();return cr(t)},qo=()=>{let t=St();return sr(t)},St=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Ao=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},No=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Co=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Do=()=>[0,0,V(0,100)],Xo=(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]},nr=t=>(t*=60,t<0&&(t+=360),t),or=(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),ir=(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)),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=Rt(e,n,o,i,c),x=ir(e,n,o,i,c,u),m=or(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)]},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),cr=(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=W(i,c,u),p=W(i,c,x),a=W(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)]},sr=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)}`},Go=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Oo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,m,f)=>x+x+m+m+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),c=parseInt(n[3],16);return[o,i,c]},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)]},jo=(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)]},ko=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=y(e,360)),[e,t[1],t[2]]},Fo=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=y(e,100)),[t[0],t[1],e]},Qo=(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=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]),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,v=i/1,H=f/a,l=p/M,A=v*v+H*H+l*l;return A<0?0:Math.sqrt(A)};var Wo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),Uo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var ti=(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,ri=(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 oi=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,c=!1,u,x=()=>{e=void 0,o=void 0,i=void 0,c=!1,n!==void 0&&window.cancelAnimationFrame(n)},m=()=>{x(),v()},f=()=>{c=!1},p=()=>{c=!0},a=R=>{e===void 0&&(e=R),o=R-e,c&&i!==R&&typeof t.callback=="function"&&t.callback(U()),o<=r?(i=R,n=window.requestAnimationFrame(a)):x()},M=(R,Et)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(R,Et)},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(a)},H=()=>o,l=()=>c,A=()=>e,Lt=()=>{if(!(r===1/0||o===void 0))return o*100/r},$t=()=>u,U=()=>({start:v,stop:x,pause:f,resume:p,restart:m,isAnimating:l,getElapsedTime:H,getStartTime:A,getPercent:Lt,getResizeObserver:$t});return U()};var si=(t,r=1/0)=>s(2*Math.PI*t,r),ui=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),xi=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),mi=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var pi=t=>t*(t+1)/2,Mi=(t,r,e)=>t/2*(2*r+(t-1)*e);var O=(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)},Vi=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return s(e,r)},li=(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)},yi=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},Ii=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return s(n/t.length,r)},ur=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i,2),0);return s(n/t.length-h(e,2),r)},Ht=(t,r=1/0)=>{var n;let e=(n=ur(t))!=null?n:0;return s(Math.sqrt(e),r)};var xr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:s((t-r)/o,n)},Bt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Bt(t,e,n,r);return{min:s(e,r),max:s(n,r),data:o}},wi=(t,r,e,n=1/0)=>Bt(t,r,e,n),mr=(t,r,e,n=1/0)=>e===0?0:s((t-r)/e,n),Tt=(t,r,e,n=1/0)=>[...t].map(o=>mr(o,r,e,n)),zi=(t,r=1/0)=>{var i;let e=(i=O(t))!=null?i:0,n=Ht(t),o=Tt(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}},Hi=(t,r,e,n=1/0)=>Tt(t,r,e,n);export{oi as animate,Mi as arithmeticSequenceSum,ri as circleCollide,rr as circleMovement,Ro as circleMovementAfterMouse,j as convertRange,ei as convexPolygonsCollide,gr as degreesToRadians,hr as doRangesOverlap,jn as dxArcCos,Fn as dxArcCot,On as dxArcSin,kn as dxArcTan,Xn as dxCos,Gn as dxCot,Cn as dxPolynomial,Dn as dxSin,Yn as dxTan,dt as dxV2CubicBezierCurve,yt as dxV2QuadraticBezierCurve,vt as dxV3CubicBezierCurve,It as dxV3QuadraticBezierCurve,er as ellipseMovement,wo as ellipseMovementAfterMouse,At as getAnglesDistance,k as getAnglesSub,O as getArithmeticMean,Vi as getArithmeticMeanFromFrequency,si as getCircleCircumference,Zo as getColorsDelta,ui as getEllipseCircumference,to as getLinearEquationBy2Points,li as getMedian,yi as getMode,V as getRandom,Ln as getRandomBoolean,Do as getRandomGrayscaleHSLColor,St as getRandomHSLColor,Ao as getRandomHSLColorWithHue,Co as getRandomHSLColorWithLightness,No as getRandomHSLColorWithSaturation,Xo as getRandomHSLColorWithinRanges,qo as getRandomHexColor,_t as getRandomInt,$n as getRandomItemFromArray,Eo as getRandomRGBColor,ko as getShiftedHue,Fo as getShiftedLightness,Qo as getShiftedSaturation,mi as getSquareInCircleSide,Ht as getStandardDeviation,L as getV2Angle,Sr as getV2AngleBetween,dr as getV2AngleInEllipse,Rr as getV3AngleBetween,qt as getVNAngleBetween,ur as getVariance,Ii as getVariance1,Wo as guid,Oo as hexToRgb,sr as hslToHex,cr as hslToRgb,me as identity2,ae as identity3,fe as identity4,pe as identityN,wr as isAngleBetween,xi as isAngleInCircleArc,J as isClockwise,B as isNumber,Te as isSingularMatrix,jo as labToRgb,q as linearEquation,Kn as linearEquationSystem2,Jn as linearEquationSystem3,Pn as linearEquationSystemN,Ho as lissajousCurve,Mt as m2Adjugate,Ve as m2AppendRow,ut as m2DeepCopy,pt as m2Determinant,Ct as m2DivideScalar,bt as m2Inverse,Pr as m2MulScalar,Ie as m2PrependRow,fn as m2ReflectionOrigin,pn as m2ReflectionOriginH,Vn as m2ReflectionX,ln as m2ReflectionXH,yn as m2ReflectionY,In as m2ReflectionYH,bn as m2ReflectionYmX,oe as m2Reset,Oe as m2RotateAroundPointH,Xt as m2Rotation,Yt as m2RotationAroundPointH,lt as m2RotationH,Ft as m2Scale,Ke as m2ScaleAtPointH,kt as m2ScaleAtPointHMatrix,Qt as m2ScaleH,rn as m2ScaleX,en as m2ScaleXH,mn as m2ScaleY,an as m2ScaleYH,Hn as m2ShearingX,zn as m2ShearingY,Kr as m2Sub,Wr as m2Sum,Ae as m2ToCSS,Xe as m2Translation,G as m2TranslationH,ee as m2Transpose,Ne as m2hToCSS,Ce as m2hToCSS3d,ce as m2x2,Be as m3Adjugate,le as m3AppendRow,xt as m3DeepCopy,He as m3Determinant,re as m3DivideScalar,Vt as m3Inverse,te as m3MulScalar,de as m3PrependRow,Mn as m3ReflectionOrigin,hn as m3ReflectionOriginH,Rn as m3ReflectionXY,wn as m3ReflectionXYH,gn as m3ReflectionXZ,Sn as m3ReflectionXZH,dn as m3ReflectionYZ,vn as m3ReflectionYZH,ie as m3Reset,Gt as m3RotationX,Fe as m3RotationXH,Ot as m3RotationY,Ze as m3RotationYH,jt as m3RotationZ,We as m3RotationZH,Zt as m3Scale,Pe as m3ScaleH,nn as m3ScaleX,on as m3ScaleXH,cn as m3ScaleY,sn as m3ScaleYH,un as m3ScaleZ,xn as m3ScaleZH,Jr as m3Sub,Ur as m3Sum,Ye as m3Translation,Ge as m3TranslationH,ne as m3Transpose,De as m3hToCSS3d,se as m3x3,ue as m4x4,ht as mAdjugate,Me as mAppendCol,be as mAppendRow,I as mDeepCopy,Se as mDelFirstColumn,ge as mDelFirstRow,mt as mDelLastColumn,ve as mDelLastRow,Y as mDeterminant,Q as mDivideScalar,ze as mEqual,we as mGetColumn,Re as mGetFirstColumn,at as mGetLastColumn,Z as mInverse,ft as mMinor,E as mMul,ct as mMulScalar,b as mMulVector,xe as mNxM,he as mPrependCol,ye as mPrependRow,st as mReset,it as mSub,ot as mSum,X as mTranspose,Bt as mlNormalizeArray,Ri as mlNormalizeTestData,wi as mlNormalizeUnseenData,xr as mlNormalizeValue,Tt as mlStandardizeArray,zi as mlStandardizeTestData,Hi as mlStandardizeUnseenData,mr as mlStandardizeValue,y as mod,pi as naturalNumbersSequenceSum,Uo as newId,zr as percentToAngle,br as polarToCartesian,vr as radiansToDegrees,ti as rectCollide,Go as rgbToHex,Yo as rgbToHsl,gt as rgbToLab,s as setDecimalPlaces,K as setV2Angle,zo as sineWaveMovement,qn as stringToNumber,jr as v2,yo as v2CubicBezierBBox,Ut as v2CubicBezierCurve,tr as v2CubicBezierCurveExtrema,Vo as v2CubicBezierCurveNormal,Jt as v2CubicBezierCurveTangent,Xr as v2Distance,Ar as v2DivideScalar,tt as v2DotProduct,Qr as v2FromPolarCoords,nt as v2GetNormal,P as v2Length,qr as v2MulScalar,$ as v2Normalize,lo as v2QuadraticBezierBBox,Wt as v2QuadraticBezierCurve,Pt as v2QuadraticBezierCurveExtrema,bo as v2QuadraticBezierCurveNormal,Kt as v2QuadraticBezierCurveTangent,je as v2Rotate,ke as v2RotateH,Je as v2Scale,Nt as v2SetLength,w as v2Sub,Lr as v2Sum,kr as v3,Or as v3CrossProduct,po as v3CubicBezierCurve,ho as v3CubicBezierCurveTangent,Yr as v3Distance,Nr as v3DivideScalar,Gr as v3DotProduct,Cr as v3Length,F as v3MulScalar,g as v3Normalize,fo as v3QuadraticBezierCurve,Mo as v3QuadraticBezierCurveTangent,Qe as v3RotateX,_e as v3RotateY,Ue as v3RotateZ,tn as v3Scale,Er as v3Sub,$r as v3Sum,Fr as v4,Dr as vDistance,D 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}; + )`,Xe=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],Ye=(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]],Ge=(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]],Xt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},lt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Yt=(t,r,e=!0,n=1/0)=>{let o=G(r,n),i=lt(t,e,n),c=G(F(r,-1),n),u=E(o,i);return E(u,c)},Oe=(t,r,e,n=!0,o=1/0)=>{let i=Yt(t,r,n,o);return h(i,e)},je=(t,r,e=!0,n=1/0)=>{let o=$(r);return h(Xt(t,e,n),o)},ke=(t,r,e=!0,n=1/0)=>{let o=g(r);return h(lt(t,e,n),o)},Gt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},Fe=(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]]},Qe=(t,r,e=!0,n=1/0)=>{let o=g(r);return h(Gt(t,e,n),o)},Ot=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},Ze=(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]]},_e=(t,r,e=!0,n=1/0)=>{let o=g(r);return h(Ot(t,e,n),o)},jt=(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]]},We=(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]]},Ue=(t,r,e=!0,n=1/0)=>{let o=g(r);return h(jt(t,e,n),o)},kt=(t,r,e=1/0)=>{let n=G(r,e),o=Qt(t),i=G(F(r,-1),e),c=E(n,o);return E(c,i)},Ke=(t,r,e,n=1/0)=>{let o=kt(t,r,n);return h(o,e)},Ft=t=>[[t[0],0],[0,t[1]]],Je=(t,r)=>h(Ft(t),r),Qt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Zt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Pe=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],tn=(t,r)=>h(Zt(t),r),rn=t=>[[t,0],[0,1]],en=t=>[[t,0,0],[0,1,0],[0,0,1]],nn=t=>[[t,0,0],[0,1,0],[0,0,1]],on=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],cn=t=>[[1,0,0],[0,t,0],[0,0,1]],sn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],un=t=>[[1,0,0],[0,1,0],[0,0,t]],xn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],mn=t=>[[1,0],[0,t]],an=t=>[[1,0,0],[0,t,0],[0,0,1]],fn=()=>[[-1,0],[0,-1]],pn=()=>[[-1,0,0],[0,-1,0],[0,0,1]],Mn=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],bn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],hn=()=>[[0,-1],[-1,0]],Vn=()=>[[1,0],[0,-1]],ln=()=>[[1,0,0],[0,-1,0],[0,0,1]],yn=()=>[[-1,0],[0,1]],In=()=>[[-1,0,0],[0,1,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=()=>[[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=()=>[[1,0,0],[0,1,0],[0,0,-1]],wn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],zn=t=>[[1,t],[0,1]],Hn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),_t=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Ln=()=>Math.random()<.5,$n=t=>{let r=_t(0,t.length-1);return t[r]};var qn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var Cn=(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)},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)]},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,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)]},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,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)]},Dn=(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/b(Math.cos(t),2),r),Gn=(t,r=1/0)=>s(-1/b(Math.sin(t),2),r),On=(t,r=1/0)=>s(1/Math.sqrt(1-b(t,2)),r),jn=(t,r=1/0)=>s(-1/Math.sqrt(1-b(t,2)),r),kn=(t,r=1/0)=>s(1/(1+b(t,2)),r),Fn=(t,r=1/0)=>s(-1/(1+b(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)},Kn=(t,r,e=1/0)=>{let n=[[t[0],t[1]],[r[0],r[1]]],o=ht(n);if(o===null)return null;let i=[t[2],r[2]];return h(o,i,e)},Jn=(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 h(i,c,n)},Pn=(t,r=1/0)=>{if(t.length<=0)return null;let e=mt(t),n=Z(e);if(n===null)return null;let o=at(t);return h(n,o,r)},to=(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 _=(t,r=1/0)=>{let e=t[0],n=t[1],o=t[2],i=t[3];if(e===0){let f=q([n,o,i],r);return T(f)?[f]:[]}let 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 Wt=(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)]},fo=(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)]},Ut=(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)]},po=(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)]},Kt=(t,r,e,n,o=1/0)=>{let i=yt(t,r,e,n);return $(i,o)},Mo=(t,r,e,n,o=1/0)=>{let i=It(t,r,e,n);return g(i,o)},Jt=(t,r,e,n,o,i=1/0)=>{let c=dt(t,r,e,n,o);return $(c,i)},bo=(t,r,e,n,o,i=1/0)=>{let c=vt(t,r,e,n,o);return g(c,i)},ho=(t,r,e,n,o=1/0)=>{let i=Kt(t,r,e,n,o);return[-i[1],i[0]]},Vo=(t,r,e,n,o,i=1/0)=>{let c=Jt(t,r,e,n,o,i);return[-c[1],c[0]]},Pt=(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],m=-2*t[1]+2*r[1],p=q([x,m,0],n),a=[];return T(u)&&a.push(u),T(p)&&a.push(p),a},tr=(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=_(x,o).filter(l=>l>=0&&l<=1),v=_(a,o).filter(l=>l>=0&&l<=1);return[...M,...v].length===2?[...M,...v]:null},lo=(t,r,e,n=1/0)=>{let o=Pt(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=Wt(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}},yo=(t,r,e,n,o=1/0)=>{let i=tr(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=Ut(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 rr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Ro=(t,r,e)=>{let n=w(t,r),o=L(n);return o=j(o,0,Math.PI*2,0,Math.PI),rr(r,o,e)},er=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),wo=(t,r,e)=>{let n=w(t,r),o=L(n);return o=j(o,0,Math.PI*2,0,Math.PI),er(r,o,e[0],e[1])},zo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},Ho=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Eo=()=>{let t=St();return cr(t)},qo=()=>{let t=St();return sr(t)},St=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Ao=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},No=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},Co=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Do=()=>[0,0,V(0,100)],Xo=(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]},nr=t=>(t*=60,t<0&&(t+=360),t),or=(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),ir=(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)),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=Rt(e,n,o,i,c),x=ir(e,n,o,i,c,u),m=or(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)]},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),cr=(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=W(i,c,u),p=W(i,c,x),a=W(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)]},sr=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)}`},Go=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},Oo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,x,m,f)=>x+x+m+m+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),c=parseInt(n[3],16);return[o,i,c]},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)]},jo=(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)]},ko=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=y(e,360)),[e,t[1],t[2]]},Fo=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=y(e,100)),[t[0],t[1],e]},Qo=(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=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]),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,v=i/1,H=f/a,l=p/M,A=v*v+H*H+l*l;return A<0?0:Math.sqrt(A)};var Wo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),Uo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var ti=(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,ri=(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 oi=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,c=!1,u,x=()=>{e=void 0,o=void 0,i=void 0,c=!1,n!==void 0&&window.cancelAnimationFrame(n)},m=()=>{x(),v()},f=()=>{c=!1},p=()=>{c=!0},a=R=>{e===void 0&&(e=R),o=R-e,c&&i!==R&&typeof t.callback=="function"&&t.callback(U()),o<=r?(i=R,n=window.requestAnimationFrame(a)):x()},M=(R,Et)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(R,Et)},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(a)},H=()=>o,l=()=>c,A=()=>e,Lt=()=>{if(!(r===1/0||o===void 0))return o*100/r},$t=()=>u,U=()=>({start:v,stop:x,pause:f,resume:p,restart:m,isAnimating:l,getElapsedTime:H,getStartTime:A,getPercent:Lt,getResizeObserver:$t});return U()};var si=(t,r=1/0)=>s(2*Math.PI*t,r),ui=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((b(t,2)+b(r,2))/2),e),xi=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),mi=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var pi=t=>t*(t+1)/2,Mi=(t,r,e)=>t/2*(2*r+(t-1)*e);var O=(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)},Vi=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return s(e,r)},li=(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)},yi=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},Ii=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+b(i-e,2),0);return s(n/t.length,r)},ur=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=O(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+b(i,2),0);return s(n/t.length-b(e,2),r)},Ht=(t,r=1/0)=>{var n;let e=(n=ur(t))!=null?n:0;return s(Math.sqrt(e),r)};var xr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:s((t-r)/o,n)},Tt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Tt(t,e,n,r);return{min:s(e,r),max:s(n,r),data:o}},wi=(t,r,e,n=1/0)=>Tt(t,r,e,n),mr=(t,r,e,n=1/0)=>e===0?0:s((t-r)/e,n),Bt=(t,r,e,n=1/0)=>[...t].map(o=>mr(o,r,e,n)),zi=(t,r=1/0)=>{var i;let e=(i=O(t))!=null?i:0,n=Ht(t),o=Bt(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}},Hi=(t,r,e,n=1/0)=>Bt(t,r,e,n);var Bi=t=>t/2*(t+1),Li=(t,r)=>(r-t+1)*(t+r)/2;export{oi as animate,Mi as arithmeticSequenceSum,ri as circleCollide,rr as circleMovement,Ro as circleMovementAfterMouse,j as convertRange,ei as convexPolygonsCollide,gr as degreesToRadians,br as doRangesOverlap,jn as dxArcCos,Fn as dxArcCot,On as dxArcSin,kn as dxArcTan,Xn as dxCos,Gn as dxCot,Cn as dxPolynomial,Dn as dxSin,Yn as dxTan,dt as dxV2CubicBezierCurve,yt as dxV2QuadraticBezierCurve,vt as dxV3CubicBezierCurve,It as dxV3QuadraticBezierCurve,er as ellipseMovement,wo as ellipseMovementAfterMouse,At as getAnglesDistance,k as getAnglesSub,O as getArithmeticMean,Vi as getArithmeticMeanFromFrequency,si as getCircleCircumference,Zo as getColorsDelta,ui as getEllipseCircumference,to as getLinearEquationBy2Points,li as getMedian,yi as getMode,V as getRandom,Ln as getRandomBoolean,Do as getRandomGrayscaleHSLColor,St as getRandomHSLColor,Ao as getRandomHSLColorWithHue,Co as getRandomHSLColorWithLightness,No as getRandomHSLColorWithSaturation,Xo as getRandomHSLColorWithinRanges,qo as getRandomHexColor,_t as getRandomInt,$n as getRandomItemFromArray,Eo as getRandomRGBColor,ko as getShiftedHue,Fo as getShiftedLightness,Qo as getShiftedSaturation,mi as getSquareInCircleSide,Ht as getStandardDeviation,L as getV2Angle,Sr as getV2AngleBetween,dr as getV2AngleInEllipse,Rr as getV3AngleBetween,qt as getVNAngleBetween,ur as getVariance,Ii as getVariance1,Wo as guid,Oo as hexToRgb,sr as hslToHex,cr as hslToRgb,me as identity2,ae as identity3,fe as identity4,pe as identityN,wr as isAngleBetween,xi as isAngleInCircleArc,J as isClockwise,T as isNumber,Be as isSingularMatrix,jo as labToRgb,q as linearEquation,Kn as linearEquationSystem2,Jn as linearEquationSystem3,Pn as linearEquationSystemN,Ho as lissajousCurve,Mt as m2Adjugate,Ve as m2AppendRow,ut as m2DeepCopy,pt as m2Determinant,Ct as m2DivideScalar,ht as m2Inverse,Pr as m2MulScalar,Ie as m2PrependRow,fn as m2ReflectionOrigin,pn as m2ReflectionOriginH,Vn as m2ReflectionX,ln as m2ReflectionXH,yn as m2ReflectionY,In as m2ReflectionYH,hn as m2ReflectionYmX,oe as m2Reset,Oe as m2RotateAroundPointH,Xt as m2Rotation,Yt as m2RotationAroundPointH,lt as m2RotationH,Ft as m2Scale,Ke as m2ScaleAtPointH,kt as m2ScaleAtPointHMatrix,Qt as m2ScaleH,rn as m2ScaleX,en as m2ScaleXH,mn as m2ScaleY,an as m2ScaleYH,Hn as m2ShearingX,zn as m2ShearingY,Kr as m2Sub,Wr as m2Sum,Ae as m2ToCSS,Xe as m2Translation,G as m2TranslationH,ee as m2Transpose,Ne as m2hToCSS,Ce as m2hToCSS3d,ce as m2x2,Te as m3Adjugate,le as m3AppendRow,xt as m3DeepCopy,He as m3Determinant,re as m3DivideScalar,Vt as m3Inverse,te as m3MulScalar,de as m3PrependRow,Mn as m3ReflectionOrigin,bn as m3ReflectionOriginH,Rn as m3ReflectionXY,wn as m3ReflectionXYH,gn as m3ReflectionXZ,Sn as m3ReflectionXZH,dn as m3ReflectionYZ,vn as m3ReflectionYZH,ie as m3Reset,Gt as m3RotationX,Fe as m3RotationXH,Ot as m3RotationY,Ze as m3RotationYH,jt as m3RotationZ,We as m3RotationZH,Zt as m3Scale,Pe as m3ScaleH,nn as m3ScaleX,on as m3ScaleXH,cn as m3ScaleY,sn as m3ScaleYH,un as m3ScaleZ,xn as m3ScaleZH,Jr as m3Sub,Ur as m3Sum,Ye as m3Translation,Ge as m3TranslationH,ne as m3Transpose,De as m3hToCSS3d,se as m3x3,ue as m4x4,bt as mAdjugate,Me as mAppendCol,he as mAppendRow,I as mDeepCopy,Se as mDelFirstColumn,ge as mDelFirstRow,mt as mDelLastColumn,ve as mDelLastRow,Y as mDeterminant,Q as mDivideScalar,ze as mEqual,we as mGetColumn,Re as mGetFirstColumn,at as mGetLastColumn,Z as mInverse,ft as mMinor,E as mMul,ct as mMulScalar,h as mMulVector,xe as mNxM,be as mPrependCol,ye as mPrependRow,st as mReset,it as mSub,ot as mSum,X as mTranspose,Tt as mlNormalizeArray,Ri as mlNormalizeTestData,wi as mlNormalizeUnseenData,xr as mlNormalizeValue,Bt as mlStandardizeArray,zi as mlStandardizeTestData,Hi as mlStandardizeUnseenData,mr as mlStandardizeValue,y as mod,pi as naturalNumbersSequenceSum,Bi as naturalNumbersSum1ToN,Li as naturalNumbersSumMToN,Uo as newId,zr as percentToAngle,hr as polarToCartesian,vr as radiansToDegrees,ti as rectCollide,Go as rgbToHex,Yo as rgbToHsl,gt as rgbToLab,s as setDecimalPlaces,K as setV2Angle,zo as sineWaveMovement,qn as stringToNumber,jr as v2,yo as v2CubicBezierBBox,Ut as v2CubicBezierCurve,tr as v2CubicBezierCurveExtrema,Vo as v2CubicBezierCurveNormal,Jt as v2CubicBezierCurveTangent,Xr as v2Distance,Ar as v2DivideScalar,tt as v2DotProduct,Qr as v2FromPolarCoords,nt as v2GetNormal,P as v2Length,qr as v2MulScalar,$ as v2Normalize,lo as v2QuadraticBezierBBox,Wt as v2QuadraticBezierCurve,Pt as v2QuadraticBezierCurveExtrema,ho as v2QuadraticBezierCurveNormal,Kt as v2QuadraticBezierCurveTangent,je as v2Rotate,ke as v2RotateH,Je as v2Scale,Nt as v2SetLength,w as v2Sub,Lr as v2Sum,kr as v3,Or as v3CrossProduct,po as v3CubicBezierCurve,bo as v3CubicBezierCurveTangent,Yr as v3Distance,Nr as v3DivideScalar,Gr as v3DotProduct,Cr as v3Length,F as v3MulScalar,g as v3Normalize,fo as v3QuadraticBezierCurve,Mo as v3QuadraticBezierCurveTangent,Qe as v3RotateX,_e as v3RotateY,Ue as v3RotateZ,tn as v3Scale,Er as v3Sub,$r as v3Sum,Fr as v4,Dr as vDistance,D as vDivideScalar,S as vDotProduct,et as vEqual,z as vLength,C as vMulScalar,rt as vN,B as vNormalize,d 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 24df80aa..c1d04eb8 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 = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};"], - "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,KAA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efficient", "__pow", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "stringToNumber", "value", "defaultNumber", "_a", "res", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "x", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "guid", "c", "newId", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "naturalNumbersSequenceSum", "n", "arithmeticSequenceSum", "a", "d", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData"] + "sources": ["../src/main/format.ts", "../src/main/other.ts", "../src/main/angle.ts", "../src/main/linear-algebra/vector.ts", "../src/main/linear-algebra/matrix.ts", "../src/main/linear-algebra/matrix-transformations.ts", "../src/main/random.ts", "../src/main/convert.ts", "../src/main/derivative.ts", "../src/main/equations/linear-equations.ts", "../src/main/equations/quadratic-equations.ts", "../src/main/bezier-curves/bezier-curve.ts", "../src/main/path-movement.ts", "../src/main/color.ts", "../src/main/id.ts", "../src/main/collision-detection.ts", "../src/main/animation.ts", "../src/main/circle-ellipse.ts", "../src/main/sequence.ts", "../src/main/statistics.ts", "../src/main/ml.ts", "../src/main/series.ts"], + "sourcesContent": ["export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};"], + "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,EA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B,GAAyBC,GAC1BA,EAAI,GAAMA,EAAI,GAMbC,GAAwB,CAACC,EAAWF,KACrCA,EAAIE,EAAI,IAAMA,EAAIF,GAAK", + "names": ["setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "stringToNumber", "value", "defaultNumber", "_a", "res", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "x", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "guid", "c", "newId", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "naturalNumbersSequenceSum", "n", "arithmeticSequenceSum", "a", "d", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "naturalNumbersSum1ToN", "n", "naturalNumbersSumMToN", "m"] } diff --git a/dist/mz-math.min.js b/dist/mz-math.min.js index a371565a..ca596bc6 100644 --- a/dist/mz-math.min.js +++ b/dist/mz-math.min.js @@ -1,14 +1,14 @@ /* -mzMath v3.0.24 +mzMath v3.0.25 A collection of TypeScript-based math helpers. 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 Jt=Object.defineProperty;var Ut=Object.getOwnPropertySymbols;var qr=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable;var V=Math.pow,Kt=(t,r,e)=>r in t?Jt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,h=(t,r)=>{for(var e in r||(r={}))qr.call(r,e)&&Kt(t,e,r[e]);if(Ut)for(var e of Ut(r))Er.call(r,e)&&Kt(t,e,r[e]);return t};var b=(t,r)=>{for(var e in r)Jt(t,e,{get:r[e],enumerable:!0})};var ct={};b(ct,{v2:()=>ee,v2Distance:()=>Jr,v2DivideScalar:()=>_r,v2DotProduct:()=>et,v2FromPolarCoords:()=>ie,v2GetNormal:()=>it,v2Length:()=>rt,v2MulScalar:()=>Zr,v2Normalize:()=>q,v2SetLength:()=>rr,v2Sub:()=>z,v2Sum:()=>kr,v3:()=>ne,v3CrossProduct:()=>re,v3Distance:()=>Pr,v3DivideScalar:()=>Wr,v3DotProduct:()=>te,v3Length:()=>Ur,v3MulScalar:()=>Z,v3Normalize:()=>S,v3Sub:()=>Qr,v3Sum:()=>Fr,v4:()=>oe,vDistance:()=>Kr,vDivideScalar:()=>X,vDotProduct:()=>R,vEqual:()=>ot,vLength:()=>H,vMulScalar:()=>D,vN:()=>nt,vNormalize:()=>L,vSub:()=>g,vSum:()=>C});var U={};b(U,{setDecimalPlaces:()=>s});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 tt={};b(tt,{degreesToRadians:()=>Xr,getAnglesDistance:()=>tr,getAnglesSub:()=>Q,getV2Angle:()=>$,getV2AngleBetween:()=>Yr,getV2AngleInEllipse:()=>Cr,getV3AngleBetween:()=>Gr,getVNAngleBetween:()=>Pt,isAngleBetween:()=>Or,isClockwise:()=>P,percentToAngle:()=>jr,radiansToDegrees:()=>Dr,setV2Angle:()=>J});var K={};b(K,{convertRange:()=>F,doRangesOverlap:()=>Ar,isNumber:()=>T,mod:()=>d,polarToCartesian:()=>Nr});var d=(t,r)=>(t%r+r)%r,F=(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),T=t=>!isNaN(parseFloat(t))&&isFinite(t),Nr=(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)},Cr=(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=rt(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)},Xr=(t,r=1/0)=>{let e=t*(Math.PI/180);return s(e,r)},Pt=(t,r,e=1/0)=>{let n=L(t),o=L(r),i=R(n,o),c=Math.acos(i);return s(c,e)},Yr=(t,r,e=1/0)=>{let n=g(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},Gr=(t,r,e=1/0)=>Pt(t,r,e),Or=(t,r,e)=>{let n=Q(r,e),o=Q(r,t),i=Q(e,t),c=o+i;return Math.abs(c-n)<=.001},P=(t,r,e=0)=>(t=t%360,r=r%360,t=t),Q=(t,r,e=1/0)=>{let n=Math.abs(d(t,360)-d(r,360));return s(n<=180?n:360-n,e)},tr=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=tr(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),Fr=(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),Qr=(t,r,e=1/0)=>g(t,r,e),D=(t,r,e=1/0)=>{let n=[];for(let o=0;oD(t,r,e),Z=(t,r,e=1/0)=>D(t,r,e),X=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oX(t,r,e),Wr=(t,r,e=1/0)=>X(t,r,e),H=(t,r=1/0)=>{let e=0;for(let n=0;nH(t,r),Ur=(t,r=1/0)=>H(t,r),rr=(t,r,e=1/0)=>{let n=$(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,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)},Pr=(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),te=(t,r,e=1/0)=>R(t,r,e),re=(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)],ee=(t=0)=>[t,t],ne=(t=0)=>[t,t,t],oe=(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=rr(e,t),J(e,r)},ot=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=z(r,t);return[-s(n[1],e),s(n[0],e)]};var It={};b(It,{identity2:()=>Ie,identity3:()=>ve,identity4:()=>ge,identityN:()=>Se,isSingularMatrix:()=>Oe,m2Adjugate:()=>Vt,m2AppendRow:()=>He,m2DeepCopy:()=>at,m2Determinant:()=>bt,m2DivideScalar:()=>er,m2Inverse:()=>yt,m2MulScalar:()=>xe,m2PrependRow:()=>Le,m2Reset:()=>he,m2Sub:()=>ue,m2Sum:()=>ce,m2Transpose:()=>pe,m2x2:()=>Ve,m3Adjugate:()=>Ge,m3AppendRow:()=>Be,m3DeepCopy:()=>ft,m3Determinant:()=>Ye,m3DivideScalar:()=>fe,m3Inverse:()=>dt,m3MulScalar:()=>ae,m3PrependRow:()=>$e,m3Reset:()=>be,m3Sub:()=>me,m3Sum:()=>se,m3Transpose:()=>Me,m3x3:()=>le,m4x4:()=>ye,mAdjugate:()=>lt,mAppendCol:()=>we,mAppendRow:()=>ze,mDeepCopy:()=>I,mDelFirstColumn:()=>Ae,mDelFirstRow:()=>Ee,mDelLastColumn:()=>pt,mDelLastRow:()=>qe,mDeterminant:()=>G,mDivideScalar:()=>_,mEqual:()=>De,mGetColumn:()=>Ce,mGetFirstColumn:()=>Ne,mGetLastColumn:()=>Mt,mInverse:()=>W,mMinor:()=>ht,mMul:()=>E,mMulScalar:()=>mt,mMulVector:()=>l,mNxM:()=>de,mPrependCol:()=>Re,mPrependRow:()=>Te,mReset:()=>xt,mSub:()=>ut,mSum:()=>st,mTranspose:()=>Y});var st=(t,r,e=1/0)=>{let n=[];for(let o=0;ost(t,r,e),se=(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),me=(t,r,e=1/0)=>ut(t,r,e),mt=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(D(o,r,e));return n},xe=(t,r,e=1/0)=>mt(t,r,e),ae=(t,r,e=1/0)=>mt(t,r,e),_=(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},er=(t,r,e=1/0)=>_(t,r,e),fe=(t,r,e=1/0)=>_(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),Me=t=>Y(t),xt=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nxt(t,r),be=(t,r=0)=>xt(t,r),Ve=(t=0)=>[[t,t],[t,t]],le=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],ye=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],de=(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]],ve=()=>[[1,0,0],[0,1,0],[0,0,1]],ge=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Se=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),we=(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},He=(t,r)=>{let e=at(t);return e.push(r),e},Be=(t,r)=>{let e=ft(t);return e.push(r),e},Te=(t,r)=>{let e=I(t);return e.unshift(r),e},Le=(t,r)=>{let e=at(t);return e.unshift(r),e},$e=(t,r)=>{let e=ft(t);return e.unshift(r),e},qe=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},Ee=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=Xe(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]},Ye=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]]]},Ge=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:er(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:_(o,n,r)};var gt={};b(gt,{m2ReflectionOrigin:()=>dn,m2ReflectionOriginH:()=>In,m2ReflectionX:()=>wn,m2ReflectionXH:()=>Rn,m2ReflectionY:()=>zn,m2ReflectionYH:()=>Hn,m2ReflectionYmX:()=>Sn,m2RotateAroundPointH:()=>Ue,m2Rotation:()=>nr,m2RotationAroundPointH:()=>or,m2RotationH:()=>vt,m2Scale:()=>mr,m2ScaleAtPointH:()=>cn,m2ScaleAtPointHMatrix:()=>ur,m2ScaleH:()=>xr,m2ScaleX:()=>xn,m2ScaleXH:()=>an,m2ScaleY:()=>ln,m2ScaleYH:()=>yn,m2ShearingX:()=>Nn,m2ShearingY:()=>An,m2ToCSS:()=>je,m2Translation:()=>Ze,m2TranslationH:()=>O,m2hToCSS:()=>ke,m2hToCSS3d:()=>Fe,m3ReflectionOrigin:()=>vn,m3ReflectionOriginH:()=>gn,m3ReflectionXY:()=>qn,m3ReflectionXYH:()=>En,m3ReflectionXZ:()=>Ln,m3ReflectionXZH:()=>$n,m3ReflectionYZ:()=>Bn,m3ReflectionYZH:()=>Tn,m3RotationX:()=>ir,m3RotationXH:()=>Pe,m3RotationY:()=>cr,m3RotationYH:()=>rn,m3RotationZ:()=>sr,m3RotationZH:()=>nn,m3Scale:()=>ar,m3ScaleH:()=>un,m3ScaleX:()=>fn,m3ScaleXH:()=>pn,m3ScaleY:()=>Mn,m3ScaleYH:()=>hn,m3ScaleZ:()=>bn,m3ScaleZH:()=>Vn,m3Translation:()=>_e,m3TranslationH:()=>We,m3hToCSS3d:()=>Qe,v2Rotate:()=>Ke,v2RotateH:()=>Je,v2Scale:()=>sn,v3RotateX:()=>tn,v3RotateY:()=>en,v3RotateZ:()=>on,v3Scale:()=>mn});var je=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)`},ke=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})`},Fe=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 Pt=Object.defineProperty;var Kt=Object.getOwnPropertySymbols;var Er=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable;var V=Math.pow,Jt=(t,r,e)=>r in t?Pt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,b=(t,r)=>{for(var e in r||(r={}))Er.call(r,e)&&Jt(t,e,r[e]);if(Kt)for(var e of Kt(r))Ar.call(r,e)&&Jt(t,e,r[e]);return t};var h=(t,r)=>{for(var e in r)Pt(t,e,{get:r[e],enumerable:!0})};var st={};h(st,{v2:()=>ne,v2Distance:()=>Pr,v2DivideScalar:()=>Wr,v2DotProduct:()=>et,v2FromPolarCoords:()=>se,v2GetNormal:()=>it,v2Length:()=>rt,v2MulScalar:()=>_r,v2Normalize:()=>q,v2SetLength:()=>er,v2Sub:()=>z,v2Sum:()=>Fr,v3:()=>oe,v3CrossProduct:()=>ee,v3Distance:()=>te,v3DivideScalar:()=>Ur,v3DotProduct:()=>re,v3Length:()=>Kr,v3MulScalar:()=>Z,v3Normalize:()=>S,v3Sub:()=>Zr,v3Sum:()=>Qr,v4:()=>ie,vDistance:()=>Jr,vDivideScalar:()=>X,vDotProduct:()=>R,vEqual:()=>ot,vLength:()=>T,vMulScalar:()=>D,vN:()=>nt,vNormalize:()=>L,vSub:()=>g,vSum:()=>C});var U={};h(U,{setDecimalPlaces:()=>c});var c=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=V(10,r);return Math.round(t*e)/e};var tt={};h(tt,{degreesToRadians:()=>Yr,getAnglesDistance:()=>rr,getAnglesSub:()=>Q,getV2Angle:()=>$,getV2AngleBetween:()=>Gr,getV2AngleInEllipse:()=>Dr,getV3AngleBetween:()=>Or,getVNAngleBetween:()=>tr,isAngleBetween:()=>jr,isClockwise:()=>P,percentToAngle:()=>kr,radiansToDegrees:()=>Xr,setV2Angle:()=>J});var K={};h(K,{convertRange:()=>F,doRangesOverlap:()=>Nr,isNumber:()=>B,mod:()=>d,polarToCartesian:()=>Cr});var d=(t,r)=>(t%r+r)%r,F=(t,r,e,n,o)=>(o-n)*(t-r)/(e-r)+n,Nr=(t,r,e,n)=>Math.max(t,e)<=Math.min(r,n),B=t=>!isNaN(parseFloat(t))&&isFinite(t),Cr=(t,r,e,n=1/0)=>{let[o,i]=t,[s,u]=r;return[c(o+s*Math.cos(e),n),c(i+u*Math.sin(e),n)]};var $=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return c(e,r)},Dr=(t,r,e=1/0)=>{let n=Math.atan2(t[1]/r[1],t[0]/r[0]);return c(n,e)},J=(t,r,e=1/0)=>{let n=rt(t);return[c(Math.cos(r)*n,e),c(Math.sin(r)*n,e)]},Xr=(t,r=1/0)=>{let e=t*(180/Math.PI);return c(e,r)},Yr=(t,r=1/0)=>{let e=t*(Math.PI/180);return c(e,r)},tr=(t,r,e=1/0)=>{let n=L(t),o=L(r),i=R(n,o),s=Math.acos(i);return c(s,e)},Gr=(t,r,e=1/0)=>{let n=g(t,r),o=Math.atan2(n[1],n[0]);return c(o,e)},Or=(t,r,e=1/0)=>tr(t,r,e),jr=(t,r,e)=>{let n=Q(r,e),o=Q(r,t),i=Q(e,t),s=o+i;return Math.abs(s-n)<=.001},P=(t,r,e=0)=>(t=t%360,r=r%360,t=t),Q=(t,r,e=1/0)=>{let n=Math.abs(d(t,360)-d(r,360));return c(n<=180?n:360-n,e)},rr=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=rr(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),Qr=(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),Zr=(t,r,e=1/0)=>g(t,r,e),D=(t,r,e=1/0)=>{let n=[];for(let o=0;oD(t,r,e),Z=(t,r,e=1/0)=>D(t,r,e),X=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o=0;oX(t,r,e),Ur=(t,r,e=1/0)=>X(t,r,e),T=(t,r=1/0)=>{let e=0;for(let n=0;nT(t,r),Kr=(t,r=1/0)=>T(t,r),er=(t,r,e=1/0)=>{let n=$(t);return[c(Math.cos(n)*r,e),c(Math.sin(n)*r,e)]},Jr=(t,r,e=1/0)=>{let n=g(t,r);return T(n,e)},Pr=(t,r,e=1/0)=>{let n=g(t,r);return T(n,e)},te=(t,r,e=1/0)=>{let n=g(t,r);return T(n,e)},L=(t,r=1/0)=>{let e=T(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),re=(t,r,e=1/0)=>R(t,r,e),ee=(t,r,e=1/0)=>[c(t[1]*r[2]-t[2]*r[1],e),c(t[2]*r[0]-t[0]*r[2],e),c(t[0]*r[1]-t[1]*r[0],e)],ne=(t=0)=>[t,t],oe=(t=0)=>[t,t,t],ie=(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=er(e,t),J(e,r)},ot=(t,r)=>{if(t.length!==r.length)return!1;for(let e=0;e{let n=z(r,t);return[-c(n[1],e),c(n[0],e)]};var It={};h(It,{identity2:()=>ve,identity3:()=>ge,identity4:()=>Se,identityN:()=>we,isSingularMatrix:()=>je,m2Adjugate:()=>Vt,m2AppendRow:()=>He,m2DeepCopy:()=>at,m2Determinant:()=>ht,m2DivideScalar:()=>nr,m2Inverse:()=>yt,m2MulScalar:()=>ae,m2PrependRow:()=>$e,m2Reset:()=>he,m2Sub:()=>me,m2Sum:()=>ce,m2Transpose:()=>Me,m2x2:()=>le,m3Adjugate:()=>Oe,m3AppendRow:()=>Be,m3DeepCopy:()=>ft,m3Determinant:()=>Ge,m3DivideScalar:()=>pe,m3Inverse:()=>dt,m3MulScalar:()=>fe,m3PrependRow:()=>qe,m3Reset:()=>Ve,m3Sub:()=>xe,m3Sum:()=>ue,m3Transpose:()=>be,m3x3:()=>ye,m4x4:()=>de,mAdjugate:()=>lt,mAppendCol:()=>Re,mAppendRow:()=>Te,mDeepCopy:()=>I,mDelFirstColumn:()=>Ne,mDelFirstRow:()=>Ae,mDelLastColumn:()=>pt,mDelLastRow:()=>Ee,mDeterminant:()=>G,mDivideScalar:()=>_,mEqual:()=>Xe,mGetColumn:()=>De,mGetFirstColumn:()=>Ce,mGetLastColumn:()=>Mt,mInverse:()=>W,mMinor:()=>bt,mMul:()=>E,mMulScalar:()=>mt,mMulVector:()=>l,mNxM:()=>Ie,mPrependCol:()=>ze,mPrependRow:()=>Le,mReset:()=>xt,mSub:()=>ut,mSum:()=>ct,mTranspose:()=>Y});var ct=(t,r,e=1/0)=>{let n=[];for(let o=0;oct(t,r,e),ue=(t,r,e=1/0)=>ct(t,r,e),ut=(t,r,e=1/0)=>{let n=[];for(let o=0;out(t,r,e),xe=(t,r,e=1/0)=>ut(t,r,e),mt=(t,r,e=1/0)=>{let n=[];for(let o of t)n.push(D(o,r,e));return n},ae=(t,r,e=1/0)=>mt(t,r,e),fe=(t,r,e=1/0)=>mt(t,r,e),_=(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},nr=(t,r,e=1/0)=>_(t,r,e),pe=(t,r,e=1/0)=>_(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),be=t=>Y(t),xt=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nxt(t,r),Ve=(t,r=0)=>xt(t,r),le=(t=0)=>[[t,t],[t,t]],ye=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],de=(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]],ge=()=>[[1,0,0],[0,1,0],[0,0,1]],Se=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],we=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),Re=(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},He=(t,r)=>{let e=at(t);return e.push(r),e},Be=(t,r)=>{let e=ft(t);return e.push(r),e},Le=(t,r)=>{let e=I(t);return e.unshift(r),e},$e=(t,r)=>{let e=at(t);return e.unshift(r),e},qe=(t,r)=>{let e=ft(t);return e.unshift(r),e},Ee=t=>{if(t.length<=0)return[];let r=I(t);return r.pop(),r},Ae=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=Ye(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 ht(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]},Ge=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]]]},Oe=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=ht(t);if(e===0)return null;let n=Vt(t);return n===null?null:nr(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:_(o,n,r)};var gt={};h(gt,{m2ReflectionOrigin:()=>In,m2ReflectionOriginH:()=>vn,m2ReflectionX:()=>Rn,m2ReflectionXH:()=>zn,m2ReflectionY:()=>Tn,m2ReflectionYH:()=>Hn,m2ReflectionYmX:()=>wn,m2RotateAroundPointH:()=>Ke,m2Rotation:()=>or,m2RotationAroundPointH:()=>ir,m2RotationH:()=>vt,m2Scale:()=>xr,m2ScaleAtPointH:()=>cn,m2ScaleAtPointHMatrix:()=>mr,m2ScaleH:()=>ar,m2ScaleX:()=>an,m2ScaleXH:()=>fn,m2ScaleY:()=>yn,m2ScaleYH:()=>dn,m2ShearingX:()=>Cn,m2ShearingY:()=>Nn,m2ToCSS:()=>ke,m2Translation:()=>_e,m2TranslationH:()=>O,m2hToCSS:()=>Fe,m2hToCSS3d:()=>Qe,m3ReflectionOrigin:()=>gn,m3ReflectionOriginH:()=>Sn,m3ReflectionXY:()=>En,m3ReflectionXYH:()=>An,m3ReflectionXZ:()=>$n,m3ReflectionXZH:()=>qn,m3ReflectionYZ:()=>Bn,m3ReflectionYZH:()=>Ln,m3RotationX:()=>sr,m3RotationXH:()=>tn,m3RotationY:()=>cr,m3RotationYH:()=>en,m3RotationZ:()=>ur,m3RotationZH:()=>on,m3Scale:()=>fr,m3ScaleH:()=>mn,m3ScaleX:()=>pn,m3ScaleXH:()=>Mn,m3ScaleY:()=>bn,m3ScaleYH:()=>hn,m3ScaleZ:()=>Vn,m3ScaleZH:()=>ln,m3Translation:()=>We,m3TranslationH:()=>Ue,m3hToCSS3d:()=>Ze,v2Rotate:()=>Je,v2RotateH:()=>Pe,v2Scale:()=>un,v3RotateX:()=>rn,v3RotateY:()=>nn,v3RotateZ:()=>sn,v3Scale:()=>xn});var ke=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)`},Fe=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix(${r}, ${e}, ${n}, ${o}, ${i}, ${s})`},Qe=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],s=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${s}, 0, 1)`},Ze=t=>`matrix3d( ${t[0][0]}, ${t[0][1]}, ${t[0][2]}, ${t[0][3]}, ${t[1][0]}, ${t[1][1]}, ${t[1][2]}, ${t[1][3]}, ${t[2][0]}, ${t[2][1]}, ${t[2][2]}, ${t[2][3]}, ${t[3][0]}, ${t[3][1]}, ${t[3][2]}, ${t[3][3]} - )`,Ze=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],_e=(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]],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]],nr=(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]]},or=(t,r,e=!0,n=1/0)=>{let o=O(r,n),i=vt(t,e,n),c=O(Z(r,-1),n),u=E(o,i);return E(u,c)},Ue=(t,r,e,n=!0,o=1/0)=>{let i=or(t,r,n,o);return l(i,e)},Ke=(t,r,e=!0,n=1/0)=>{let o=q(r);return l(nr(t,e,n),o)},Je=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(vt(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?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},Pe=(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]]},tn=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(ir(t,e,n),o)},cr=(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]]},rn=(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]]},en=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(cr(t,e,n),o)},sr=(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]]},nn=(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]]},on=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(sr(t,e,n),o)},ur=(t,r,e=1/0)=>{let n=O(r,e),o=xr(t),i=O(Z(r,-1),e),c=E(n,o);return E(c,i)},cn=(t,r,e,n=1/0)=>{let o=ur(t,r,n);return l(o,e)},mr=t=>[[t[0],0],[0,t[1]]],sn=(t,r)=>l(mr(t),r),xr=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],ar=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],un=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],mn=(t,r)=>l(ar(t),r),xn=t=>[[t,0],[0,1]],an=t=>[[t,0,0],[0,1,0],[0,0,1]],fn=t=>[[t,0,0],[0,1,0],[0,0,1]],pn=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]],hn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],bn=t=>[[1,0,0],[0,1,0],[0,0,t]],Vn=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],ln=t=>[[1,0],[0,t]],yn=t=>[[1,0,0],[0,t,0],[0,0,1]],dn=()=>[[-1,0],[0,-1]],In=()=>[[-1,0,0],[0,-1,0],[0,0,1]],vn=()=>[[-1,0,0],[0,-1,0],[0,0,-1]],gn=()=>[[-1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]],Sn=()=>[[0,-1],[-1,0]],wn=()=>[[1,0],[0,-1]],Rn=()=>[[1,0,0],[0,-1,0],[0,0,1]],zn=()=>[[-1,0],[0,1]],Hn=()=>[[-1,0,0],[0,1,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]],qn=()=>[[1,0,0],[0,1,0],[0,0,-1]],En=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],An=t=>[[1,t],[0,1]],Nn=t=>[[1,0],[t,1]];var St={};b(St,{getRandom:()=>y,getRandomBoolean:()=>Cn,getRandomInt:()=>fr,getRandomItemFromArray:()=>Dn});var y=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),fr=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Cn=()=>Math.random()<.5,Dn=t=>{let r=fr(0,t.length-1);return t[r]};var wt={};b(wt,{stringToNumber:()=>Xn});var Xn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var qt={};b(qt,{v2CubicBezierBBox:()=>co,v2CubicBezierCurve:()=>Mr,v2CubicBezierCurveExtrema:()=>lr,v2CubicBezierCurveNormal:()=>oo,v2CubicBezierCurveTangent:()=>br,v2QuadraticBezierBBox:()=>io,v2QuadraticBezierCurve:()=>pr,v2QuadraticBezierCurveExtrema:()=>Vr,v2QuadraticBezierCurveNormal:()=>no,v2QuadraticBezierCurveTangent:()=>hr,v3CubicBezierCurve:()=>to,v3CubicBezierCurveTangent:()=>eo,v3QuadraticBezierCurve:()=>Pn,v3QuadraticBezierCurveTangent:()=>ro});var Tt={};b(Tt,{dxArcCos:()=>Qn,dxArcCot:()=>_n,dxArcSin:()=>Fn,dxArcTan:()=>Zn,dxCos:()=>On,dxCot:()=>kn,dxPolynomial:()=>Yn,dxSin:()=>Gn,dxTan:()=>jn,dxV2CubicBezierCurve:()=>Ht,dxV2QuadraticBezierCurve:()=>Rt,dxV3CubicBezierCurve:()=>Bt,dxV3QuadraticBezierCurve:()=>zt});var Yn=(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),m=6*t-9*t*t,x=3*t*t;return[s(c*r[0]+u*e[0]+m*n[0]+x*o[0],i),s(c*r[1]+u*e[1]+m*n[1]+x*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),m=6*t-9*t*t,x=3*t*t;return[s(c*r[0]+u*e[0]+m*n[0]+x*o[0],i),s(c*r[1]+u*e[1]+m*n[1]+x*o[1],i),s(c*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},Gn=(t,r=1/0)=>s(Math.cos(t),r),On=(t,r=1/0)=>s(-Math.sin(t),r),jn=(t,r=1/0)=>s(1/V(Math.cos(t),2),r),kn=(t,r=1/0)=>s(-1/V(Math.sin(t),2),r),Fn=(t,r=1/0)=>s(1/Math.sqrt(1-V(t,2)),r),Qn=(t,r=1/0)=>s(-1/Math.sqrt(1-V(t,2)),r),Zn=(t,r=1/0)=>s(1/(1+V(t,2)),r),_n=(t,r=1/0)=>s(-1/(1+V(t,2)),r);var Lt={};b(Lt,{getLinearEquationBy2Points:()=>Jn,linearEquation:()=>A,linearEquationSystem2:()=>Wn,linearEquationSystem3:()=>Un,linearEquationSystemN:()=>Kn});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)},Wn=(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 l(o,i,e)},Un=(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 l(i,c,n)},Kn=(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 l(n,o,r)},Jn=(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,m="";return c===0?m=`y = ${u}`:(m=`y = ${c===1?"":c}x`,u!==0&&(m+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:c,xIntercept:void 0,yIntercept:u,formula:m}};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 m=2*e,x=Math.sqrt(u);return[s((-n+x)/m,r),s((-n-x)/m,r)]};var pr=(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)]},Pn=(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)]},Mr=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[s(c*r[0]+u*e[0]+m*n[0]+x*o[0],i),s(c*r[1]+u*e[1]+m*n[1]+x*o[1],i)]},to=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[s(c*r[0]+u*e[0]+m*n[0]+x*o[0],i),s(c*r[1]+u*e[1]+m*n[1]+x*o[1],i),s(c*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},hr=(t,r,e,n,o=1/0)=>{let i=Rt(t,r,e,n);return q(i,o)},ro=(t,r,e,n,o=1/0)=>{let i=zt(t,r,e,n);return S(i,o)},br=(t,r,e,n,o,i=1/0)=>{let c=Ht(t,r,e,n,o);return q(c,i)},eo=(t,r,e,n,o,i=1/0)=>{let c=Bt(t,r,e,n,o);return S(c,i)},no=(t,r,e,n,o=1/0)=>{let i=hr(t,r,e,n,o);return[-i[1],i[0]]},oo=(t,r,e,n,o,i=1/0)=>{let c=br(t,r,e,n,o,i);return[-c[1],c[0]]},Vr=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=A([o,i,0],n),m=2*t[1]-4*r[1]+2*e[1],x=-2*t[1]+2*r[1],p=A([m,x,0],n),a=[];return T(u)&&a.push(u),T(p)&&a.push(p),a},lr=(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],m=[i,c,u,0],x=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[x,f,p,0],M=$t(m,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},io=(t,r,e,n=1/0)=>{let o=Vr(t,r,e),i=1/0,c=1/0,u=-1/0,m=-1/0;for(let x of o){let f=pr(x,t,r,e),p=f[0],a=f[1];i=Math.min(i,p),u=Math.max(u,p),c=Math.min(c,a),m=Math.max(m,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),m=s(Math.max(m,t[1],e[1]),n),{x:i,y:c,w:Math.abs(u-i),h:Math.abs(m-c),x2:u,y2:m}},co=(t,r,e,n,o=1/0)=>{let i=lr(t,r,e,n)||[],c=1/0,u=1/0,m=-1/0,x=-1/0;for(let f of i){let p=Mr(f,t,r,e,n),a=p[0],M=p[1];c=Math.min(c,a!=null?a:1/0),m=Math.max(m,a!=null?a:-1/0),u=Math.min(u,M!=null?M:1/0),x=Math.max(x,M!=null?M:-1/0)}return c=s(Math.min(c,t[0],n[0]),o),m=s(Math.max(m,t[0],n[0]),o),u=s(Math.min(u,t[1],n[1]),o),x=s(Math.max(x,t[1],n[1]),o),{x:c,y:u,w:Math.abs(m-c),h:Math.abs(x-u),x2:m,y2:x}};var Et={};b(Et,{circleMovement:()=>yr,circleMovementAfterMouse:()=>so,ellipseMovement:()=>dr,ellipseMovementAfterMouse:()=>uo,lissajousCurve:()=>xo,sineWaveMovement:()=>mo});var yr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),so=(t,r,e)=>{let n=z(t,r),o=$(n);return o=F(o,0,Math.PI*2,0,Math.PI),yr(r,o,e)},dr=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),uo=(t,r,e)=>{let n=z(t,r),o=$(n);return o=F(o,0,Math.PI*2,0,Math.PI),dr(r,o,e[0],e[1])},mo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},xo=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var Dt={};b(Dt,{getColorsDelta:()=>Bo,getRandomGrayscaleHSLColor:()=>bo,getRandomHSLColor:()=>Ct,getRandomHSLColorWithHue:()=>po,getRandomHSLColorWithLightness:()=>ho,getRandomHSLColorWithSaturation:()=>Mo,getRandomHSLColorWithinRanges:()=>Vo,getRandomHexColor:()=>fo,getRandomRGBColor:()=>ao,getShiftedHue:()=>Ro,getShiftedLightness:()=>zo,getShiftedSaturation:()=>Ho,hexToRgb:()=>So,hslToHex:()=>gr,hslToRgb:()=>vr,labToRgb:()=>wo,rgbToHex:()=>go,rgbToHsl:()=>vo,rgbToLab:()=>Nt});var ao=()=>{let t=Ct();return vr(t)},fo=()=>{let t=Ct();return gr(t)},Ct=()=>{let t=y(1,360),r=y(0,100),e=y(0,100);return[t,r,e]},po=t=>{let r=y(0,100),e=y(0,100);return[t,r,e]},Mo=t=>{let r=y(1,360),e=y(0,100);return[r,t,e]},ho=t=>{let r=y(1,360),e=y(0,100);return[r,e,t]},bo=()=>[0,0,y(0,100)],Vo=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let c=y(t,r),u=y(e,n),m=y(o,i);return[c,u,m]},lo=t=>(t*=60,t<0&&(t+=360),t),yo=(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),Io=(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?Ir(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=Ir(e,n,o,i,c),m=Io(e,n,o,i,c,u),x=yo(e,n,o,i,c);return x>360||m>100||u>100?[0,0,100]:x<0||m<0||u<0?[0,0,0]:[s(x,r),s(m,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),vr=(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,m=e,x=e-.333,f=At(i,c,u),p=At(i,c,m),a=At(i,c,x);return f*=255,p*=255,a*=255,f>255||p>255||a>255?[255,255,255]:f<0||p<0||a<0?[0,0,0]:[s(f,r),s(p,r),s(a,r)]},gr=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 m=(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),x=n<.5?n*(1+e):n+e-n*e,f=2*n-x;o=m(f,x,r+1/3),i=m(f,x,r),c=m(f,x,r-1/3)}let u=m=>{let x=Math.round(m*255).toString(16);return x.length===1?"0"+x:x};return`#${u(o)}${u(i)}${u(c)}`},go=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},So=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,m,x,f)=>m+m+x+x+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),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)]},wo=(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)]},Ro=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=d(e,360)),[e,t[1],t[2]]},zo=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=d(e,100)),[t[0],t[1],e]},Ho=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},Bo=(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],m=Math.sqrt(n[1]*n[1]+n[2]*n[2]),x=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=m-x,p=c*c+u*u-f*f;p=p<0?0:Math.sqrt(p);let a=1+.045*m,M=1+.015*m,w=i/1,N=f/a,v=p/M,k=w*w+N*N+v*v;return k<0?0:Math.sqrt(k)};var Sr={};var Xt={};b(Xt,{guid:()=>To,newId:()=>Lo});var To=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),Lo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var Yt={};b(Yt,{circleCollide:()=>qo,convexPolygonsCollide:()=>Eo,rectCollide:()=>$o});var $o=(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,qo=(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},wr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...wr(t)),e.push(...wr(r));for(let n of e){let o=it(n[0],n[1]),i=Rr(t,o),c=Rr(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},Rr=(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:()=>Ao});var Ao=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,c=!1,u,m=()=>{e=void 0,o=void 0,i=void 0,c=!1,n!==void 0&&window.cancelAnimationFrame(n)},x=()=>{m(),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(Wt()),o<=r?(i=B,n=window.requestAnimationFrame(a)):m()},M=(B,$r)=>{x(),typeof t.resizeCallback=="function"&&t.resizeCallback(B,$r)},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,k=()=>e,Tr=()=>{if(!(r===1/0||o===void 0))return o*100/r},Lr=()=>u,Wt=()=>({start:w,stop:m,pause:f,resume:p,restart:x,isAnimating:v,getElapsedTime:N,getStartTime:k,getPercent:Tr,getResizeObserver:Lr});return Wt()};var Ot={};b(Ot,{getCircleCircumference:()=>No,getEllipseCircumference:()=>Co,getSquareInCircleSide:()=>Xo,isAngleInCircleArc:()=>Do});var No=(t,r=1/0)=>s(2*Math.PI*t,r),Co=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((V(t,2)+V(r,2))/2),e),Do=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Xo=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var jt={};b(jt,{arithmeticSequenceSum:()=>Go,naturalNumbersSequenceSum:()=>Yo});var Yo=t=>t*(t+1)/2,Go=(t,r,e)=>t/2*(2*r+(t-1)*e);var Ft={};b(Ft,{getArithmeticMean:()=>j,getArithmeticMeanFromFrequency:()=>Oo,getMedian:()=>jo,getMode:()=>ko,getStandardDeviation:()=>kt,getVariance:()=>zr,getVariance1:()=>Fo});var j=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return s(e/t.length,r)},Oo=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return s(e,r)},jo=(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)},ko=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},Fo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i-e,2),0);return s(n/t.length,r)},zr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i,2),0);return s(n/t.length-V(e,2),r)},kt=(t,r=1/0)=>{var n;let e=(n=zr(t))!=null?n:0;return s(Math.sqrt(e),r)};var _t={};b(_t,{mlNormalizeArray:()=>Qt,mlNormalizeTestData:()=>Qo,mlNormalizeUnseenData:()=>Zo,mlNormalizeValue:()=>Hr,mlStandardizeArray:()=>Zt,mlStandardizeTestData:()=>_o,mlStandardizeUnseenData:()=>Wo,mlStandardizeValue:()=>Br});var Hr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:s((t-r)/o,n)},Qt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Qt(t,e,n,r);return{min:s(e,r),max:s(n,r),data:o}},Zo=(t,r,e,n=1/0)=>Qt(t,r,e,n),Br=(t,r,e,n=1/0)=>e===0?0:s((t-r)/e,n),Zt=(t,r,e,n=1/0)=>[...t].map(o=>Br(o,r,e,n)),_o=(t,r=1/0)=>{var i;let e=(i=j(t))!=null?i:0,n=kt(t),o=Zt(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}},Wo=(t,r,e,n=1/0)=>Zt(t,r,e,n);var Uo=h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h(h({},ct),It),gt),U),tt),St),K),wt),qt),Lt),Et),Dt),Sr),Xt),Tt),Yt),Gt),Ot),jt),Ft),_t);window.mzMath=window.mzMath||Uo;})(); + )`,_e=(t,r=1/0)=>[[1,0],[0,1],[c(t[0],r),c(t[1],r)]],We=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[c(t[0],r),c(t[1],r),c(t[2],r)]],O=(t,r=1/0)=>[[1,0,c(t[0],r)],[0,1,c(t[1],r)],[0,0,1]],Ue=(t,r=1/0)=>[[1,0,0,c(t[0],r)],[0,1,0,c(t[1],r)],[0,0,1,c(t[2],r)],[0,0,0,1]],or=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o],[o,n]]:[[n,o],[-o,n]]},vt=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},ir=(t,r,e=!0,n=1/0)=>{let o=O(r,n),i=vt(t,e,n),s=O(Z(r,-1),n),u=E(o,i);return E(u,s)},Ke=(t,r,e,n=!0,o=1/0)=>{let i=ir(t,r,n,o);return l(i,e)},Je=(t,r,e=!0,n=1/0)=>{let o=q(r);return l(or(t,e,n),o)},Pe=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(vt(t,e,n),o)},sr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0],[0,n,-o],[0,o,n]]:[[1,0,0],[0,n,o],[0,-o,n]]},tn=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[1,0,0,0],[0,n,-o,0],[0,o,n,0],[0,0,0,1]]:[[1,0,0,0],[0,n,o,0],[0,-o,n,0],[0,0,0,1]]},rn=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(sr(t,e,n),o)},cr=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},en=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},nn=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(cr(t,e,n),o)},ur=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},on=(t,r=!0,e=1/0)=>{let n=c(Math.cos(t),e),o=c(Math.sin(t),e);return r?[[n,-o,0,0],[o,n,0,0],[0,0,1,0],[0,0,0,1]]:[[n,o,0,0],[-o,n,0,0],[0,0,1,0],[0,0,0,1]]},sn=(t,r,e=!0,n=1/0)=>{let o=S(r);return l(ur(t,e,n),o)},mr=(t,r,e=1/0)=>{let n=O(r,e),o=ar(t),i=O(Z(r,-1),e),s=E(n,o);return E(s,i)},cn=(t,r,e,n=1/0)=>{let o=mr(t,r,n);return l(o,e)},xr=t=>[[t[0],0],[0,t[1]]],un=(t,r)=>l(xr(t),r),ar=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],fr=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],mn=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],xn=(t,r)=>l(fr(t),r),an=t=>[[t,0],[0,1]],fn=t=>[[t,0,0],[0,1,0],[0,0,1]],pn=t=>[[t,0,0],[0,1,0],[0,0,1]],Mn=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],bn=t=>[[1,0,0],[0,t,0],[0,0,1]],hn=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],Vn=t=>[[1,0,0],[0,1,0],[0,0,t]],ln=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],yn=t=>[[1,0],[0,t]],dn=t=>[[1,0,0],[0,t,0],[0,0,1]],In=()=>[[-1,0],[0,-1]],vn=()=>[[-1,0,0],[0,-1,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]],wn=()=>[[0,-1],[-1,0]],Rn=()=>[[1,0],[0,-1]],zn=()=>[[1,0,0],[0,-1,0],[0,0,1]],Tn=()=>[[-1,0],[0,1]],Hn=()=>[[-1,0,0],[0,1,0],[0,0,1]],Bn=()=>[[-1,0,0],[0,1,0],[0,0,1]],Ln=()=>[[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],$n=()=>[[1,0,0],[0,-1,0],[0,0,1]],qn=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],En=()=>[[1,0,0],[0,1,0],[0,0,-1]],An=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Nn=t=>[[1,t],[0,1]],Cn=t=>[[1,0],[t,1]];var St={};h(St,{getRandom:()=>y,getRandomBoolean:()=>Dn,getRandomInt:()=>pr,getRandomItemFromArray:()=>Xn});var y=(t,r,e=1/0)=>c(Math.random()*(r-t)+t,e),pr=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),Dn=()=>Math.random()<.5,Xn=t=>{let r=pr(0,t.length-1);return t[r]};var wt={};h(wt,{stringToNumber:()=>Yn});var Yn=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var qt={};h(qt,{v2CubicBezierBBox:()=>co,v2CubicBezierCurve:()=>br,v2CubicBezierCurveExtrema:()=>yr,v2CubicBezierCurveNormal:()=>io,v2CubicBezierCurveTangent:()=>Vr,v2QuadraticBezierBBox:()=>so,v2QuadraticBezierCurve:()=>Mr,v2QuadraticBezierCurveExtrema:()=>lr,v2QuadraticBezierCurveNormal:()=>oo,v2QuadraticBezierCurveTangent:()=>hr,v3CubicBezierCurve:()=>ro,v3CubicBezierCurveTangent:()=>no,v3QuadraticBezierCurve:()=>to,v3QuadraticBezierCurveTangent:()=>eo});var Bt={};h(Bt,{dxArcCos:()=>Zn,dxArcCot:()=>Wn,dxArcSin:()=>Qn,dxArcTan:()=>_n,dxCos:()=>jn,dxCot:()=>Fn,dxPolynomial:()=>Gn,dxSin:()=>On,dxTan:()=>kn,dxV2CubicBezierCurve:()=>Tt,dxV2QuadraticBezierCurve:()=>Rt,dxV3CubicBezierCurve:()=>Ht,dxV3QuadraticBezierCurve:()=>zt});var Gn=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],s=o[1];n+=i*s*Math.pow(t,s-1)}return c(n,e)},Rt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},zt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),s=2-4*t,u=2*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},Tt=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,x=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i)]},Ht=(t,r,e,n,o,i=1/0)=>{let s=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),m=6*t-9*t*t,x=3*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},On=(t,r=1/0)=>c(Math.cos(t),r),jn=(t,r=1/0)=>c(-Math.sin(t),r),kn=(t,r=1/0)=>c(1/V(Math.cos(t),2),r),Fn=(t,r=1/0)=>c(-1/V(Math.sin(t),2),r),Qn=(t,r=1/0)=>c(1/Math.sqrt(1-V(t,2)),r),Zn=(t,r=1/0)=>c(-1/Math.sqrt(1-V(t,2)),r),_n=(t,r=1/0)=>c(1/(1+V(t,2)),r),Wn=(t,r=1/0)=>c(-1/(1+V(t,2)),r);var Lt={};h(Lt,{getLinearEquationBy2Points:()=>Pn,linearEquation:()=>A,linearEquationSystem2:()=>Un,linearEquationSystem3:()=>Kn,linearEquationSystemN:()=>Jn});var A=(t,r=1/0)=>{let e=t[0],n=t[1],i=t[2]-n;return e===0&&i===0?1/0:e===0?NaN:c(i/e,r)},Un=(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 l(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=dt(o);if(i===null)return null;let s=[t[3],r[3],e[3]];return l(i,s,n)},Jn=(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 l(n,o,r)},Pn=(t,r)=>{let[e,n]=z(r,t),[o,i]=t;if(e===0)return{slope:void 0,xIntercept:o,yIntercept:void 0,formula:`x = ${o}`};let s=n/e,u=i-s*o,m="";return s===0?m=`y = ${u}`:(m=`y = ${s===1?"":s}x`,u!==0&&(m+=` ${u<0?"-":"+"} ${Math.abs(u)}`)),{slope:s,xIntercept:void 0,yIntercept:u,formula:m}};var $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 B(f)?[f]:[]}let s=o-i,u=n*n-4*e*s;if(u<0)return[];if(u===0)return[c(-n/(2*e),r)];let m=2*e,x=Math.sqrt(u);return[c((-n+x)/m,r),c((-n-x)/m,r)]};var Mr=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o)]},to=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),s=(1-t)*2*t,u=t*t;return[c(i*r[0]+s*e[0]+u*n[0],o),c(i*r[1]+s*e[1]+u*n[1],o),c(i*r[2]+s*e[2]+u*n[2],o)]},br=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i)]},ro=(t,r,e,n,o,i=1/0)=>{let s=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,m=(1-t)*3*t*t,x=t*t*t;return[c(s*r[0]+u*e[0]+m*n[0]+x*o[0],i),c(s*r[1]+u*e[1]+m*n[1]+x*o[1],i),c(s*r[2]+u*e[2]+m*n[2]+x*o[2],i)]},hr=(t,r,e,n,o=1/0)=>{let i=Rt(t,r,e,n);return q(i,o)},eo=(t,r,e,n,o=1/0)=>{let i=zt(t,r,e,n);return S(i,o)},Vr=(t,r,e,n,o,i=1/0)=>{let s=Tt(t,r,e,n,o);return q(s,i)},no=(t,r,e,n,o,i=1/0)=>{let s=Ht(t,r,e,n,o);return S(s,i)},oo=(t,r,e,n,o=1/0)=>{let i=hr(t,r,e,n,o);return[-i[1],i[0]]},io=(t,r,e,n,o,i=1/0)=>{let s=Vr(t,r,e,n,o,i);return[-s[1],s[0]]},lr=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=A([o,i,0],n),m=2*t[1]-4*r[1]+2*e[1],x=-2*t[1]+2*r[1],p=A([m,x,0],n),a=[];return B(u)&&a.push(u),B(p)&&a.push(p),a},yr=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],s=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],m=[i,s,u,0],x=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[x,f,p,0],M=$t(m,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},so=(t,r,e,n=1/0)=>{let o=lr(t,r,e),i=1/0,s=1/0,u=-1/0,m=-1/0;for(let x of o){let f=Mr(x,t,r,e),p=f[0],a=f[1];i=Math.min(i,p),u=Math.max(u,p),s=Math.min(s,a),m=Math.max(m,a)}return i=c(Math.min(i,t[0],e[0]),n),u=c(Math.max(u,t[0],e[0]),n),s=c(Math.min(s,t[1],e[1]),n),m=c(Math.max(m,t[1],e[1]),n),{x:i,y:s,w:Math.abs(u-i),h:Math.abs(m-s),x2:u,y2:m}},co=(t,r,e,n,o=1/0)=>{let i=yr(t,r,e,n)||[],s=1/0,u=1/0,m=-1/0,x=-1/0;for(let f of i){let p=br(f,t,r,e,n),a=p[0],M=p[1];s=Math.min(s,a!=null?a:1/0),m=Math.max(m,a!=null?a:-1/0),u=Math.min(u,M!=null?M:1/0),x=Math.max(x,M!=null?M:-1/0)}return s=c(Math.min(s,t[0],n[0]),o),m=c(Math.max(m,t[0],n[0]),o),u=c(Math.min(u,t[1],n[1]),o),x=c(Math.max(x,t[1],n[1]),o),{x:s,y:u,w:Math.abs(m-s),h:Math.abs(x-u),x2:m,y2:x}};var Et={};h(Et,{circleMovement:()=>dr,circleMovementAfterMouse:()=>uo,ellipseMovement:()=>Ir,ellipseMovementAfterMouse:()=>mo,lissajousCurve:()=>ao,sineWaveMovement:()=>xo});var dr=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),uo=(t,r,e)=>{let n=z(t,r),o=$(n);return o=F(o,0,Math.PI*2,0,Math.PI),dr(r,o,e)},Ir=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),mo=(t,r,e)=>{let n=z(t,r),o=$(n);return o=F(o,0,Math.PI*2,0,Math.PI),Ir(r,o,e[0],e[1])},xo=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},ao=(t,r,e,n,o,i,s)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-s)];var Dt={};h(Dt,{getColorsDelta:()=>Bo,getRandomGrayscaleHSLColor:()=>Vo,getRandomHSLColor:()=>Ct,getRandomHSLColorWithHue:()=>Mo,getRandomHSLColorWithLightness:()=>ho,getRandomHSLColorWithSaturation:()=>bo,getRandomHSLColorWithinRanges:()=>lo,getRandomHexColor:()=>po,getRandomRGBColor:()=>fo,getShiftedHue:()=>zo,getShiftedLightness:()=>To,getShiftedSaturation:()=>Ho,hexToRgb:()=>wo,hslToHex:()=>Sr,hslToRgb:()=>gr,labToRgb:()=>Ro,rgbToHex:()=>So,rgbToHsl:()=>go,rgbToLab:()=>Nt});var fo=()=>{let t=Ct();return gr(t)},po=()=>{let t=Ct();return Sr(t)},Ct=()=>{let t=y(1,360),r=y(0,100),e=y(0,100);return[t,r,e]},Mo=t=>{let r=y(0,100),e=y(0,100);return[t,r,e]},bo=t=>{let r=y(1,360),e=y(0,100);return[r,t,e]},ho=t=>{let r=y(1,360),e=y(0,100);return[r,e,t]},Vo=()=>[0,0,y(0,100)],lo=(t=1,r=360,e=0,n=100,o=0,i=100)=>{let s=y(t,r),u=y(e,n),m=y(o,i);return[s,u,m]},yo=t=>(t*=60,t<0&&(t+=360),t),Io=(t,r,e,n=void 0,o=void 0)=>{if(n=n===void 0?Math.min(t,r,e):n,o=o===void 0?Math.max(t,r,e):o,n===o)return 0;let i=o-n,s=0;return o===t&&(s=(r-e)/i+(r(n=n===void 0?Math.min(t,r,e):n,o=n===void 0?Math.max(t,r,e):o,(n+o)/2*100),vo=(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?vr(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),go=(t,r=1/0)=>{let e=t[0]/255,n=t[1]/255,o=t[2]/255,i=Math.min(e,n,o),s=Math.max(e,n,o),u=vr(e,n,o,i,s),m=vo(e,n,o,i,s,u),x=Io(e,n,o,i,s);return x>360||m>100||u>100?[0,0,100]:x<0||m<0||u<0?[0,0,0]:[c(x,r),c(m,r),c(u,r)]},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),gr=(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,s=2*o-i,u=e+.333,m=e,x=e-.333,f=At(i,s,u),p=At(i,s,m),a=At(i,s,x);return f*=255,p*=255,a*=255,f>255||p>255||a>255?[255,255,255]:f<0||p<0||a<0?[0,0,0]:[c(f,r),c(p,r),c(a,r)]},Sr=t=>{if(t[0]>360||t[1]>100||t[2]>100)return"#ffffff";if(t[0]<0||t[1]<0||t[2]<0)return"#000000";let r=t[0]/360,e=t[1]/100,n=t[2]/100,o,i,s;if(e===0)o=i=s=n;else{let m=(p,a,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),x=n<.5?n*(1+e):n+e-n*e,f=2*n-x;o=m(f,x,r+1/3),i=m(f,x,r),s=m(f,x,r-1/3)}let u=m=>{let x=Math.round(m*255).toString(16);return x.length===1?"0"+x:x};return`#${u(o)}${u(i)}${u(s)}`},So=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},wo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,m,x,f)=>m+m+x+x+f+f),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return null;let o=parseInt(n[1],16),i=parseInt(n[2],16),s=parseInt(n[3],16);return[o,i,s]},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,s=(e*.2126+n*.7152+o*.0722)/1,u=(e*.0193+n*.1192+o*.9505)/1.08883;return i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,u=u>.008856?Math.pow(u,1/3):7.787*u+16/116,[c(116*s-16,r),c(500*(i-s),r),c(200*(s-u),r)]},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,s=n*-.9689+e*1.8758+o*.0415,u=n*.0557+e*-.204+o*1.057;return i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:12.92*u,[c(Math.max(0,Math.min(1,i))*255,r),c(Math.max(0,Math.min(1,s))*255,r),c(Math.max(0,Math.min(1,u))*255,r)]},zo=(t,r=180)=>{let e=t[0];return e+=r,(e>360||e<0)&&(e=d(e,360)),[e,t[1],t[2]]},To=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=d(e,100)),[t[0],t[1],e]},Ho=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},Bo=(t,r,e=1/0)=>{let n=Nt(t,e),o=Nt(r,e),i=n[0]-o[0],s=n[1]-o[1],u=n[2]-o[2],m=Math.sqrt(n[1]*n[1]+n[2]*n[2]),x=Math.sqrt(o[1]*o[1]+o[2]*o[2]),f=m-x,p=s*s+u*u-f*f;p=p<0?0:Math.sqrt(p);let a=1+.045*m,M=1+.015*m,w=i/1,N=f/a,v=p/M,k=w*w+N*N+v*v;return k<0?0:Math.sqrt(k)};var wr={};var Xt={};h(Xt,{guid:()=>Lo,newId:()=>$o});var Lo=()=>"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 Yt={};h(Yt,{circleCollide:()=>Eo,convexPolygonsCollide:()=>Ao,rectCollide:()=>qo});var qo=(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,Eo=(t,r)=>{let e=Math.abs(t.cx-r.cx),n=Math.abs(t.cy-r.cy);return Math.sqrt(e*e+n*n)<=t.r+r.r},Rr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...Rr(t)),e.push(...Rr(r));for(let n of e){let o=it(n[0],n[1]),i=zr(t,o),s=zr(r,o);if(!(i.max>=s.min&&s.max>=i.min))return!1}return!0},zr=(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={};h(Gt,{animate:()=>No});var No=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,s=!1,u,m=()=>{e=void 0,o=void 0,i=void 0,s=!1,n!==void 0&&window.cancelAnimationFrame(n)},x=()=>{m(),w()},f=()=>{s=!1},p=()=>{s=!0},a=H=>{e===void 0&&(e=H),o=H-e,s&&i!==H&&typeof t.callback=="function"&&t.callback(Ut()),o<=r?(i=H,n=window.requestAnimationFrame(a)):m()},M=(H,qr)=>{x(),typeof t.resizeCallback=="function"&&t.resizeCallback(H,qr)},w=()=>{e=void 0,o=void 0,i=void 0,s=!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=()=>s,k=()=>e,Lr=()=>{if(!(r===1/0||o===void 0))return o*100/r},$r=()=>u,Ut=()=>({start:w,stop:m,pause:f,resume:p,restart:x,isAnimating:v,getElapsedTime:N,getStartTime:k,getPercent:Lr,getResizeObserver:$r});return Ut()};var Ot={};h(Ot,{getCircleCircumference:()=>Co,getEllipseCircumference:()=>Do,getSquareInCircleSide:()=>Yo,isAngleInCircleArc:()=>Xo});var Co=(t,r=1/0)=>c(2*Math.PI*t,r),Do=(t,r,e=1/0)=>c(2*Math.PI*Math.sqrt((V(t,2)+V(r,2))/2),e),Xo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Yo=(t,r=1/0)=>c(t*2/Math.sqrt(2),r);var jt={};h(jt,{arithmeticSequenceSum:()=>Oo,naturalNumbersSequenceSum:()=>Go});var Go=t=>t*(t+1)/2,Oo=(t,r,e)=>t/2*(2*r+(t-1)*e);var Ft={};h(Ft,{getArithmeticMean:()=>j,getArithmeticMeanFromFrequency:()=>jo,getMedian:()=>ko,getMode:()=>Fo,getStandardDeviation:()=>kt,getVariance:()=>Tr,getVariance1:()=>Qo});var j=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return c(e/t.length,r)},jo=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return c(e,r)},ko=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=[...t].sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?c((e[n]+e[n-1])/2,r):c(e[n],r)},Fo=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},Qo=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i-e,2),0);return c(n/t.length,r)},Tr=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=j(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+V(i,2),0);return c(n/t.length-V(e,2),r)},kt=(t,r=1/0)=>{var n;let e=(n=Tr(t))!=null?n:0;return c(Math.sqrt(e),r)};var _t={};h(_t,{mlNormalizeArray:()=>Qt,mlNormalizeTestData:()=>Zo,mlNormalizeUnseenData:()=>_o,mlNormalizeValue:()=>Hr,mlStandardizeArray:()=>Zt,mlStandardizeTestData:()=>Wo,mlStandardizeUnseenData:()=>Uo,mlStandardizeValue:()=>Br});var Hr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:c((t-r)/o,n)},Qt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=Qt(t,e,n,r);return{min:c(e,r),max:c(n,r),data:o}},_o=(t,r,e,n=1/0)=>Qt(t,r,e,n),Br=(t,r,e,n=1/0)=>e===0?0:c((t-r)/e,n),Zt=(t,r,e,n=1/0)=>[...t].map(o=>Br(o,r,e,n)),Wo=(t,r=1/0)=>{var i;let e=(i=j(t))!=null?i:0,n=kt(t),o=Zt(t,e,n,r);return{mean:c(e,r),stdDev:c(n,r),data:o}},Uo=(t,r,e,n=1/0)=>Zt(t,r,e,n);var Wt={};h(Wt,{naturalNumbersSum1ToN:()=>Ko,naturalNumbersSumMToN:()=>Jo});var Ko=t=>t/2*(t+1),Jo=(t,r)=>(r-t+1)*(t+r)/2;var Po=b(b(b(b(b(b(b(b(b(b(b(b(b(b(b(b(b(b(b(b(b(b({},st),It),gt),U),tt),St),K),wt),qt),Lt),Et),Dt),wr),Xt),Bt),Yt),Gt),Ot),jt),Ft),_t),Wt);window.mzMath=window.mzMath||Po;})(); //# sourceMappingURL=mz-math.min.js.map diff --git a/dist/mz-math.min.js.map b/dist/mz-math.min.js.map index e9cffa49..e14fa369 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 = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "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,gBAAAC,EAAA,WAAAC,GAAA,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MrDY,GAAqB,CAACR,EAAgBM,EAAcC,EAAgBX,EAAgB,MACtF,CAAC,GAAGI,CAAI,EAAE,IAAIP,GAASY,GAAmBZ,EAAOa,EAAMC,EAAQX,CAAa,CAAC,EAG3Ea,GAAwB,CAACT,EAAgBJ,EAAgB,MAAmC,CAhEzG,IAAAc,EAiEI,IAAMJ,GAAOI,EAAAC,EAAkBX,CAAI,IAAtB,KAAAU,EAA2B,EAClCH,EAASK,GAAqBZ,CAAI,EAClCG,EAAQK,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa,EAElE,MAAO,CACH,KAAME,EAAiBQ,EAAMV,CAAa,EAC1C,OAAQE,EAAiBS,EAAQX,CAAa,EAC9C,KAAMO,CACV,CACJ,EAKaU,GAA0B,CAACb,EAAgBM,EAAcC,EAAgBX,EAAgB,MAC3FY,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa,EC1D/D,IAAMkB,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", "x", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "physics_exports", "id_exports", "__export", "guid", "newId", "c", "collision_detection_exports", "__export", "circleCollide", "convexPolygonsCollide", "rectCollide", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animation_exports", "__export", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "circle_ellipse_exports", "__export", "getCircleCircumference", "getEllipseCircumference", "getSquareInCircleSide", "isAngleInCircleArc", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "sequence_exports", "__export", "arithmeticSequenceSum", "naturalNumbersSequenceSum", "n", "a", "d", "statistics_exports", "__export", "getArithmeticMean", "getArithmeticMeanFromFrequency", "getMedian", "getMode", "getStandardDeviation", "getVariance", "getVariance1", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "ml_exports", "__export", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "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"] + "sources": ["../src/main/linear-algebra/vector.ts", "../src/main/format.ts", "../src/main/angle.ts", "../src/main/other.ts", "../src/main/linear-algebra/matrix.ts", "../src/main/linear-algebra/matrix-transformations.ts", "../src/main/random.ts", "../src/main/convert.ts", "../src/main/bezier-curves/bezier-curve.ts", "../src/main/derivative.ts", "../src/main/equations/linear-equations.ts", "../src/main/equations/quadratic-equations.ts", "../src/main/path-movement.ts", "../src/main/color.ts", "../src/main/physics.ts", "../src/main/id.ts", "../src/main/collision-detection.ts", "../src/main/animation.ts", "../src/main/circle-ellipse.ts", "../src/main/sequence.ts", "../src/main/statistics.ts", "../src/main/ml.ts", "../src/main/series.ts", "../src/index.ts"], + "sourcesContent": ["import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "import { Vector2 } from '../types';\n\n/**\n * Speed = how far something moves in a given amount of time.\n * Speed is also a vector:\n * magnitude = distance\n * direction = time\n */\nexport type Speed = Vector2;\n\n/**\n * Velocity is a measure of how fast an object is moving in a particular direction.\n * Velocity = Distance traveled / Time taken\n * It has a magnitude and direction, and can be represented as a vector.\n */\nexport type Velocity = Vector2;\n\n/**\n * Acceleration is a measure of how quickly an object's velocity changes over time.\n * Acceleration = (Final velocity - Initial velocity) / Time taken\n * a = (vf - v0)/t.\n * Distance = Initial velocity * time + (acceleration * time^2) / 2\n * It also has a magnitude and direction, and can be represented as a vector.\n * When the direction is negative ----> it's a \"slowdown\" movement\n */\nexport type Acceleration = Vector2;\n\n/**\n * Gravity is the force that attracts two objects with mass toward each other.\n * Newton's law of universal gravitation formula:\n * Gravitational force = (Gravitational constant * Mass of object 1 * Mass of object 2) / Distance between objects^2\n * It also has a magnitude and direction, and can be represented as a vector.\n * magnitude = the strength of the gravitational force\n * direction = the direction in which the force is acting (the direction of the gravitational force is always toward the center of mass of the objects involved)\n */\nexport type Gravity = Vector2;\n\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number => {\n return (n - m + 1) * (m + n) / 2;\n};", "import * as vector from './main/linear-algebra/vector';\nimport * as matrix from './main/linear-algebra/matrix';\nimport * as matrixTransformations from './main/linear-algebra/matrix-transformations';\nimport * as format from './main/format';\nimport * as angle from './main/angle';\nimport * as random from './main/random';\nimport * as other from './main/other';\nimport * as convert from './main/convert';\nimport * as bezierCurve from './main/bezier-curves/bezier-curve';\nimport * as equations from './main/equations/linear-equations';\nimport * as pathMovement from './main/path-movement';\nimport * as color from './main/color';\nimport * as physics from './main/physics';\nimport * as id from './main/id';\nimport * as derivative from './main/derivative';\nimport * as collisions from './main/collision-detection';\nimport * as animation from './main/animation';\nimport * as circleEllipse from './main/circle-ellipse';\nimport * as sequence from './main/sequence';\nimport * as statistics from './main/statistics';\nimport * as ml from './main/ml';\nimport * as series from './main/series';\n\nconst api = {\n ...vector,\n ...matrix,\n ...matrixTransformations,\n ...format,\n ...angle,\n ...random,\n ...other,\n ...convert,\n ...bezierCurve,\n ...equations,\n ...pathMovement,\n ...color,\n ...physics,\n ...id,\n ...derivative,\n ...collisions,\n ...animation,\n ...circleEllipse,\n ...sequence,\n ...statistics,\n ...ml,\n ...series,\n};\n\ndeclare global {\n interface Window {\n mzMath: typeof api,\n }\n}\n\nwindow.mzMath = window.mzMath || api;\n\nexport * from './main/linear-algebra/vector';\nexport * from './main/linear-algebra/matrix';\nexport * from './main/linear-algebra/matrix-transformations';\nexport * from './main/format';\nexport * from './main/angle';\nexport * from './main/random';\nexport * from './main/other';\nexport * from './main/convert';\nexport * from './main/bezier-curves/bezier-curve';\nexport * from './main/equations/linear-equations';\nexport * from './main/path-movement';\nexport * from './main/color';\nexport * from './main/physics';\nexport * from './main/id';\nexport * from './main/derivative';\nexport * from './main/collision-detection';\nexport * from './main/animation';\nexport * from './main/circle-ellipse';\nexport * from './main/sequence';\nexport * from './main/statistics';\nexport * from './main/ml';\nexport * from './main/series';"], + "mappings": ";;;;;;;qbAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,QAAAE,GAAA,eAAAC,GAAA,mBAAAC,GAAA,iBAAAC,GAAA,sBAAAC,GAAA,gBAAAC,GAAA,aAAAC,GAAA,gBAAAC,GAAA,gBAAAC,EAAA,gBAAAC,GAAA,UAAAC,EAAA,UAAAC,GAAA,OAAAC,GAAA,mBAAAC,GAAA,eAAAC,GAAA,mBAAAC,GAAA,iBAAAC,GAAA,aAAAC,GAAA,gBAAAC,EAAA,gBAAAC,EAAA,UAAAC,GAAA,UAAAC,GAAA,OAAAC,GAAA,cAAAC,GAAA,kBAAAC,EAAA,gBAAAC,EAAA,WAAAC,GAAA,YAAAC,EAAA,eAAAC,EAAA,OAAAC,GAAA,eAAAC,EAAA,SAAAC,EAAA,SAAAC,ICAA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAO,IAAMC,EAAmB,CAACC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,GAAwB,CAACT,EAAgBJ,EAAgB,MAAmC,CAhEzG,IAAAc,EAiEI,IAAMJ,GAAOI,EAAAC,EAAkBX,CAAI,IAAtB,KAAAU,EAA2B,EAClCH,EAASK,GAAqBZ,CAAI,EAClCG,EAAQK,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa,EAElE,MAAO,CACH,KAAME,EAAiBQ,EAAMV,CAAa,EAC1C,OAAQE,EAAiBS,EAAQX,CAAa,EAC9C,KAAMO,CACV,CACJ,EAKaU,GAA0B,CAACb,EAAgBM,EAAcC,EAAgBX,EAAgB,MAC3FY,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa,EChF/D,IAAAkB,GAAA,GAAAC,EAAAD,GAAA,2BAAAE,GAAA,0BAAAC,KAIO,IAAMD,GAAyBE,GAC1BA,EAAI,GAAMA,EAAI,GAMbD,GAAwB,CAACE,EAAWD,KACrCA,EAAIC,EAAI,IAAMA,EAAID,GAAK,ECWnC,IAAME,GAAMC,4CAAA,GACLC,IACAC,IACAC,IACAC,GACAC,IACAC,IACAC,GACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IACAC,IASP,OAAO,OAAS,OAAO,QAAUvB", + "names": ["vector_exports", "__export", "v2", "v2Distance", "v2DivideScalar", "v2DotProduct", "v2FromPolarCoords", "v2GetNormal", "v2Length", "v2MulScalar", "v2Normalize", "v2SetLength", "v2Sub", "v2Sum", "v3", "v3CrossProduct", "v3Distance", "v3DivideScalar", "v3DotProduct", "v3Length", "v3MulScalar", "v3Normalize", "v3Sub", "v3Sum", "v4", "vDistance", "vDivideScalar", "vDotProduct", "vEqual", "vLength", "vMulScalar", "vN", "vNormalize", "vSub", "vSum", "format_exports", "__export", "setDecimalPlaces", "setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "angle_exports", "__export", "degreesToRadians", "getAnglesDistance", "getAnglesSub", "getV2Angle", "getV2AngleBetween", "getV2AngleInEllipse", "getV3AngleBetween", "getVNAngleBetween", "isAngleBetween", "isClockwise", "percentToAngle", "radiansToDegrees", "setV2Angle", "other_exports", "__export", "convertRange", "doRangesOverlap", "isNumber", "mod", "polarToCartesian", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "matrix_exports", "__export", "identity2", "identity3", "identity4", "identityN", "isSingularMatrix", "m2Adjugate", "m2AppendRow", "m2DeepCopy", "m2Determinant", "m2DivideScalar", "m2Inverse", "m2MulScalar", "m2PrependRow", "m2Reset", "m2Sub", "m2Sum", "m2Transpose", "m2x2", "m3Adjugate", "m3AppendRow", "m3DeepCopy", "m3Determinant", "m3DivideScalar", "m3Inverse", "m3MulScalar", "m3PrependRow", "m3Reset", "m3Sub", "m3Sum", "m3Transpose", "m3x3", "m4x4", "mAdjugate", "mAppendCol", "mAppendRow", "mDeepCopy", "mDelFirstColumn", "mDelFirstRow", "mDelLastColumn", "mDelLastRow", "mDeterminant", "mDivideScalar", "mEqual", "mGetColumn", "mGetFirstColumn", "mGetLastColumn", "mInverse", "mMinor", "mMul", "mMulScalar", "mMulVector", "mNxM", "mPrependCol", "mPrependRow", "mReset", "mSub", "mSum", "mTranspose", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "matrix_transformations_exports", "__export", "m2ReflectionOrigin", "m2ReflectionOriginH", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m2ReflectionYmX", "m2RotateAroundPointH", "m2Rotation", "m2RotationAroundPointH", "m2RotationH", "m2Scale", "m2ScaleAtPointH", "m2ScaleAtPointHMatrix", "m2ScaleH", "m2ScaleX", "m2ScaleXH", "m2ScaleY", "m2ScaleYH", "m2ShearingX", "m2ShearingY", "m2ToCSS", "m2Translation", "m2TranslationH", "m2hToCSS", "m2hToCSS3d", "m3ReflectionOrigin", "m3ReflectionOriginH", "m3ReflectionXY", "m3ReflectionXYH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionYZ", "m3ReflectionYZH", "m3RotationX", "m3RotationXH", "m3RotationY", "m3RotationYH", "m3RotationZ", "m3RotationZH", "m3Scale", "m3ScaleH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m3Translation", "m3TranslationH", "m3hToCSS3d", "v2Rotate", "v2RotateH", "v2Scale", "v3RotateX", "v3RotateY", "v3RotateZ", "v3Scale", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "random_exports", "__export", "getRandom", "getRandomBoolean", "getRandomInt", "getRandomItemFromArray", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "convert_exports", "__export", "stringToNumber", "value", "defaultNumber", "_a", "res", "bezier_curve_exports", "__export", "v2CubicBezierBBox", "v2CubicBezierCurve", "v2CubicBezierCurveExtrema", "v2CubicBezierCurveNormal", "v2CubicBezierCurveTangent", "v2QuadraticBezierBBox", "v2QuadraticBezierCurve", "v2QuadraticBezierCurveExtrema", "v2QuadraticBezierCurveNormal", "v2QuadraticBezierCurveTangent", "v3CubicBezierCurve", "v3CubicBezierCurveTangent", "v3QuadraticBezierCurve", "v3QuadraticBezierCurveTangent", "derivative_exports", "__export", "dxArcCos", "dxArcCot", "dxArcSin", "dxArcTan", "dxCos", "dxCot", "dxPolynomial", "dxSin", "dxTan", "dxV2CubicBezierCurve", "dxV2QuadraticBezierCurve", "dxV3CubicBezierCurve", "dxV3QuadraticBezierCurve", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linear_equations_exports", "__export", "getLinearEquationBy2Points", "linearEquation", "linearEquationSystem2", "linearEquationSystem3", "linearEquationSystemN", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "path_movement_exports", "__export", "circleMovement", "circleMovementAfterMouse", "ellipseMovement", "ellipseMovementAfterMouse", "lissajousCurve", "sineWaveMovement", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "color_exports", "__export", "getColorsDelta", "getRandomGrayscaleHSLColor", "getRandomHSLColor", "getRandomHSLColorWithHue", "getRandomHSLColorWithLightness", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithinRanges", "getRandomHexColor", "getRandomRGBColor", "getShiftedHue", "getShiftedLightness", "getShiftedSaturation", "hexToRgb", "hslToHex", "hslToRgb", "labToRgb", "rgbToHex", "rgbToHsl", "rgbToLab", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "x", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "physics_exports", "id_exports", "__export", "guid", "newId", "c", "collision_detection_exports", "__export", "circleCollide", "convexPolygonsCollide", "rectCollide", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animation_exports", "__export", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "circle_ellipse_exports", "__export", "getCircleCircumference", "getEllipseCircumference", "getSquareInCircleSide", "isAngleInCircleArc", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "sequence_exports", "__export", "arithmeticSequenceSum", "naturalNumbersSequenceSum", "n", "a", "d", "statistics_exports", "__export", "getArithmeticMean", "getArithmeticMeanFromFrequency", "getMedian", "getMode", "getStandardDeviation", "getVariance", "getVariance1", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "ml_exports", "__export", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "series_exports", "__export", "naturalNumbersSum1ToN", "naturalNumbersSumMToN", "n", "m", "api", "__spreadValues", "vector_exports", "matrix_exports", "matrix_transformations_exports", "format_exports", "angle_exports", "random_exports", "other_exports", "convert_exports", "bezier_curve_exports", "linear_equations_exports", "path_movement_exports", "color_exports", "physics_exports", "id_exports", "derivative_exports", "collision_detection_exports", "animation_exports", "circle_ellipse_exports", "sequence_exports", "statistics_exports", "ml_exports", "series_exports"] } diff --git a/dist/mz-math.node.cjs b/dist/mz-math.node.cjs index b986a0d0..20f48364 100644 --- a/dist/mz-math.node.cjs +++ b/dist/mz-math.node.cjs @@ -1,14 +1,14 @@ /* -mzMath v3.0.24 +mzMath v3.0.25 A collection of TypeScript-based math helpers. 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 _=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var xr=Object.getOwnPropertyNames;var mr=Object.prototype.hasOwnProperty;var h=Math.pow;var ar=(t,r)=>{for(var e in r)_(t,e,{get:r[e],enumerable:!0})},fr=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of xr(r))!mr.call(t,o)&&o!==e&&_(t,o,{get:()=>r[o],enumerable:!(n=ur(r,o))||n.enumerable});return t};var pr=t=>fr(_({},"__esModule",{value:!0}),t);var Bo={};ar(Bo,{animate:()=>po,arithmeticSequenceSum:()=>yo,circleCollide:()=>ao,circleMovement:()=>Wt,circleMovementAfterMouse:()=>Yn,convertRange:()=>j,convexPolygonsCollide:()=>fo,degreesToRadians:()=>lr,doRangesOverlap:()=>Mr,dxArcCos:()=>Rn,dxArcCot:()=>zn,dxArcSin:()=>Sn,dxArcTan:()=>wn,dxCos:()=>dn,dxCot:()=>gn,dxPolynomial:()=>yn,dxSin:()=>In,dxTan:()=>vn,dxV2CubicBezierCurve:()=>yt,dxV2QuadraticBezierCurve:()=>Vt,dxV3CubicBezierCurve:()=>It,dxV3QuadraticBezierCurve:()=>lt,ellipseMovement:()=>Ut,ellipseMovementAfterMouse:()=>Gn,getAnglesDistance:()=>Tt,getAnglesSub:()=>k,getArithmeticMean:()=>G,getArithmeticMeanFromFrequency:()=>Io,getCircleCircumference:()=>Mo,getColorsDelta:()=>so,getEllipseCircumference:()=>ho,getLinearEquationBy2Points:()=>Ln,getMedian:()=>vo,getMode:()=>go,getRandom:()=>V,getRandomBoolean:()=>bn,getRandomGrayscaleHSLColor:()=>Wn,getRandomHSLColor:()=>St,getRandomHSLColorWithHue:()=>Qn,getRandomHSLColorWithLightness:()=>_n,getRandomHSLColorWithSaturation:()=>Zn,getRandomHSLColorWithinRanges:()=>Un,getRandomHexColor:()=>Fn,getRandomInt:()=>Ot,getRandomItemFromArray:()=>Vn,getRandomRGBColor:()=>kn,getShiftedHue:()=>oo,getShiftedLightness:()=>io,getShiftedSaturation:()=>co,getSquareInCircleSide:()=>Vo,getStandardDeviation:()=>Rt,getV2Angle:()=>T,getV2AngleBetween:()=>yr,getV2AngleInEllipse:()=>br,getV3AngleBetween:()=>Ir,getVNAngleBetween:()=>Bt,getVariance:()=>er,getVariance1:()=>So,guid:()=>uo,hexToRgb:()=>eo,hslToHex:()=>Pt,hslToRgb:()=>Jt,identity2:()=>te,identity3:()=>re,identity4:()=>ee,identityN:()=>ne,isAngleBetween:()=>dr,isAngleInCircleArc:()=>bo,isClockwise:()=>U,isNumber:()=>H,isSingularMatrix:()=>de,labToRgb:()=>no,linearEquation:()=>E,linearEquationSystem2:()=>Hn,linearEquationSystem3:()=>Bn,linearEquationSystemN:()=>Tn,lissajousCurve:()=>jn,m2Adjugate:()=>ft,m2AppendRow:()=>se,m2DeepCopy:()=>ct,m2Determinant:()=>at,m2DivideScalar:()=>$t,m2Inverse:()=>Mt,m2MulScalar:()=>jr,m2PrependRow:()=>me,m2ReflectionOrigin:()=>Je,m2ReflectionOriginH:()=>Pe,m2ReflectionX:()=>nn,m2ReflectionXH:()=>on,m2ReflectionY:()=>cn,m2ReflectionYH:()=>sn,m2ReflectionYmX:()=>en,m2Reset:()=>_r,m2RotateAroundPointH:()=>Be,m2Rotation:()=>Et,m2RotationAroundPointH:()=>qt,m2RotationH:()=>bt,m2Scale:()=>Xt,m2ScaleAtPointH:()=>De,m2ScaleAtPointHMatrix:()=>Dt,m2ScaleH:()=>Yt,m2ScaleX:()=>Oe,m2ScaleXH:()=>je,m2ScaleY:()=>Ue,m2ScaleYH:()=>Ke,m2ShearingX:()=>hn,m2ShearingY:()=>Mn,m2Sub:()=>Gr,m2Sum:()=>Xr,m2ToCSS:()=>ve,m2Translation:()=>we,m2TranslationH:()=>Y,m2Transpose:()=>Qr,m2hToCSS:()=>ge,m2hToCSS3d:()=>Se,m2x2:()=>Ur,m3Adjugate:()=>Ie,m3AppendRow:()=>ue,m3DeepCopy:()=>st,m3Determinant:()=>ye,m3DivideScalar:()=>Fr,m3Inverse:()=>ht,m3MulScalar:()=>kr,m3PrependRow:()=>ae,m3ReflectionOrigin:()=>tn,m3ReflectionOriginH:()=>rn,m3ReflectionXY:()=>fn,m3ReflectionXYH:()=>pn,m3ReflectionXZ:()=>mn,m3ReflectionXZH:()=>an,m3ReflectionYZ:()=>un,m3ReflectionYZH:()=>xn,m3Reset:()=>Wr,m3RotationX:()=>At,m3RotationXH:()=>$e,m3RotationY:()=>Nt,m3RotationYH:()=>qe,m3RotationZ:()=>Ct,m3RotationZH:()=>Ne,m3Scale:()=>Gt,m3ScaleH:()=>Ye,m3ScaleX:()=>ke,m3ScaleXH:()=>Fe,m3ScaleY:()=>Qe,m3ScaleYH:()=>Ze,m3ScaleZ:()=>_e,m3ScaleZH:()=>We,m3Sub:()=>Or,m3Sum:()=>Yr,m3Translation:()=>ze,m3TranslationH:()=>He,m3Transpose:()=>Zr,m3hToCSS3d:()=>Re,m3x3:()=>Kr,m4x4:()=>Jr,mAdjugate:()=>pt,mAppendCol:()=>oe,mAppendRow:()=>ce,mDeepCopy:()=>y,mDelFirstColumn:()=>Me,mDelFirstRow:()=>pe,mDelLastColumn:()=>ut,mDelLastRow:()=>fe,mDeterminant:()=>X,mDivideScalar:()=>Q,mEqual:()=>Ve,mGetColumn:()=>be,mGetFirstColumn:()=>he,mGetLastColumn:()=>xt,mInverse:()=>Z,mMinor:()=>mt,mMul:()=>$,mMulScalar:()=>ot,mMulVector:()=>b,mNxM:()=>Pr,mPrependCol:()=>ie,mPrependRow:()=>xe,mReset:()=>it,mSub:()=>nt,mSum:()=>et,mTranspose:()=>D,mlNormalizeArray:()=>wt,mlNormalizeTestData:()=>Ro,mlNormalizeUnseenData:()=>wo,mlNormalizeValue:()=>nr,mlStandardizeArray:()=>zt,mlStandardizeTestData:()=>zo,mlStandardizeUnseenData:()=>Ho,mlStandardizeValue:()=>or,mod:()=>l,naturalNumbersSequenceSum:()=>lo,newId:()=>xo,percentToAngle:()=>vr,polarToCartesian:()=>hr,radiansToDegrees:()=>Vr,rectCollide:()=>mo,rgbToHex:()=>ro,rgbToHsl:()=>to,rgbToLab:()=>gt,setDecimalPlaces:()=>s,setV2Angle:()=>W,sineWaveMovement:()=>On,stringToNumber:()=>ln,v2:()=>Ar,v2CubicBezierBBox:()=>Xn,v2CubicBezierCurve:()=>kt,v2CubicBezierCurveExtrema:()=>_t,v2CubicBezierCurveNormal:()=>Cn,v2CubicBezierCurveTangent:()=>Qt,v2Distance:()=>Lr,v2DivideScalar:()=>zr,v2DotProduct:()=>J,v2FromPolarCoords:()=>Dr,v2GetNormal:()=>rt,v2Length:()=>K,v2MulScalar:()=>wr,v2Normalize:()=>L,v2QuadraticBezierBBox:()=>Dn,v2QuadraticBezierCurve:()=>jt,v2QuadraticBezierCurveExtrema:()=>Zt,v2QuadraticBezierCurveNormal:()=>Nn,v2QuadraticBezierCurveTangent:()=>Ft,v2Rotate:()=>Te,v2RotateH:()=>Le,v2Scale:()=>Xe,v2SetLength:()=>Lt,v2Sub:()=>R,v2Sum:()=>gr,v3:()=>Nr,v3CrossProduct:()=>qr,v3CubicBezierCurve:()=>En,v3CubicBezierCurveTangent:()=>An,v3Distance:()=>$r,v3DivideScalar:()=>Hr,v3DotProduct:()=>Er,v3Length:()=>Br,v3MulScalar:()=>F,v3Normalize:()=>v,v3QuadraticBezierCurve:()=>$n,v3QuadraticBezierCurveTangent:()=>qn,v3RotateX:()=>Ee,v3RotateY:()=>Ae,v3RotateZ:()=>Ce,v3Scale:()=>Ge,v3Sub:()=>Rr,v3Sum:()=>Sr,v4:()=>Cr,vDistance:()=>Tr,vDivideScalar:()=>C,vDotProduct:()=>S,vEqual:()=>tt,vLength:()=>w,vMulScalar:()=>N,vN:()=>P,vNormalize:()=>B,vSub:()=>d,vSum:()=>A});module.exports=pr(Bo);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,j=(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),H=t=>!isNaN(parseFloat(t))&&isFinite(t),hr=(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)},br=(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=K(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},Vr=(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)},Bt=(t,r,e=1/0)=>{let n=B(t),o=B(r),i=S(n,o),c=Math.acos(i);return s(c,e)},yr=(t,r,e=1/0)=>{let n=d(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},Ir=(t,r,e=1/0)=>Bt(t,r,e),dr=(t,r,e)=>{let n=k(r,e),o=k(r,t),i=k(e,t),c=o+i;return Math.abs(c-n)<=.001},U=(t,r,e=0)=>(t=t%360,r=r%360,t=t),k=(t,r,e=1/0)=>{let n=Math.abs(l(t,360)-l(r,360));return s(n<=180?n:360-n,e)},Tt=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Tt(r,e,n);return U(r,e,n)?l(n+t*o/100,360):l(n-t*o/100,360)};var A=(t,r,e=1/0)=>{let n=[];for(let o=0;oA(t,r,e),Sr=(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),Rr=(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),F=(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),Hr=(t,r,e=1/0)=>C(t,r,e),w=(t,r=1/0)=>{let e=0;for(let n=0;nw(t,r),Br=(t,r=1/0)=>w(t,r),Lt=(t,r,e=1/0)=>{let n=T(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Tr=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},Lr=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},$r=(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),Er=(t,r,e=1/0)=>S(t,r,e),qr=(t,r,e=1/0)=>[s(t[1]*r[2]-t[2]*r[1],e),s(t[2]*r[0]-t[0]*r[2],e),s(t[0]*r[1]-t[1]*r[0],e)],Ar=(t=0)=>[t,t],Nr=(t=0)=>[t,t,t],Cr=(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=Lt(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),Yr=(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),Or=(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},jr=(t,r,e=1/0)=>ot(t,r,e),kr=(t,r,e=1/0)=>ot(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(C(o,r,e));return n},$t=(t,r,e=1/0)=>Q(t,r,e),Fr=(t,r,e=1/0)=>Q(t,r,e),D=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oD(t),Zr=t=>D(t),it=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nit(t,r),Wr=(t,r=0)=>it(t,r),Ur=(t=0)=>[[t,t],[t,t]],Kr=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],Jr=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],Pr=(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]],re=()=>[[1,0,0],[0,1,0],[0,0,1]],ee=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],ne=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;ey(t),st=t=>y(t),oe=(t,r)=>{if(t.length<=0)return[];let e=y(t);for(let n=0;n{if(t.length<=0)return[];let e=y(t);for(let n=0;n{let e=y(t);return e.push(r),e},se=(t,r)=>{let e=ct(t);return e.push(r),e},ue=(t,r)=>{let e=st(t);return e.push(r),e},xe=(t,r)=>{let e=y(t);return e.unshift(r),e},me=(t,r)=>{let e=ct(t);return e.unshift(r),e},ae=(t,r)=>{let e=st(t);return e.unshift(r),e},fe=t=>{if(t.length<=0)return[];let r=y(t);return r.pop(),r},pe=t=>{if(t.length<=0)return[];let r=y(t);return r.shift(),r},ut=t=>{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=le(t,r,e);return X(o)},X=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return at(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},ye=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)},ft=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},Ie=t=>pt(t),pt=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return ft(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)===0},Mt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=at(t);if(e===0)return null;let n=ft(t);return n===null?null:$t(n,e,r)},ht=(t,r=1/0)=>Z(t,r),Z=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=X(t),o=pt(t);return o===null?null:Q(o,n,r)};var ve=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})`},Se=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],c=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${c}, 0, 1)`},Re=t=>`matrix3d( +var _=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var xr=Object.getOwnPropertyNames;var mr=Object.prototype.hasOwnProperty;var b=Math.pow;var ar=(t,r)=>{for(var e in r)_(t,e,{get:r[e],enumerable:!0})},fr=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of xr(r))!mr.call(t,o)&&o!==e&&_(t,o,{get:()=>r[o],enumerable:!(n=ur(r,o))||n.enumerable});return t};var pr=t=>fr(_({},"__esModule",{value:!0}),t);var Lo={};ar(Lo,{animate:()=>po,arithmeticSequenceSum:()=>yo,circleCollide:()=>ao,circleMovement:()=>Wt,circleMovementAfterMouse:()=>Yn,convertRange:()=>j,convexPolygonsCollide:()=>fo,degreesToRadians:()=>lr,doRangesOverlap:()=>Mr,dxArcCos:()=>Rn,dxArcCot:()=>zn,dxArcSin:()=>Sn,dxArcTan:()=>wn,dxCos:()=>dn,dxCot:()=>gn,dxPolynomial:()=>yn,dxSin:()=>In,dxTan:()=>vn,dxV2CubicBezierCurve:()=>yt,dxV2QuadraticBezierCurve:()=>Vt,dxV3CubicBezierCurve:()=>It,dxV3QuadraticBezierCurve:()=>lt,ellipseMovement:()=>Ut,ellipseMovementAfterMouse:()=>Gn,getAnglesDistance:()=>Bt,getAnglesSub:()=>k,getArithmeticMean:()=>G,getArithmeticMeanFromFrequency:()=>Io,getCircleCircumference:()=>Mo,getColorsDelta:()=>so,getEllipseCircumference:()=>bo,getLinearEquationBy2Points:()=>Ln,getMedian:()=>vo,getMode:()=>go,getRandom:()=>V,getRandomBoolean:()=>hn,getRandomGrayscaleHSLColor:()=>Wn,getRandomHSLColor:()=>St,getRandomHSLColorWithHue:()=>Qn,getRandomHSLColorWithLightness:()=>_n,getRandomHSLColorWithSaturation:()=>Zn,getRandomHSLColorWithinRanges:()=>Un,getRandomHexColor:()=>Fn,getRandomInt:()=>Ot,getRandomItemFromArray:()=>Vn,getRandomRGBColor:()=>kn,getShiftedHue:()=>oo,getShiftedLightness:()=>io,getShiftedSaturation:()=>co,getSquareInCircleSide:()=>Vo,getStandardDeviation:()=>Rt,getV2Angle:()=>B,getV2AngleBetween:()=>yr,getV2AngleInEllipse:()=>hr,getV3AngleBetween:()=>Ir,getVNAngleBetween:()=>Tt,getVariance:()=>er,getVariance1:()=>So,guid:()=>uo,hexToRgb:()=>eo,hslToHex:()=>Pt,hslToRgb:()=>Jt,identity2:()=>te,identity3:()=>re,identity4:()=>ee,identityN:()=>ne,isAngleBetween:()=>dr,isAngleInCircleArc:()=>ho,isClockwise:()=>U,isNumber:()=>H,isSingularMatrix:()=>de,labToRgb:()=>no,linearEquation:()=>E,linearEquationSystem2:()=>Hn,linearEquationSystem3:()=>Tn,linearEquationSystemN:()=>Bn,lissajousCurve:()=>jn,m2Adjugate:()=>ft,m2AppendRow:()=>se,m2DeepCopy:()=>ct,m2Determinant:()=>at,m2DivideScalar:()=>$t,m2Inverse:()=>Mt,m2MulScalar:()=>jr,m2PrependRow:()=>me,m2ReflectionOrigin:()=>Je,m2ReflectionOriginH:()=>Pe,m2ReflectionX:()=>nn,m2ReflectionXH:()=>on,m2ReflectionY:()=>cn,m2ReflectionYH:()=>sn,m2ReflectionYmX:()=>en,m2Reset:()=>_r,m2RotateAroundPointH:()=>Te,m2Rotation:()=>Et,m2RotationAroundPointH:()=>qt,m2RotationH:()=>ht,m2Scale:()=>Xt,m2ScaleAtPointH:()=>De,m2ScaleAtPointHMatrix:()=>Dt,m2ScaleH:()=>Yt,m2ScaleX:()=>Oe,m2ScaleXH:()=>je,m2ScaleY:()=>Ue,m2ScaleYH:()=>Ke,m2ShearingX:()=>bn,m2ShearingY:()=>Mn,m2Sub:()=>Gr,m2Sum:()=>Xr,m2ToCSS:()=>ve,m2Translation:()=>we,m2TranslationH:()=>Y,m2Transpose:()=>Qr,m2hToCSS:()=>ge,m2hToCSS3d:()=>Se,m2x2:()=>Ur,m3Adjugate:()=>Ie,m3AppendRow:()=>ue,m3DeepCopy:()=>st,m3Determinant:()=>ye,m3DivideScalar:()=>Fr,m3Inverse:()=>bt,m3MulScalar:()=>kr,m3PrependRow:()=>ae,m3ReflectionOrigin:()=>tn,m3ReflectionOriginH:()=>rn,m3ReflectionXY:()=>fn,m3ReflectionXYH:()=>pn,m3ReflectionXZ:()=>mn,m3ReflectionXZH:()=>an,m3ReflectionYZ:()=>un,m3ReflectionYZH:()=>xn,m3Reset:()=>Wr,m3RotationX:()=>At,m3RotationXH:()=>$e,m3RotationY:()=>Nt,m3RotationYH:()=>qe,m3RotationZ:()=>Ct,m3RotationZH:()=>Ne,m3Scale:()=>Gt,m3ScaleH:()=>Ye,m3ScaleX:()=>ke,m3ScaleXH:()=>Fe,m3ScaleY:()=>Qe,m3ScaleYH:()=>Ze,m3ScaleZ:()=>_e,m3ScaleZH:()=>We,m3Sub:()=>Or,m3Sum:()=>Yr,m3Translation:()=>ze,m3TranslationH:()=>He,m3Transpose:()=>Zr,m3hToCSS3d:()=>Re,m3x3:()=>Kr,m4x4:()=>Jr,mAdjugate:()=>pt,mAppendCol:()=>oe,mAppendRow:()=>ce,mDeepCopy:()=>y,mDelFirstColumn:()=>Me,mDelFirstRow:()=>pe,mDelLastColumn:()=>ut,mDelLastRow:()=>fe,mDeterminant:()=>X,mDivideScalar:()=>Q,mEqual:()=>Ve,mGetColumn:()=>he,mGetFirstColumn:()=>be,mGetLastColumn:()=>xt,mInverse:()=>Z,mMinor:()=>mt,mMul:()=>$,mMulScalar:()=>ot,mMulVector:()=>h,mNxM:()=>Pr,mPrependCol:()=>ie,mPrependRow:()=>xe,mReset:()=>it,mSub:()=>nt,mSum:()=>et,mTranspose:()=>D,mlNormalizeArray:()=>wt,mlNormalizeTestData:()=>Ro,mlNormalizeUnseenData:()=>wo,mlNormalizeValue:()=>nr,mlStandardizeArray:()=>zt,mlStandardizeTestData:()=>zo,mlStandardizeUnseenData:()=>Ho,mlStandardizeValue:()=>or,mod:()=>l,naturalNumbersSequenceSum:()=>lo,naturalNumbersSum1ToN:()=>To,naturalNumbersSumMToN:()=>Bo,newId:()=>xo,percentToAngle:()=>vr,polarToCartesian:()=>br,radiansToDegrees:()=>Vr,rectCollide:()=>mo,rgbToHex:()=>ro,rgbToHsl:()=>to,rgbToLab:()=>gt,setDecimalPlaces:()=>s,setV2Angle:()=>W,sineWaveMovement:()=>On,stringToNumber:()=>ln,v2:()=>Ar,v2CubicBezierBBox:()=>Xn,v2CubicBezierCurve:()=>kt,v2CubicBezierCurveExtrema:()=>_t,v2CubicBezierCurveNormal:()=>Cn,v2CubicBezierCurveTangent:()=>Qt,v2Distance:()=>Lr,v2DivideScalar:()=>zr,v2DotProduct:()=>J,v2FromPolarCoords:()=>Dr,v2GetNormal:()=>rt,v2Length:()=>K,v2MulScalar:()=>wr,v2Normalize:()=>L,v2QuadraticBezierBBox:()=>Dn,v2QuadraticBezierCurve:()=>jt,v2QuadraticBezierCurveExtrema:()=>Zt,v2QuadraticBezierCurveNormal:()=>Nn,v2QuadraticBezierCurveTangent:()=>Ft,v2Rotate:()=>Be,v2RotateH:()=>Le,v2Scale:()=>Xe,v2SetLength:()=>Lt,v2Sub:()=>R,v2Sum:()=>gr,v3:()=>Nr,v3CrossProduct:()=>qr,v3CubicBezierCurve:()=>En,v3CubicBezierCurveTangent:()=>An,v3Distance:()=>$r,v3DivideScalar:()=>Hr,v3DotProduct:()=>Er,v3Length:()=>Tr,v3MulScalar:()=>F,v3Normalize:()=>v,v3QuadraticBezierCurve:()=>$n,v3QuadraticBezierCurveTangent:()=>qn,v3RotateX:()=>Ee,v3RotateY:()=>Ae,v3RotateZ:()=>Ce,v3Scale:()=>Ge,v3Sub:()=>Rr,v3Sum:()=>Sr,v4:()=>Cr,vDistance:()=>Br,vDivideScalar:()=>C,vDotProduct:()=>S,vEqual:()=>tt,vLength:()=>w,vMulScalar:()=>N,vN:()=>P,vNormalize:()=>T,vSub:()=>d,vSum:()=>A});module.exports=pr(Lo);var s=(t,r=1/0)=>{if(r===1/0)return t;r<0&&(r=0);let e=b(10,r);return Math.round(t*e)/e};var l=(t,r)=>(t%r+r)%r,j=(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),H=t=>!isNaN(parseFloat(t))&&isFinite(t),br=(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 B=(t,r=1/0)=>{let e=Math.atan2(t[1],t[0]);return s(e,r)},hr=(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=K(t);return[s(Math.cos(r)*n,e),s(Math.sin(r)*n,e)]},Vr=(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)},Tt=(t,r,e=1/0)=>{let n=T(t),o=T(r),i=S(n,o),c=Math.acos(i);return s(c,e)},yr=(t,r,e=1/0)=>{let n=d(t,r),o=Math.atan2(n[1],n[0]);return s(o,e)},Ir=(t,r,e=1/0)=>Tt(t,r,e),dr=(t,r,e)=>{let n=k(r,e),o=k(r,t),i=k(e,t),c=o+i;return Math.abs(c-n)<=.001},U=(t,r,e=0)=>(t=t%360,r=r%360,t=t),k=(t,r,e=1/0)=>{let n=Math.abs(l(t,360)-l(r,360));return s(n<=180?n:360-n,e)},Bt=(t,r,e=0,n=1/0)=>(t=t%360,r=r%360,t{t<0&&(t=0),t>100&&(t=100);let o=Bt(r,e,n);return U(r,e,n)?l(n+t*o/100,360):l(n-t*o/100,360)};var A=(t,r,e=1/0)=>{let n=[];for(let o=0;oA(t,r,e),Sr=(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),Rr=(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),F=(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),Hr=(t,r,e=1/0)=>C(t,r,e),w=(t,r=1/0)=>{let e=0;for(let n=0;nw(t,r),Tr=(t,r=1/0)=>w(t,r),Lt=(t,r,e=1/0)=>{let n=B(t);return[s(Math.cos(n)*r,e),s(Math.sin(n)*r,e)]},Br=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},Lr=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},$r=(t,r,e=1/0)=>{let n=d(t,r);return w(n,e)},T=(t,r=1/0)=>{let e=w(t),n=[];for(let o=0;oT(t,r),v=(t,r=1/0)=>T(t,r),S=(t,r,e=1/0)=>{let n=0;for(let o=0;oS(t,r,e),Er=(t,r,e=1/0)=>S(t,r,e),qr=(t,r,e=1/0)=>[s(t[1]*r[2]-t[2]*r[1],e),s(t[2]*r[0]-t[0]*r[2],e),s(t[0]*r[1]-t[1]*r[0],e)],Ar=(t=0)=>[t,t],Nr=(t=0)=>[t,t,t],Cr=(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=Lt(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),Yr=(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),Or=(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},jr=(t,r,e=1/0)=>ot(t,r,e),kr=(t,r,e=1/0)=>ot(t,r,e),Q=(t,r,e=1/0)=>{if(r===0)throw new Error("Division by zero error.");let n=[];for(let o of t)n.push(C(o,r,e));return n},$t=(t,r,e=1/0)=>Q(t,r,e),Fr=(t,r,e=1/0)=>Q(t,r,e),D=t=>{let r=t.length;if(r<=0)return t;let e=t[0].length;if(e<=0)return t;let n=[];for(let o=0;oD(t),Zr=t=>D(t),it=(t,r=0)=>{if(t.length<=0)return[];let e=[];for(let n=0;nit(t,r),Wr=(t,r=0)=>it(t,r),Ur=(t=0)=>[[t,t],[t,t]],Kr=(t=0)=>[[t,t,t],[t,t,t],[t,t,t]],Jr=(t=0)=>[[t,t,t,t],[t,t,t,t],[t,t,t,t],[t,t,t,t]],Pr=(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]],re=()=>[[1,0,0],[0,1,0],[0,0,1]],ee=()=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],ne=t=>{if(t<0)throw new Error("N must be a non-negative number.");if(t===0)return[];let r=[];for(let e=0;e{let r=[];for(let e=0;ey(t),st=t=>y(t),oe=(t,r)=>{if(t.length<=0)return[];let e=y(t);for(let n=0;n{if(t.length<=0)return[];let e=y(t);for(let n=0;n{let e=y(t);return e.push(r),e},se=(t,r)=>{let e=ct(t);return e.push(r),e},ue=(t,r)=>{let e=st(t);return e.push(r),e},xe=(t,r)=>{let e=y(t);return e.unshift(r),e},me=(t,r)=>{let e=ct(t);return e.unshift(r),e},ae=(t,r)=>{let e=st(t);return e.unshift(r),e},fe=t=>{if(t.length<=0)return[];let r=y(t);return r.pop(),r},pe=t=>{if(t.length<=0)return[];let r=y(t);return r.shift(),r},ut=t=>{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=y(t);for(let e=0;e{if(t.length<=0)return[];let r=[];for(let e=0;e{if(t.length<=0)return[];let r=t[0].length,e=[];for(let n=0;n{if(t.length<=0)return[];let e=[];for(let n=0;n{let n=[];for(let i=0;i{if(t.length<0)return[];if(t[0].length!==r.length)throw new Error("The number of columns in the matrix must be equal to the length of the vector.");let n=[];for(let o=0;o{if(t.length!==r.length)return!1;for(let e=0;e{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=[];for(let i=0;i{let n=t.length;if(n<=0)throw new Error("The matrix should not be empty.");if(n!==t[0].length)throw new Error("The matrix must be square.");let o=le(t,r,e);return X(o)},X=t=>{let r=t.length;if(r===0)return 1;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t[0][0];if(r===2)return at(t);let e=0;for(let n=0;n{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return t[0][0]*t[1][1]-t[1][0]*t[0][1]},ye=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)},ft=t=>{if(t.length!==t[0].length)throw new Error("The matrix must be square.");return[[t[1][1],-t[0][1]],[-t[1][0],t[0][0]]]},Ie=t=>pt(t),pt=t=>{let r=t.length;if(r<=0)return null;if(r!==t[0].length)throw new Error("The matrix must be square.");if(r===1)return t;if(r===2)return ft(t);let e=[];for(let n=0;n{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");return X(t)===0},Mt=(t,r=1/0)=>{if(t.length>0&&t.length!==t[0].length)throw new Error("The matrix must be square.");let e=at(t);if(e===0)return null;let n=ft(t);return n===null?null:$t(n,e,r)},bt=(t,r=1/0)=>Z(t,r),Z=(t,r=1/0)=>{let e=t.length;if(e>0&&e!==t[0].length)throw new Error("The matrix must be square.");let n=X(t),o=pt(t);return o===null?null:Q(o,n,r)};var ve=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})`},Se=t=>{let r=t[0][0],e=t[1][0],n=t[0][1],o=t[1][1],i=t[0][2],c=t[1][2];return`matrix3d(${r}, ${e}, 0, 0, ${n}, ${o}, 0, 0, 0, 0, 1, 0, ${i}, ${c}, 0, 1)`},Re=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]} - )`,we=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],ze=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[s(t[0],r),s(t[1],r),s(t[2],r)]],Y=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],He=(t,r=1/0)=>[[1,0,0,s(t[0],r)],[0,1,0,s(t[1],r)],[0,0,1,s(t[2],r)],[0,0,0,1]],Et=(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]]},qt=(t,r,e=!0,n=1/0)=>{let o=Y(r,n),i=bt(t,e,n),c=Y(F(r,-1),n),u=$(o,i);return $(u,c)},Be=(t,r,e,n=!0,o=1/0)=>{let i=qt(t,r,n,o);return b(i,e)},Te=(t,r,e=!0,n=1/0)=>{let o=L(r);return b(Et(t,e,n),o)},Le=(t,r,e=!0,n=1/0)=>{let o=v(r);return b(bt(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?[[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]]},Ee=(t,r,e=!0,n=1/0)=>{let o=v(r);return b(At(t,e,n),o)},Nt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},qe=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},Ae=(t,r,e=!0,n=1/0)=>{let o=v(r);return b(Nt(t,e,n),o)},Ct=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Ne=(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]]},Ce=(t,r,e=!0,n=1/0)=>{let o=v(r);return b(Ct(t,e,n),o)},Dt=(t,r,e=1/0)=>{let n=Y(r,e),o=Yt(t),i=Y(F(r,-1),e),c=$(n,o);return $(c,i)},De=(t,r,e,n=1/0)=>{let o=Dt(t,r,n);return b(o,e)},Xt=t=>[[t[0],0],[0,t[1]]],Xe=(t,r)=>b(Xt(t),r),Yt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Gt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Ye=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Ge=(t,r)=>b(Gt(t),r),Oe=t=>[[t,0],[0,1]],je=t=>[[t,0,0],[0,1,0],[0,0,1]],ke=t=>[[t,0,0],[0,1,0],[0,0,1]],Fe=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Qe=t=>[[1,0,0],[0,t,0],[0,0,1]],Ze=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],_e=t=>[[1,0,0],[0,1,0],[0,0,t]],We=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],Ue=t=>[[1,0],[0,t]],Ke=t=>[[1,0,0],[0,t,0],[0,0,1]],Je=()=>[[-1,0],[0,-1]],Pe=()=>[[-1,0,0],[0,-1,0],[0,0,1]],tn=()=>[[-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]],en=()=>[[0,-1],[-1,0]],nn=()=>[[1,0],[0,-1]],on=()=>[[1,0,0],[0,-1,0],[0,0,1]],cn=()=>[[-1,0],[0,1]],sn=()=>[[-1,0,0],[0,1,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]],mn=()=>[[1,0,0],[0,-1,0],[0,0,1]],an=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],fn=()=>[[1,0,0],[0,1,0],[0,0,-1]],pn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Mn=t=>[[1,t],[0,1]],hn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),Ot=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),bn=()=>Math.random()<.5,Vn=t=>{let r=Ot(0,t.length-1);return t[r]};var ln=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var yn=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],c=o[1];n+=i*c*Math.pow(t,c-1)}return s(n,e)},Vt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},lt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},yt=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},It=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+m*o[2],i)]},In=(t,r=1/0)=>s(Math.cos(t),r),dn=(t,r=1/0)=>s(-Math.sin(t),r),vn=(t,r=1/0)=>s(1/h(Math.cos(t),2),r),gn=(t,r=1/0)=>s(-1/h(Math.sin(t),2),r),Sn=(t,r=1/0)=>s(1/Math.sqrt(1-h(t,2)),r),Rn=(t,r=1/0)=>s(-1/Math.sqrt(1-h(t,2)),r),wn=(t,r=1/0)=>s(1/(1+h(t,2)),r),zn=(t,r=1/0)=>s(-1/(1+h(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)},Hn=(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 b(o,i,e)},Bn=(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 b(i,c,n)},Tn=(t,r=1/0)=>{if(t.length<=0)return null;let e=ut(t),n=Z(e);if(n===null)return null;let o=xt(t);return b(n,o,r)},Ln=(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,m=Math.sqrt(u);return[s((-n+m)/x,r),s((-n-m)/x,r)]};var jt=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},$n=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},kt=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,x=(1-t)*3*t*t,m=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},En=(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)]},Ft=(t,r,e,n,o=1/0)=>{let i=Vt(t,r,e,n);return L(i,o)},qn=(t,r,e,n,o=1/0)=>{let i=lt(t,r,e,n);return v(i,o)},Qt=(t,r,e,n,o,i=1/0)=>{let c=yt(t,r,e,n,o);return L(c,i)},An=(t,r,e,n,o,i=1/0)=>{let c=It(t,r,e,n,o);return v(c,i)},Nn=(t,r,e,n,o=1/0)=>{let i=Ft(t,r,e,n,o);return[-i[1],i[0]]},Cn=(t,r,e,n,o,i=1/0)=>{let c=Qt(t,r,e,n,o,i);return[-c[1],c[0]]},Zt=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=E([o,i,0],n),x=2*t[1]-4*r[1]+2*e[1],m=-2*t[1]+2*r[1],p=E([x,m,0],n),a=[];return H(u)&&a.push(u),H(p)&&a.push(p),a},_t=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],c=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],x=[i,c,u,0],m=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[m,f,p,0],M=dt(x,o).filter(I=>I>=0&&I<=1),g=dt(a,o).filter(I=>I>=0&&I<=1);return[...M,...g].length===2?[...M,...g]:null},Dn=(t,r,e,n=1/0)=>{let o=Zt(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=jt(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}},Xn=(t,r,e,n,o=1/0)=>{let i=_t(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=kt(f,t,r,e,n),a=p[0],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 Wt=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Yn=(t,r,e)=>{let n=R(t,r),o=T(n);return o=j(o,0,Math.PI*2,0,Math.PI),Wt(r,o,e)},Ut=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),Gn=(t,r,e)=>{let n=R(t,r),o=T(n);return o=j(o,0,Math.PI*2,0,Math.PI),Ut(r,o,e[0],e[1])},On=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},jn=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var kn=()=>{let t=St();return Jt(t)},Fn=()=>{let t=St();return Pt(t)},St=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Qn=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},Zn=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},_n=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Wn=()=>[0,0,V(0,100)],Un=(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]},Kn=t=>(t*=60,t<0&&(t+=360),t),Jn=(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),Pn=(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?Kt(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),to=(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=Kt(e,n,o,i,c),x=Pn(e,n,o,i,c,u),m=Jn(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)]},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),Jt=(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=vt(i,c,u),p=vt(i,c,x),a=vt(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)]},Pt=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)}`},ro=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},eo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,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]},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)]},no=(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]]},io=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=l(e,100)),[t[0],t[1],e]},co=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},so=(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]),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,g=i/1,q=f/a,I=p/M,O=g*g+q*q+I*I;return O<0?0:Math.sqrt(O)};var uo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),xo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var mo=(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,ao=(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},tr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...tr(t)),e.push(...tr(r));for(let n of e){let o=rt(n[0],n[1]),i=rr(t,o),c=rr(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},rr=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=J(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var po=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,c=!1,u,x=()=>{e=void 0,o=void 0,i=void 0,c=!1,n!==void 0&&window.cancelAnimationFrame(n)},m=()=>{x(),g()},f=()=>{c=!1},p=()=>{c=!0},a=z=>{e===void 0&&(e=z),o=z-e,c&&i!==z&&typeof t.callback=="function"&&t.callback(Ht()),o<=r?(i=z,n=window.requestAnimationFrame(a)):x()},M=(z,sr)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(z,sr)},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(a)},q=()=>o,I=()=>c,O=()=>e,ir=()=>{if(!(r===1/0||o===void 0))return o*100/r},cr=()=>u,Ht=()=>({start:g,stop:x,pause:f,resume:p,restart:m,isAnimating:I,getElapsedTime:q,getStartTime:O,getPercent:ir,getResizeObserver:cr});return Ht()};var Mo=(t,r=1/0)=>s(2*Math.PI*t,r),ho=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((h(t,2)+h(r,2))/2),e),bo=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Vo=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var lo=t=>t*(t+1)/2,yo=(t,r,e)=>t/2*(2*r+(t-1)*e);var G=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return s(e/t.length,r)},Io=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return s(e,r)},vo=(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},So=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i-e,2),0);return s(n/t.length,r)},er=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+h(i,2),0);return s(n/t.length-h(e,2),r)},Rt=(t,r=1/0)=>{var n;let e=(n=er(t))!=null?n:0;return s(Math.sqrt(e),r)};var nr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:s((t-r)/o,n)},wt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=wt(t,e,n,r);return{min:s(e,r),max:s(n,r),data:o}},wo=(t,r,e,n=1/0)=>wt(t,r,e,n),or=(t,r,e,n=1/0)=>e===0?0:s((t-r)/e,n),zt=(t,r,e,n=1/0)=>[...t].map(o=>or(o,r,e,n)),zo=(t,r=1/0)=>{var i;let e=(i=G(t))!=null?i:0,n=Rt(t),o=zt(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}},Ho=(t,r,e,n=1/0)=>zt(t,r,e,n);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,getArithmeticMeanFromFrequency,getCircleCircumference,getColorsDelta,getEllipseCircumference,getLinearEquationBy2Points,getMedian,getMode,getRandom,getRandomBoolean,getRandomGrayscaleHSLColor,getRandomHSLColor,getRandomHSLColorWithHue,getRandomHSLColorWithLightness,getRandomHSLColorWithSaturation,getRandomHSLColorWithinRanges,getRandomHexColor,getRandomInt,getRandomItemFromArray,getRandomRGBColor,getShiftedHue,getShiftedLightness,getShiftedSaturation,getSquareInCircleSide,getStandardDeviation,getV2Angle,getV2AngleBetween,getV2AngleInEllipse,getV3AngleBetween,getVNAngleBetween,getVariance,getVariance1,guid,hexToRgb,hslToHex,hslToRgb,identity2,identity3,identity4,identityN,isAngleBetween,isAngleInCircleArc,isClockwise,isNumber,isSingularMatrix,labToRgb,linearEquation,linearEquationSystem2,linearEquationSystem3,linearEquationSystemN,lissajousCurve,m2Adjugate,m2AppendRow,m2DeepCopy,m2Determinant,m2DivideScalar,m2Inverse,m2MulScalar,m2PrependRow,m2ReflectionOrigin,m2ReflectionOriginH,m2ReflectionX,m2ReflectionXH,m2ReflectionY,m2ReflectionYH,m2ReflectionYmX,m2Reset,m2RotateAroundPointH,m2Rotation,m2RotationAroundPointH,m2RotationH,m2Scale,m2ScaleAtPointH,m2ScaleAtPointHMatrix,m2ScaleH,m2ScaleX,m2ScaleXH,m2ScaleY,m2ScaleYH,m2ShearingX,m2ShearingY,m2Sub,m2Sum,m2ToCSS,m2Translation,m2TranslationH,m2Transpose,m2hToCSS,m2hToCSS3d,m2x2,m3Adjugate,m3AppendRow,m3DeepCopy,m3Determinant,m3DivideScalar,m3Inverse,m3MulScalar,m3PrependRow,m3ReflectionOrigin,m3ReflectionOriginH,m3ReflectionXY,m3ReflectionXYH,m3ReflectionXZ,m3ReflectionXZH,m3ReflectionYZ,m3ReflectionYZH,m3Reset,m3RotationX,m3RotationXH,m3RotationY,m3RotationYH,m3RotationZ,m3RotationZH,m3Scale,m3ScaleH,m3ScaleX,m3ScaleXH,m3ScaleY,m3ScaleYH,m3ScaleZ,m3ScaleZH,m3Sub,m3Sum,m3Translation,m3TranslationH,m3Transpose,m3hToCSS3d,m3x3,m4x4,mAdjugate,mAppendCol,mAppendRow,mDeepCopy,mDelFirstColumn,mDelFirstRow,mDelLastColumn,mDelLastRow,mDeterminant,mDivideScalar,mEqual,mGetColumn,mGetFirstColumn,mGetLastColumn,mInverse,mMinor,mMul,mMulScalar,mMulVector,mNxM,mPrependCol,mPrependRow,mReset,mSub,mSum,mTranspose,mlNormalizeArray,mlNormalizeTestData,mlNormalizeUnseenData,mlNormalizeValue,mlStandardizeArray,mlStandardizeTestData,mlStandardizeUnseenData,mlStandardizeValue,mod,naturalNumbersSequenceSum,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}); + )`,we=(t,r=1/0)=>[[1,0],[0,1],[s(t[0],r),s(t[1],r)]],ze=(t,r=1/0)=>[[1,0,0],[0,1,0],[0,0,1],[s(t[0],r),s(t[1],r),s(t[2],r)]],Y=(t,r=1/0)=>[[1,0,s(t[0],r)],[0,1,s(t[1],r)],[0,0,1]],He=(t,r=1/0)=>[[1,0,0,s(t[0],r)],[0,1,0,s(t[1],r)],[0,0,1,s(t[2],r)],[0,0,0,1]],Et=(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]]},ht=(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]]},qt=(t,r,e=!0,n=1/0)=>{let o=Y(r,n),i=ht(t,e,n),c=Y(F(r,-1),n),u=$(o,i);return $(u,c)},Te=(t,r,e,n=!0,o=1/0)=>{let i=qt(t,r,n,o);return h(i,e)},Be=(t,r,e=!0,n=1/0)=>{let o=L(r);return h(Et(t,e,n),o)},Le=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(ht(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?[[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]]},Ee=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(At(t,e,n),o)},Nt=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o],[0,1,0],[-o,0,n]]:[[n,0,-o],[0,1,0],[o,0,n]]},qe=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,0,o,0],[0,1,0,0],[-o,0,n,0],[0,0,0,1]]:[[n,0,-o,0],[0,1,0,0],[o,0,n,0],[0,0,0,1]]},Ae=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(Nt(t,e,n),o)},Ct=(t,r=!0,e=1/0)=>{let n=s(Math.cos(t),e),o=s(Math.sin(t),e);return r?[[n,-o,0],[o,n,0],[0,0,1]]:[[n,o,0],[-o,n,0],[0,0,1]]},Ne=(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]]},Ce=(t,r,e=!0,n=1/0)=>{let o=v(r);return h(Ct(t,e,n),o)},Dt=(t,r,e=1/0)=>{let n=Y(r,e),o=Yt(t),i=Y(F(r,-1),e),c=$(n,o);return $(c,i)},De=(t,r,e,n=1/0)=>{let o=Dt(t,r,n);return h(o,e)},Xt=t=>[[t[0],0],[0,t[1]]],Xe=(t,r)=>h(Xt(t),r),Yt=t=>[[t[0],0,0],[0,t[1],0],[0,0,1]],Gt=t=>[[t[0],0,0],[0,t[1],0],[0,0,t[2]]],Ye=t=>[[t[0],0,0,0],[0,t[1],0,0],[0,0,t[2],0],[0,0,0,1]],Ge=(t,r)=>h(Gt(t),r),Oe=t=>[[t,0],[0,1]],je=t=>[[t,0,0],[0,1,0],[0,0,1]],ke=t=>[[t,0,0],[0,1,0],[0,0,1]],Fe=t=>[[t,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],Qe=t=>[[1,0,0],[0,t,0],[0,0,1]],Ze=t=>[[1,0,0,0],[0,t,0,0],[0,0,1,0],[0,0,0,1]],_e=t=>[[1,0,0],[0,1,0],[0,0,t]],We=t=>[[1,0,0,0],[0,1,0,0],[0,0,t,0],[0,0,0,1]],Ue=t=>[[1,0],[0,t]],Ke=t=>[[1,0,0],[0,t,0],[0,0,1]],Je=()=>[[-1,0],[0,-1]],Pe=()=>[[-1,0,0],[0,-1,0],[0,0,1]],tn=()=>[[-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]],en=()=>[[0,-1],[-1,0]],nn=()=>[[1,0],[0,-1]],on=()=>[[1,0,0],[0,-1,0],[0,0,1]],cn=()=>[[-1,0],[0,1]],sn=()=>[[-1,0,0],[0,1,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]],mn=()=>[[1,0,0],[0,-1,0],[0,0,1]],an=()=>[[1,0,0,0],[0,-1,0,0],[0,0,1,0],[0,0,0,1]],fn=()=>[[1,0,0],[0,1,0],[0,0,-1]],pn=()=>[[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,1]],Mn=t=>[[1,t],[0,1]],bn=t=>[[1,0],[t,1]];var V=(t,r,e=1/0)=>s(Math.random()*(r-t)+t,e),Ot=(t,r)=>Math.floor(Math.random()*(r-t+1)+t),hn=()=>Math.random()<.5,Vn=t=>{let r=Ot(0,t.length-1);return t[r]};var ln=(t,r)=>{var n;if(t==null)return r;let e=(n=Number(t))!=null?n:r;return isNaN(e)?r:e};var yn=(t,r,e=1/0)=>{let n=0;for(let o of r){if(o.length!==2)return NaN;let i=o[0],c=o[1];n+=i*c*Math.pow(t,c-1)}return s(n,e)},Vt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},lt=(t,r,e,n,o=1/0)=>{let i=-2*(1-t),c=2-4*t,u=2*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},yt=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},It=(t,r,e,n,o,i=1/0)=>{let c=-3*Math.pow(1-t,2),u=3*(t-1)*(3*t-1),x=6*t-9*t*t,m=3*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i),s(c*r[2]+u*e[2]+x*n[2]+m*o[2],i)]},In=(t,r=1/0)=>s(Math.cos(t),r),dn=(t,r=1/0)=>s(-Math.sin(t),r),vn=(t,r=1/0)=>s(1/b(Math.cos(t),2),r),gn=(t,r=1/0)=>s(-1/b(Math.sin(t),2),r),Sn=(t,r=1/0)=>s(1/Math.sqrt(1-b(t,2)),r),Rn=(t,r=1/0)=>s(-1/Math.sqrt(1-b(t,2)),r),wn=(t,r=1/0)=>s(1/(1+b(t,2)),r),zn=(t,r=1/0)=>s(-1/(1+b(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)},Hn=(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)},Tn=(t,r,e,n=1/0)=>{let o=[[t[0],t[1],t[2]],[r[0],r[1],r[2]],[e[0],e[1],e[2]]],i=bt(o);if(i===null)return null;let c=[t[3],r[3],e[3]];return h(i,c,n)},Bn=(t,r=1/0)=>{if(t.length<=0)return null;let e=ut(t),n=Z(e);if(n===null)return null;let o=xt(t);return h(n,o,r)},Ln=(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,m=Math.sqrt(u);return[s((-n+m)/x,r),s((-n-m)/x,r)]};var jt=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o)]},$n=(t,r,e,n,o=1/0)=>{let i=Math.pow(1-t,2),c=(1-t)*2*t,u=t*t;return[s(i*r[0]+c*e[0]+u*n[0],o),s(i*r[1]+c*e[1]+u*n[1],o),s(i*r[2]+c*e[2]+u*n[2],o)]},kt=(t,r,e,n,o,i=1/0)=>{let c=Math.pow(1-t,3),u=Math.pow(1-t,2)*3*t,x=(1-t)*3*t*t,m=t*t*t;return[s(c*r[0]+u*e[0]+x*n[0]+m*o[0],i),s(c*r[1]+u*e[1]+x*n[1]+m*o[1],i)]},En=(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)]},Ft=(t,r,e,n,o=1/0)=>{let i=Vt(t,r,e,n);return L(i,o)},qn=(t,r,e,n,o=1/0)=>{let i=lt(t,r,e,n);return v(i,o)},Qt=(t,r,e,n,o,i=1/0)=>{let c=yt(t,r,e,n,o);return L(c,i)},An=(t,r,e,n,o,i=1/0)=>{let c=It(t,r,e,n,o);return v(c,i)},Nn=(t,r,e,n,o=1/0)=>{let i=Ft(t,r,e,n,o);return[-i[1],i[0]]},Cn=(t,r,e,n,o,i=1/0)=>{let c=Qt(t,r,e,n,o,i);return[-c[1],c[0]]},Zt=(t,r,e,n=1/0)=>{let o=2*t[0]-4*r[0]+2*e[0],i=-2*t[0]+2*r[0],u=E([o,i,0],n),x=2*t[1]-4*r[1]+2*e[1],m=-2*t[1]+2*r[1],p=E([x,m,0],n),a=[];return H(u)&&a.push(u),H(p)&&a.push(p),a},_t=(t,r,e,n,o=1/0)=>{let i=-3*t[0]+9*r[0]-9*e[0]+3*n[0],c=6*t[0]-12*r[0]+6*e[0],u=-3*t[0]+3*r[0],x=[i,c,u,0],m=-3*t[1]+9*r[1]-9*e[1]+3*n[1],f=6*t[1]-12*r[1]+6*e[1],p=-3*t[1]+3*r[1],a=[m,f,p,0],M=dt(x,o).filter(I=>I>=0&&I<=1),g=dt(a,o).filter(I=>I>=0&&I<=1);return[...M,...g].length===2?[...M,...g]:null},Dn=(t,r,e,n=1/0)=>{let o=Zt(t,r,e),i=1/0,c=1/0,u=-1/0,x=-1/0;for(let m of o){let f=jt(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}},Xn=(t,r,e,n,o=1/0)=>{let i=_t(t,r,e,n)||[],c=1/0,u=1/0,x=-1/0,m=-1/0;for(let f of i){let p=kt(f,t,r,e,n),a=p[0],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 Wt=(t,r,e)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*e]),Yn=(t,r,e)=>{let n=R(t,r),o=B(n);return o=j(o,0,Math.PI*2,0,Math.PI),Wt(r,o,e)},Ut=(t,r,e,n)=>(r=r%Math.PI*2,[t[0]+Math.cos(r)*e,t[1]+Math.sin(r)*n]),Gn=(t,r,e)=>{let n=R(t,r),o=B(n);return o=j(o,0,Math.PI*2,0,Math.PI),Ut(r,o,e[0],e[1])},On=(t,r,e,n)=>{let o=r*Math.sin(2*Math.PI*e*t+n);return[t,o]},jn=(t,r,e,n,o,i,c)=>[t*Math.cos(n*e-i),r*Math.cos(o*e-c)];var kn=()=>{let t=St();return Jt(t)},Fn=()=>{let t=St();return Pt(t)},St=()=>{let t=V(1,360),r=V(0,100),e=V(0,100);return[t,r,e]},Qn=t=>{let r=V(0,100),e=V(0,100);return[t,r,e]},Zn=t=>{let r=V(1,360),e=V(0,100);return[r,t,e]},_n=t=>{let r=V(1,360),e=V(0,100);return[r,e,t]},Wn=()=>[0,0,V(0,100)],Un=(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]},Kn=t=>(t*=60,t<0&&(t+=360),t),Jn=(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),Pn=(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?Kt(t,r,e):i,(i<=50?(o-n)/(o+n):(o-n)/(2-o-n))*100)),to=(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=Kt(e,n,o,i,c),x=Pn(e,n,o,i,c,u),m=Jn(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)]},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),Jt=(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=vt(i,c,u),p=vt(i,c,x),a=vt(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)]},Pt=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)}`},ro=t=>{let[r,e,n]=t;return"#"+(1<<24|r<<16|e<<8|n).toString(16).slice(1)},eo=t=>{let r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=t.replace(r,(u,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]},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)]},no=(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]]},io=(t,r=10)=>{let e=t[2];return e+=r,(e>100||e<0)&&(e=l(e,100)),[t[0],t[1],e]},co=(t,r=10)=>{let e=t[1];return e+=r,e>100&&(e-=100),e<0&&(e+=100),[t[0],e,t[2]]},so=(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]),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,g=i/1,q=f/a,I=p/M,O=g*g+q*q+I*I;return O<0?0:Math.sqrt(O)};var uo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16|0;return(t=="x"?r:r&3|8).toString(16)}),xo=()=>Math.random().toString(36).substring(2)+new Date().getTime().toString(36);var mo=(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,ao=(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},tr=t=>{let r=[];for(let e=0;e{let e=[];e.push(...tr(t)),e.push(...tr(r));for(let n of e){let o=rt(n[0],n[1]),i=rr(t,o),c=rr(r,o);if(!(i.max>=c.min&&c.max>=i.min))return!1}return!0},rr=(t,r)=>{let e=1/0,n=-1/0;for(let o of t){let i=J(o,r);e=Math.min(e,i),n=Math.max(n,i)}return{min:e,max:n}};var po=t=>{let r=t.duration!==void 0?t.duration:1/0,e,n,o,i,c=!1,u,x=()=>{e=void 0,o=void 0,i=void 0,c=!1,n!==void 0&&window.cancelAnimationFrame(n)},m=()=>{x(),g()},f=()=>{c=!1},p=()=>{c=!0},a=z=>{e===void 0&&(e=z),o=z-e,c&&i!==z&&typeof t.callback=="function"&&t.callback(Ht()),o<=r?(i=z,n=window.requestAnimationFrame(a)):x()},M=(z,sr)=>{m(),typeof t.resizeCallback=="function"&&t.resizeCallback(z,sr)},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(a)},q=()=>o,I=()=>c,O=()=>e,ir=()=>{if(!(r===1/0||o===void 0))return o*100/r},cr=()=>u,Ht=()=>({start:g,stop:x,pause:f,resume:p,restart:m,isAnimating:I,getElapsedTime:q,getStartTime:O,getPercent:ir,getResizeObserver:cr});return Ht()};var Mo=(t,r=1/0)=>s(2*Math.PI*t,r),bo=(t,r,e=1/0)=>s(2*Math.PI*Math.sqrt((b(t,2)+b(r,2))/2),e),ho=(t,r,e)=>(t>r&&(r+=360),e>=t&&e<=r||e+360>=t&&e+360<=r),Vo=(t,r=1/0)=>s(t*2/Math.sqrt(2),r);var lo=t=>t*(t+1)/2,yo=(t,r,e)=>t/2*(2*r+(t-1)*e);var G=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=t.reduce((n,o)=>n+o,0);return s(e/t.length,r)},Io=(t,r=1/0)=>{let e=0;for(let[n,o]of t)e+=n*o;return s(e,r)},vo=(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},So=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+b(i-e,2),0);return s(n/t.length,r)},er=(t,r=1/0)=>{if(!t||t.length<=0)return;let e=G(t);if(e===void 0)return;let n=t.reduce((o,i)=>o+b(i,2),0);return s(n/t.length-b(e,2),r)},Rt=(t,r=1/0)=>{var n;let e=(n=er(t))!=null?n:0;return s(Math.sqrt(e),r)};var nr=(t,r,e,n=1/0)=>{let o=e-r;return o===0?0:s((t-r)/o,n)},wt=(t,r,e,n=1/0)=>{let o=[...t];for(let i=0;i{let e=Math.min(...t),n=Math.max(...t),o=wt(t,e,n,r);return{min:s(e,r),max:s(n,r),data:o}},wo=(t,r,e,n=1/0)=>wt(t,r,e,n),or=(t,r,e,n=1/0)=>e===0?0:s((t-r)/e,n),zt=(t,r,e,n=1/0)=>[...t].map(o=>or(o,r,e,n)),zo=(t,r=1/0)=>{var i;let e=(i=G(t))!=null?i:0,n=Rt(t),o=zt(t,e,n,r);return{mean:s(e,r),stdDev:s(n,r),data:o}},Ho=(t,r,e,n=1/0)=>zt(t,r,e,n);var To=t=>t/2*(t+1),Bo=(t,r)=>(r-t+1)*(t+r)/2;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,getArithmeticMeanFromFrequency,getCircleCircumference,getColorsDelta,getEllipseCircumference,getLinearEquationBy2Points,getMedian,getMode,getRandom,getRandomBoolean,getRandomGrayscaleHSLColor,getRandomHSLColor,getRandomHSLColorWithHue,getRandomHSLColorWithLightness,getRandomHSLColorWithSaturation,getRandomHSLColorWithinRanges,getRandomHexColor,getRandomInt,getRandomItemFromArray,getRandomRGBColor,getShiftedHue,getShiftedLightness,getShiftedSaturation,getSquareInCircleSide,getStandardDeviation,getV2Angle,getV2AngleBetween,getV2AngleInEllipse,getV3AngleBetween,getVNAngleBetween,getVariance,getVariance1,guid,hexToRgb,hslToHex,hslToRgb,identity2,identity3,identity4,identityN,isAngleBetween,isAngleInCircleArc,isClockwise,isNumber,isSingularMatrix,labToRgb,linearEquation,linearEquationSystem2,linearEquationSystem3,linearEquationSystemN,lissajousCurve,m2Adjugate,m2AppendRow,m2DeepCopy,m2Determinant,m2DivideScalar,m2Inverse,m2MulScalar,m2PrependRow,m2ReflectionOrigin,m2ReflectionOriginH,m2ReflectionX,m2ReflectionXH,m2ReflectionY,m2ReflectionYH,m2ReflectionYmX,m2Reset,m2RotateAroundPointH,m2Rotation,m2RotationAroundPointH,m2RotationH,m2Scale,m2ScaleAtPointH,m2ScaleAtPointHMatrix,m2ScaleH,m2ScaleX,m2ScaleXH,m2ScaleY,m2ScaleYH,m2ShearingX,m2ShearingY,m2Sub,m2Sum,m2ToCSS,m2Translation,m2TranslationH,m2Transpose,m2hToCSS,m2hToCSS3d,m2x2,m3Adjugate,m3AppendRow,m3DeepCopy,m3Determinant,m3DivideScalar,m3Inverse,m3MulScalar,m3PrependRow,m3ReflectionOrigin,m3ReflectionOriginH,m3ReflectionXY,m3ReflectionXYH,m3ReflectionXZ,m3ReflectionXZH,m3ReflectionYZ,m3ReflectionYZH,m3Reset,m3RotationX,m3RotationXH,m3RotationY,m3RotationYH,m3RotationZ,m3RotationZH,m3Scale,m3ScaleH,m3ScaleX,m3ScaleXH,m3ScaleY,m3ScaleYH,m3ScaleZ,m3ScaleZH,m3Sub,m3Sum,m3Translation,m3TranslationH,m3Transpose,m3hToCSS3d,m3x3,m4x4,mAdjugate,mAppendCol,mAppendRow,mDeepCopy,mDelFirstColumn,mDelFirstRow,mDelLastColumn,mDelLastRow,mDeterminant,mDivideScalar,mEqual,mGetColumn,mGetFirstColumn,mGetLastColumn,mInverse,mMinor,mMul,mMulScalar,mMulVector,mNxM,mPrependCol,mPrependRow,mReset,mSub,mSum,mTranspose,mlNormalizeArray,mlNormalizeTestData,mlNormalizeUnseenData,mlNormalizeValue,mlStandardizeArray,mlStandardizeTestData,mlStandardizeUnseenData,mlStandardizeValue,mod,naturalNumbersSequenceSum,naturalNumbersSum1ToN,naturalNumbersSumMToN,newId,percentToAngle,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 5c312a3b..0fdfdaf5 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 = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};"], - "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,sBAAAC,GAAA,iBAAAC,EAAA,sBAAAC,EAAA,mCAAAC,GAAA,2BAAAC,GAAA,mBAAAC,GAAA,4BAAAC,GAAA,+BAAAC,GAAA,cAAAC,GAAA,YAAAC,GAAA,cAAAC,EAAA,qBAAAC,GAAA,+BAAAC,GAAA,sBAAAC,GAAA,6BAAAC,GAAA,mCAAAC,GAAA,oCAAAC,GAAA,kCAAAC,GAAA,sBAAAC,GAAA,iBAAAC,GAAA,2BAAAC,GAAA,sBAAAC,GAAA,kBAAAC,GAAA,wBAAAC,GAAA,yBAAAC,GAAA,0BAAAC,GAAA,yBAAAC,GAAA,eAAAC,EAAA,sBAAAC,GAAA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,EAKaC,GAAwB,CAACJ,EAAgBN,EAAaC,EAAaC,EAAgB,MACrFG,GAAiBC,EAAMN,EAAKC,EAAKC,CAAa,EAQ5CS,GAAqB,CAACZ,EAAea,EAAcC,EAAgBX,EAAgB,MACzFW,IAAW,EAAU,EACjBT,GAAkBL,EAAQa,GAAQC,EAAQX,CAAa,EAMrDY,GAAqB,CAACR,EAAgBM,EAAcC,EAAgBX,EAAgB,MACtF,CAAC,GAAGI,CAAI,EAAE,IAAIP,GAASY,GAAmBZ,EAAOa,EAAMC,EAAQX,CAAa,CAAC,EAG3Ea,GAAwB,CAACT,EAAgBJ,EAAgB,MAAmC,CAhEzG,IAAAc,EAiEI,IAAMJ,GAAOI,EAAAC,EAAkBX,CAAI,IAAtB,KAAAU,EAA2B,EAClCH,EAASK,GAAqBZ,CAAI,EAClCG,EAAQK,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa,EAElE,MAAO,CACH,KAAME,EAAiBQ,EAAMV,CAAa,EAC1C,OAAQE,EAAiBS,EAAQX,CAAa,EAC9C,KAAMO,CACV,CACJ,EAKaU,GAA0B,CAACb,EAAgBM,EAAcC,EAAgBX,EAAgB,MAC3FY,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa", - "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", "getArithmeticMeanFromFrequency", "getCircleCircumference", "getColorsDelta", "getEllipseCircumference", "getLinearEquationBy2Points", "getMedian", "getMode", "getRandom", "getRandomBoolean", "getRandomGrayscaleHSLColor", "getRandomHSLColor", "getRandomHSLColorWithHue", "getRandomHSLColorWithLightness", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithinRanges", "getRandomHexColor", "getRandomInt", "getRandomItemFromArray", "getRandomRGBColor", "getShiftedHue", "getShiftedLightness", "getShiftedSaturation", "getSquareInCircleSide", "getStandardDeviation", "getV2Angle", "getV2AngleBetween", "getV2AngleInEllipse", "getV3AngleBetween", "getVNAngleBetween", "getVariance", "getVariance1", "guid", "hexToRgb", "hslToHex", "hslToRgb", "identity2", "identity3", "identity4", "identityN", "isAngleBetween", "isAngleInCircleArc", "isClockwise", "isNumber", "isSingularMatrix", "labToRgb", "linearEquation", "linearEquationSystem2", "linearEquationSystem3", "linearEquationSystemN", "lissajousCurve", "m2Adjugate", "m2AppendRow", "m2DeepCopy", "m2Determinant", "m2DivideScalar", "m2Inverse", "m2MulScalar", "m2PrependRow", "m2ReflectionOrigin", "m2ReflectionOriginH", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m2ReflectionYmX", "m2Reset", "m2RotateAroundPointH", "m2Rotation", "m2RotationAroundPointH", "m2RotationH", "m2Scale", "m2ScaleAtPointH", "m2ScaleAtPointHMatrix", "m2ScaleH", "m2ScaleX", "m2ScaleXH", "m2ScaleY", "m2ScaleYH", "m2ShearingX", "m2ShearingY", "m2Sub", "m2Sum", "m2ToCSS", "m2Translation", "m2TranslationH", "m2Transpose", "m2hToCSS", "m2hToCSS3d", "m2x2", "m3Adjugate", "m3AppendRow", "m3DeepCopy", "m3Determinant", "m3DivideScalar", "m3Inverse", "m3MulScalar", "m3PrependRow", "m3ReflectionOrigin", "m3ReflectionOriginH", "m3ReflectionXY", "m3ReflectionXYH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionYZ", "m3ReflectionYZH", "m3Reset", "m3RotationX", "m3RotationXH", "m3RotationY", "m3RotationYH", "m3RotationZ", "m3RotationZH", "m3Scale", "m3ScaleH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m3Sub", "m3Sum", "m3Translation", "m3TranslationH", "m3Transpose", "m3hToCSS3d", "m3x3", "m4x4", "mAdjugate", "mAppendCol", "mAppendRow", "mDeepCopy", "mDelFirstColumn", "mDelFirstRow", "mDelLastColumn", "mDelLastRow", "mDeterminant", "mDivideScalar", "mEqual", "mGetColumn", "mGetFirstColumn", "mGetLastColumn", "mInverse", "mMinor", "mMul", "mMulScalar", "mMulVector", "mNxM", "mPrependCol", "mPrependRow", "mReset", "mSub", "mSum", "mTranspose", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mod", "naturalNumbersSequenceSum", "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", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData"] + "sources": ["../src/index-esm.ts", "../src/main/format.ts", "../src/main/other.ts", "../src/main/angle.ts", "../src/main/linear-algebra/vector.ts", "../src/main/linear-algebra/matrix.ts", "../src/main/linear-algebra/matrix-transformations.ts", "../src/main/random.ts", "../src/main/convert.ts", "../src/main/derivative.ts", "../src/main/equations/linear-equations.ts", "../src/main/equations/quadratic-equations.ts", "../src/main/bezier-curves/bezier-curve.ts", "../src/main/path-movement.ts", "../src/main/color.ts", "../src/main/id.ts", "../src/main/collision-detection.ts", "../src/main/animation.ts", "../src/main/circle-ellipse.ts", "../src/main/sequence.ts", "../src/main/statistics.ts", "../src/main/ml.ts", "../src/main/series.ts"], + "sourcesContent": ["export * from './main/linear-algebra/vector';\nexport * from './main/linear-algebra/matrix';\nexport * from './main/linear-algebra/matrix-transformations';\nexport * from './main/format';\nexport * from './main/angle';\nexport * from './main/random';\nexport * from './main/other';\nexport * from './main/convert';\nexport * from './main/bezier-curves/bezier-curve';\nexport * from './main/equations/linear-equations';\nexport * from './main/path-movement';\nexport * from './main/color';\nexport * from './main/physics';\nexport * from './main/id';\nexport * from './main/derivative';\nexport * from './main/collision-detection';\nexport * from './main/animation';\nexport * from './main/circle-ellipse';\nexport * from './main/sequence';\nexport * from './main/statistics';\nexport * from './main/ml';\nexport * from './main/series';", "export const setDecimalPlaces = (num: number, decimalPlaces: number | undefined = Infinity) => {\n if(decimalPlaces === Infinity) return num;\n\n if(decimalPlaces < 0){\n decimalPlaces = 0;\n }\n\n const coefficient = 10 ** decimalPlaces;\n return Math.round(num * coefficient) / coefficient;\n};", "import { Vector2 } from '../types';\nimport { setDecimalPlaces } from './format';\n\nexport const mod = (n: number, m: number) => {\n return ((n % m) + m) % m;\n};\n\n/**\n * Convert range [a, b] to [c, d].\n * f(x) = (d - c) * (x - a) / (b - a) + c\n */\nexport const convertRange = (x: number, a: number, b: number, c: number, d: number) => {\n return (d - c) * (x - a) / (b - a) + c;\n};\n\n/**\n * Check if 2 ranges [a,b] and [c,d] overlap.\n */\nexport const doRangesOverlap = (a: number, b: number, c: number, d: number) => {\n return Math.max(a, c) <= Math.min(b, d) ;\n};\n\n// eslint-disable-next-line\nexport const isNumber = (value: any) => {\n return !isNaN(parseFloat(value)) && isFinite(value);\n};\n\n/**\n * Convert polar coordinates to cartesian coordinates.\n */\nexport const polarToCartesian = (center: Vector2, radii: Vector2, angleInRad: number, decimalPlaces = Infinity) : Vector2 => {\n const [cx, cy] = center;\n const [rx, ry] = radii;\n\n return [\n setDecimalPlaces(cx + (rx * Math.cos(angleInRad)), decimalPlaces),\n setDecimalPlaces(cy + (ry * Math.sin(angleInRad)), decimalPlaces),\n ];\n};", "import { Vector, Vector2, Vector3 } from '../types';\nimport { setDecimalPlaces } from './format';\nimport { v2Length, vNormalize, vDotProduct, vSub } from './linear-algebra/vector';\nimport { mod } from './other';\n\nexport const getV2Angle = (v2: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1], v2[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleInEllipse = (v2: Vector2, radii: Vector2, decimalPlaces = Infinity) => {\n const angle = Math.atan2(v2[1]/radii[1], v2[0]/radii[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const setV2Angle = (v2: Vector2, newAngleRad: number, decimalPlaces = Infinity): Vector2 => {\n const length = v2Length(v2);\n return [\n setDecimalPlaces(Math.cos(newAngleRad) * length, decimalPlaces),\n setDecimalPlaces(Math.sin(newAngleRad) * length, decimalPlaces),\n ];\n};\n\nexport const radiansToDegrees = (radians: number, decimalPlaces = Infinity) => {\n const res = radians * (180 / Math.PI);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\nexport const degreesToRadians = (degrees: number, decimalPlaces = Infinity) => {\n const res = degrees * (Math.PI / 180);\n return setDecimalPlaces(res, decimalPlaces);\n};\n\n/**\n * Returns the range [0, Math.PI]\n * A = Math.acos( dot(v1, v2)/(v1.length()*v2.length()) );\n */\nexport const getVNAngleBetween = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n const unitVector1 = vNormalize(vector1);\n const unitVector2 = vNormalize(vector2);\n const dotProduct = vDotProduct(unitVector1, unitVector2);\n const angle = Math.acos(dotProduct);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV2AngleBetween = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) : number => {\n // return getVNAngleBetween(vector1, vector2, decimalPlaces);\n const diff = vSub(vector1, vector2);\n const angle = Math.atan2(diff[1], diff[0]);\n return setDecimalPlaces(angle, decimalPlaces);\n};\n\nexport const getV3AngleBetween = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return getVNAngleBetween(vector1, vector2, decimalPlaces);\n};\n\nexport const isAngleBetween = (angleDegrees: number, startAngleDegrees: number, endAngleDegrees: number) : boolean => {\n const distance = getAnglesSub(startAngleDegrees, endAngleDegrees);\n const distance1 = getAnglesSub(startAngleDegrees, angleDegrees);\n const distance2 = getAnglesSub(endAngleDegrees, angleDegrees);\n const totalDistance = distance1 + distance2;\n\n // Use a small threshold for floating point errors\n return Math.abs(totalDistance - distance) <= 0.001;\n}\n\nexport const isClockwise = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n return angle2Deg >= angle1Deg;\n};\n\n/**\n * Shortest distance (angular) between two angles.\n */\nexport const getAnglesSub = (angleDegrees1: number, angleDegrees2: number, decimalPlaces = Infinity) : number => {\n const angleDistance = Math.abs(mod(angleDegrees1, 360) - mod(angleDegrees2, 360));\n return setDecimalPlaces(angleDistance <= 180 ? angleDistance : 360 - angleDistance, decimalPlaces);\n};\n\nexport const getAnglesDistance = (angle1Deg: number, angle2Deg: number, startAngleDeg = 0, decimalPlaces = Infinity) => {\n angle1Deg = angle1Deg % 360;\n angle2Deg = angle2Deg % 360;\n\n if(angle1Deg < startAngleDeg) {\n angle1Deg += 360;\n }\n\n if(angle2Deg < startAngleDeg) {\n angle2Deg += 360;\n }\n\n if(isClockwise(angle1Deg, angle2Deg, startAngleDeg)) {\n return setDecimalPlaces((angle2Deg - angle1Deg + 360) % 360, decimalPlaces);\n }\n else{\n return setDecimalPlaces((angle1Deg - angle2Deg + 360) % 360, decimalPlaces);\n }\n};\n\nexport const percentToAngle = (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle = 0) => {\n if(percent < 0) {\n percent = 0;\n }\n\n if(percent > 100) {\n percent = 100;\n }\n\n const distance = getAnglesDistance(startAngleDeg, endAngleDeg, circleStartAngle);\n\n const clockwise = isClockwise(startAngleDeg, endAngleDeg, circleStartAngle);\n if(clockwise) {\n return mod(circleStartAngle + (percent * distance / 100), 360);\n }\n else {\n return mod(circleStartAngle - (percent * distance / 100), 360);\n }\n};", "import { Vector, Vector2, Vector3, Vector4 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { getV2Angle, setV2Angle } from '../angle';\n\n// ------------ SUM ------------------------\n\nexport const vSum = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSum(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sum = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSum(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ SUB ------------------------\n\nexport const vSub = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : Vector => {\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vSub(vector1, vector2, decimalPlaces) as Vector2;\n};\n\nexport const v3Sub = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vSub(vector1, vector2, decimalPlaces) as Vector3;\n};\n\n// ------------ MUL SCALAR ------------------------\n\nexport const vMulScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n const vector: Vector = [];\n\n for(let i=0; i {\n return vMulScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3MulScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vMulScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ DIVIDE ------------------------\n\nexport const vDivideScalar = (v: Vector, scalar: number, decimalPlaces = Infinity): Vector => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const vector: Vector = [];\n\n for(let i=0; i {\n return vDivideScalar(v2, scalar, decimalPlaces) as Vector2;\n};\n\nexport const v3DivideScalar = (v3: Vector3, scalar: number, decimalPlaces = Infinity): Vector3 => {\n return vDivideScalar(v3, scalar, decimalPlaces) as Vector3;\n};\n\n// ------------ LENGTH ------------------------\n\nexport const vLength = (vector: Vector, decimalPlaces = Infinity) => {\n let sum = 0;\n\n for(let i=0; i {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v3Length = (vector: Vector3, decimalPlaces = Infinity) => {\n return vLength(vector, decimalPlaces);\n};\n\nexport const v2SetLength = (v2: Vector2, newLength: number, decimalPlaces = Infinity): Vector2 => {\n const angle = getV2Angle(v2);\n return [\n setDecimalPlaces(Math.cos(angle) * newLength, decimalPlaces),\n setDecimalPlaces(Math.sin(angle) * newLength, decimalPlaces),\n ];\n};\n\n// ----------- DISTANCE ------------------------\n\nexport const vDistance = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v2Distance = (vector1: Vector2, vector2: Vector2, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\nexport const v3Distance = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) => {\n const diff = vSub(vector1, vector2);\n return vLength(diff, decimalPlaces);\n};\n\n// ------------ NORMALIZE ------------------------\n\n/**\n * Normalization creates a unit vector, which is a vector of length 1.\n */\nexport const vNormalize = (v: Vector, decimalPlaces = Infinity) : Vector => {\n const length = vLength(v);\n const unitVector: Vector = [];\n\n for(let i=0; i {\n return vNormalize(v2, decimalPlaces) as Vector2;\n};\n\nexport const v3Normalize = (v3: Vector3, decimalPlaces = Infinity) : Vector3 => {\n return vNormalize(v3, decimalPlaces) as Vector3;\n};\n\n// ------------ DOT PRODUCT ------------------------\n\nexport const vDotProduct = (vector1: Vector, vector2: Vector, decimalPlaces = Infinity) : number => {\n let sum = 0;\n\n for(let i=0; i {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\nexport const v3DotProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity) : number => {\n return vDotProduct(vector1, vector2, decimalPlaces);\n};\n\n// ------------ CROSS PRODUCT ------------------------\n\n/**\n * Cross product is possible on 3D vectors only.\n * The cross product a \u00D7 b is defined as a vector c that is perpendicular (orthogonal) to both a and b.\n */\nexport const v3CrossProduct = (vector1: Vector3, vector2: Vector3, decimalPlaces = Infinity): Vector3 => {\n return [\n setDecimalPlaces(vector1[1] * vector2[2] - vector1[2] * vector2[1], decimalPlaces),\n setDecimalPlaces(vector1[2] * vector2[0] - vector1[0] * vector2[2], decimalPlaces),\n setDecimalPlaces(vector1[0] * vector2[1] - vector1[1] * vector2[0], decimalPlaces),\n ];\n};\n\n// --------------- INIT VECTOR HELPER -----------------\n\nexport const v2 = (defaultValue = 0): Vector2 => {\n return [defaultValue, defaultValue];\n};\n\nexport const v3 = (defaultValue = 0): Vector3 => {\n return [defaultValue, defaultValue, defaultValue];\n};\n\nexport const v4 = (defaultValue = 0): Vector4 => {\n return [defaultValue, defaultValue, defaultValue, defaultValue];\n};\n\nexport const vN = (N: number, defaultValue = 0): Vector => {\n\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n const vector: Vector = [];\n for(let i=0; i {\n let vector: Vector2 = [0, 0];\n vector = v2SetLength(vector, distance);\n return setV2Angle(vector, angleRad);\n};\n\n// --------------- EQUALITY -------------------------\n\nexport const vEqual = (vector1: Vector, vector2: Vector): boolean => {\n if(vector1.length !== vector2.length) return false;\n\n for(let i=0; i {\n const sub = v2Sub(vector2, vector1);\n return [\n -setDecimalPlaces(sub[1], decimalPlaces),\n setDecimalPlaces(sub[0], decimalPlaces)\n ];\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector, Vector2, Vector3 } from '../../types';\nimport { vMulScalar, vSum, vSub, vDotProduct, vN, vEqual, vDivideScalar } from './vector';\n\n// --------------- SUM ----------------------\n\nexport const mSum = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sum = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSum(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- SUB ----------------------\n\nexport const mSub = (matrix1: Matrix, matrix2: Matrix, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix2;\n};\n\nexport const m3Sub = (matrix1: Matrix3, matrix2: Matrix3, decimalPlaces = Infinity): Matrix3 => {\n return mSub(matrix1, matrix2, decimalPlaces) as Matrix3;\n};\n\n// --------------- MUL SCALAR ----------------------\n\nexport const mMulScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vMulScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2MulScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mMulScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3MulScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mMulScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n// --------------- DIVIDE SCALAR ----------------------\n\nexport const mDivideScalar = (m: Matrix, scalar: number, decimalPlaces = Infinity): Matrix => {\n if(scalar === 0){\n throw new Error('Division by zero error.');\n }\n\n const matrix: Matrix = [];\n\n for(const v of m){\n matrix.push(vDivideScalar(v, scalar, decimalPlaces));\n }\n\n return matrix;\n};\n\nexport const m2DivideScalar = (m2: Matrix2, scalar: number, decimalPlaces = Infinity): Matrix2 => {\n return mDivideScalar(m2, scalar, decimalPlaces) as Matrix2;\n};\n\nexport const m3DivideScalar = (m3: Matrix3, scalar: number, decimalPlaces = Infinity): Matrix3 => {\n return mDivideScalar(m3, scalar, decimalPlaces) as Matrix3;\n};\n\n\n// --------------- TRANSPOSE ----------------------\n\nexport const mTranspose = (m: Matrix): Matrix => {\n\n const vectorsCount = m.length;\n if(vectorsCount <= 0) return m;\n\n const vectorLength = m[0].length;\n if(vectorLength <= 0) return m;\n\n const matrix: Matrix = [];\n for(let i=0; i {\n return mTranspose(m2);\n};\n\nexport const m3Transpose = (m3: Matrix3): Matrix => {\n return mTranspose(m3);\n};\n\n// ----------------- RESET ----------------------\n\nexport const mReset = (m: Matrix, defaultValue = 0): Matrix => {\n\n if(m.length <= 0) return [];\n\n const res: Matrix = [];\n\n for(let i=0; i {\n return mReset(m2, defaultValue) as Matrix2;\n};\n\nexport const m3Reset = (m3: Matrix3, defaultValue = 0): Matrix3 => {\n return mReset(m3, defaultValue) as Matrix3;\n};\n\n// --------------- MATRIX INIT HELPERS -----------------\n\nexport const m2x2 = (defaultValue = 0): Matrix2 => {\n return [\n [defaultValue, defaultValue],\n [defaultValue, defaultValue],\n ];\n};\n\nexport const m3x3 = (defaultValue = 0): Matrix3 => {\n return [\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const m4x4 = (defaultValue = 0): Matrix4 => {\n return [\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n [defaultValue, defaultValue, defaultValue, defaultValue],\n ];\n};\n\nexport const mNxM = (N: number, M: number, defaultValue = 0): Matrix => {\n if(N <= 0 || M <= 0){\n throw new Error('M and N must be positive numbers.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return [\n [1, 0],\n [0, 1],\n ];\n};\n\nexport const identity3 = (): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\nexport const identity4 = (): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Identity Matrix (I).\n * M x I = I x M = M for any matrix M.\n * Identity Matrix is a special case of scale matrix.\n */\nexport const identityN = (N: number): Matrix => {\n if(N < 0){\n throw new Error('N must be a non-negative number.');\n }\n\n if(N === 0) return [];\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const matrix: Matrix = [];\n\n for(let i=0; i {\n return mDeepCopy(m2) as Matrix2;\n};\n\nexport const m3DeepCopy = (m3: Matrix3): Matrix3 => {\n return mDeepCopy(m3) as Matrix3;\n};\n\n// -------------- APPEND / PREPEND ROW OR COLUMN ---------------\n\nexport const mAppendCol = (m: Matrix, col: Vector): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n const copy = mDeepCopy(m);\n copy.push(row);\n return copy;\n};\n\nexport const m2AppendRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.push(row);\n return copy;\n};\n\nexport const m3AppendRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.push(row);\n return copy;\n};\n\nexport const mPrependRow = (m: Matrix, row: Vector) : Matrix => {\n const copy = mDeepCopy(m);\n copy.unshift(row);\n return copy;\n};\n\nexport const m2PrependRow = (m2: Matrix2, row: Vector2) : Matrix2 => {\n const copy = m2DeepCopy(m2);\n copy.unshift(row);\n return copy;\n};\n\nexport const m3PrependRow = (m3: Matrix3, row: Vector3) : Matrix3 => {\n const copy = m3DeepCopy(m3);\n copy.unshift(row);\n return copy;\n};\n\n// ------------ DELETE ROW OR COLUMN ----------------------------\n\nexport const mDelLastRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.pop();\n return copy;\n};\n\nexport const mDelFirstRow = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n copy.shift();\n return copy;\n};\n\nexport const mDelLastColumn = (m: Matrix): Matrix => {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const copy = mDeepCopy(m);\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const size = m[0].length;\n\n const vector: Vector = [];\n for(let i=0; i {\n if(m.length <= 0) return [];\n\n const vector: Vector = [];\n for(let i=0; i {\n\n const matrix: Matrix = [];\n for(let i=0; i {\n\n if(matrix.length < 0) return [];\n\n if(matrix[0].length !== vector.length){\n throw new Error('The number of columns in the matrix must be equal to the length of the vector.');\n }\n\n const res: Vector = [];\n\n for(let i=0; i {\n if(matrix1.length !== matrix2.length) return false;\n\n for(let i=0; i returns matrix N (m-1 x m-1)\n * The matrix must be square.\n */\nconst mMinorHelper = (m: Matrix, row: number, col: number) => {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const matrix: Matrix = [];\n\n for(let i=0; i {\n const size = m.length;\n\n if(size <= 0){\n throw new Error('The matrix should not be empty.');\n }\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // prepare the matrix without provided row and column\n const matrix = mMinorHelper(m, row, col);\n\n // calculate the matrix determinant\n return mDeterminant(matrix);\n};\n\n/**\n * Calculate determinant for NxN matrix.\n * Matrix should be square.\n */\nexport const mDeterminant = (matrix: Matrix): number => {\n const size = matrix.length;\n if(size === 0) return 1;\n\n if(size !== matrix[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return matrix[0][0];\n if(size === 2) return m2Determinant(matrix as Matrix2);\n\n let d = 0;\n\n for(let i=0; i {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return m2[0][0] * m2[1][1] - m2[1][0] * m2[0][1];\n};\n\n/**\n * Calculate determinant for 3x3 matrix.\n * Matrix should be square.\n */\nexport const m3Determinant = (m3: Matrix3): number => {\n if(m3.length !== m3[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return mDeterminant(m3);\n};\n\n// ------------------ INVERSE -----------------------\n\nexport const m2Adjugate = (m2: Matrix2): Matrix2|null => {\n if(m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n return [\n [m2[1][1], -m2[0][1]],\n [-m2[1][0], m2[0][0]],\n ];\n};\n\nexport const m3Adjugate = (m3: Matrix3) : Matrix3|null => {\n return mAdjugate(m3) as (Matrix3|null);\n};\n\n/**\n * Adjugate is a transpose of a cofactor matrix\n */\nexport const mAdjugate = (m: Matrix): Matrix|null => {\n\n const size = m.length;\n if(size <= 0) return null;\n\n if(size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n if(size === 1) return m;\n\n if(size === 2) return m2Adjugate(m as Matrix2);\n\n // build a cofactor matrix ----------------\n const cofactors: Matrix = [];\n\n for(let i=0; i {\n if(m.length > 0 && m.length !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = mDeterminant(m);\n return d === 0;\n};\n\n/**\n * Square matrix A (nxn) is invertible is there is another square matrix B (nxn) so AxB = BxA = I\n * For A (2x2) matrix, the inverse is:\n * (1 / (determinant(A))) * adj(A)\n */\nexport const m2Inverse = (m2: Matrix2, decimalPlaces = Infinity): (Matrix2 | null) => {\n if(m2.length > 0 && m2.length !== m2[0].length){\n throw new Error('The matrix must be square.');\n }\n\n const d = m2Determinant(m2);\n if(d === 0) return null;\n\n const adj = m2Adjugate(m2);\n if(adj === null) return null;\n\n return m2DivideScalar(adj, d, decimalPlaces);\n};\n\nexport const m3Inverse = (m3: Matrix3, decimalPlaces = Infinity): (Matrix3 | null) => {\n return mInverse(m3, decimalPlaces) as (Matrix3|null);\n};\n\nexport const mInverse = (m: Matrix, decimalPlaces = Infinity): (Matrix | null) => {\n const size = m.length;\n\n if(size > 0 && size !== m[0].length){\n throw new Error('The matrix must be square.');\n }\n\n // find a determinant ----------------------\n const d = mDeterminant(m);\n\n // find an Adjugate - a transpose of a cofactor matrix\n const adj = mAdjugate(m);\n if(adj === null) return null;\n\n return mDivideScalar(adj, d, decimalPlaces);\n};", "import { Matrix2, Matrix3, Matrix4, Matrix, Vector2, Vector3, Vector4 } from '../../types';\nimport { v2Normalize, v3MulScalar, v3Normalize } from './vector';\nimport { mMulVector, mMul } from './matrix';\nimport { setDecimalPlaces } from '../format';\n\n/*\nAny 2D affine transformation can be decomposed\ninto a rotation, followed by a scaling, followed by a\nshearing, and followed by a translation.\n---------------------------------------------------------\nAffine matrix = translation x shearing x scaling x rotation\n */\n\n// ----------------- CSS -------------------------------------\n\n/**\n * Matrix 2D in non-homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2ToCSS = (m: Matrix2) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, 0, 0)`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix\n */\nexport const m2hToCSS = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix(${ a }, ${ b }, ${ c }, ${ d }, ${ tx }, ${ ty })`;\n};\n\n/**\n * Matrix 2D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m2hToCSS3d = (m: Matrix3) : string => {\n const a = m[0][0];\n const b = m[1][0];\n const c = m[0][1];\n const d = m[1][1];\n const tx = m[0][2];\n const ty = m[1][2];\n\n return `matrix3d(${ a }, ${ b }, 0, 0, ${ c }, ${ d }, 0, 0, 0, 0, 1, 0, ${ tx }, ${ ty }, 0, 1)`;\n};\n\n/**\n * Matrix 3D in homogeneous coordinates to CSS matrix3d() function\n * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d\n */\nexport const m3hToCSS3d = (m: Matrix4) : string => {\n\n return `matrix3d(\n ${ m[0][0] }, ${ m[0][1] }, ${ m[0][2] }, ${ m[0][3] },\n ${ m[1][0] }, ${ m[1][1] }, ${ m[1][2] }, ${ m[1][3] },\n ${ m[2][0] }, ${ m[2][1] }, ${ m[2][2] }, ${ m[2][3] },\n ${ m[3][0] }, ${ m[3][1] }, ${ m[3][2] }, ${ m[3][3] }\n )`;\n};\n\n// ---------------- TRANSLATION MATRICES ----------------------\n\nexport const m2Translation = (position: Vector2, decimalPlaces = Infinity): Matrix2 => {\n\n return [\n [1, 0],\n [0, 1],\n [setDecimalPlaces(position[0], decimalPlaces), setDecimalPlaces(position[1], decimalPlaces)],\n ];\n};\n\nexport const m3Translation = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n [\n setDecimalPlaces(position[0], decimalPlaces),\n setDecimalPlaces(position[1], decimalPlaces),\n setDecimalPlaces(position[2], decimalPlaces)\n ],\n ];\n};\n\n/**\n * 2D Translation matrix in homogeneous coordinates.\n */\nexport const m2TranslationH = (position: Vector3, decimalPlaces = Infinity): Matrix3 => {\n\n return [\n [1, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1],\n ];\n};\n\n/**\n * 3D Translation matrix in homogeneous coordinates.\n */\nexport const m3TranslationH = (position: Vector4, decimalPlaces = Infinity): Matrix4 => {\n\n return [\n [1, 0, 0, setDecimalPlaces(position[0], decimalPlaces)],\n [0, 1, 0, setDecimalPlaces(position[1], decimalPlaces)],\n [0, 0, 1, setDecimalPlaces(position[2], decimalPlaces)],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- ROTATION MATRICES -------------------------\n\n/**\n * Rotation of an angle about the origin.\n */\nexport const m2Rotation = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix2 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin],\n [sin, cos],\n ] :\n [\n [cos, sin],\n [-sin, cos],\n ];\n};\n\n/**\n * Rotation of an angle about the origin in homogeneous coordinates (clockwise).\n */\nexport const m2RotationH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ]:\n [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation of an angle \"angleRad\" around the given point (transformOrigin) in homogeneous coordinates (clockwise).\n * result_vector = TranslationMatrix(x, y) * RotationMatrix() * TranslationMatrix(-x, -y) * position_vector\n */\nexport const m2RotationAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const rotation = m2RotationH(angleRad, isClockwise, decimalPlaces);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, rotation);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2RotateAroundPointH = (\n angleRad: number,\n transformOrigin: Vector3,\n position: Vector3,\n isClockwise = true,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2RotationAroundPointH(angleRad, transformOrigin, isClockwise, decimalPlaces);\n return mMulVector(mat3h, position) as Vector3;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2Rotate = (angleRad: number, vector: Vector2, isClockwise = true, decimalPlaces = Infinity): Vector2 => {\n const unitVector = v2Normalize(vector);\n return mMulVector(m2Rotation(angleRad, isClockwise, decimalPlaces), unitVector) as Vector2;\n};\n\n/**\n * Rotate vector around the origin by angle \"angleRad\" (clockwise).\n */\nexport const v2RotateH = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m2RotationH(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the X axis (clockwise).\n */\nexport const m3RotationX = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0],\n [0, cos, -sin],\n [0, sin, cos],\n ] :\n [\n [1, 0, 0],\n [0, cos, sin],\n [0, -sin, cos],\n ];\n};\n\n/**\n * Rotation around the X axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationXH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [1, 0, 0, 0],\n [0, cos, -sin, 0],\n [0, sin, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [1, 0, 0, 0],\n [0, cos, sin, 0],\n [0, -sin, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateX = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationX(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Y axis (clockwise).\n */\nexport const m3RotationY = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin],\n [0, 1, 0],\n [-sin, 0, cos],\n ] :\n [\n [cos, 0, -sin],\n [0, 1, 0],\n [sin, 0, cos],\n ];\n};\n\n/**\n * Rotation around the Y axis (clockwise) - in homogeneous coordinates\n */\nexport const m3RotationYH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, 0, sin, 0],\n [0, 1, 0, 0],\n [-sin, 0, cos, 0],\n [0, 0, 0, 1],\n ] :\n [\n [cos, 0, -sin, 0],\n [0, 1, 0, 0],\n [sin, 0, cos, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateY = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationY(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n/**\n * Rotation around the Z axis (clockwise).\n */\nexport const m3RotationZ = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix3 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0],\n [sin, cos, 0],\n [0, 0, 1],\n ] : [\n [cos, sin, 0],\n [-sin, cos, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Rotation around the Z axis (clockwise)- in homogeneous coordinates\n */\nexport const m3RotationZH = (angleRad: number, isClockwise = true, decimalPlaces = Infinity): Matrix4 => {\n\n const cos = setDecimalPlaces(Math.cos(angleRad), decimalPlaces);\n const sin = setDecimalPlaces(Math.sin(angleRad), decimalPlaces);\n\n return isClockwise ? [\n [cos, -sin, 0, 0],\n [sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ] : [\n [cos, sin, 0, 0],\n [-sin, cos, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\nexport const v3RotateZ = (angleRad: number, vector: Vector3, isClockwise = true, decimalPlaces = Infinity): Vector3 => {\n const unitVector = v3Normalize(vector);\n return mMulVector(m3RotationZ(angleRad, isClockwise, decimalPlaces), unitVector) as Vector3;\n};\n\n// ---------------- SCALE MATRICES -------------\n\n/**\n * Get matrix for arbitrary scaling pivot point.\n * result_vector = TranslationMatrix(x, y) * ScaleMatrix() * TranslationMatrix(-x, -y) * scale_vector\n */\nexport const m2ScaleAtPointHMatrix = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n decimalPlaces = Infinity): Matrix3 => {\n\n const translation = m2TranslationH(transformOrigin, decimalPlaces);\n const scale = m2ScaleH(scaleVector);\n const translationBack = m2TranslationH(v3MulScalar(transformOrigin, -1), decimalPlaces);\n const temp1 = mMul(translation, scale);\n return mMul(temp1, translationBack) as Matrix3;\n};\n\nexport const m2ScaleAtPointH = (\n scaleVector: Vector3,\n transformOrigin: Vector3,\n point: Vector3,\n decimalPlaces = Infinity): Vector3 => {\n\n const mat3h = m2ScaleAtPointHMatrix(scaleVector, transformOrigin, decimalPlaces);\n return mMulVector(mat3h, point) as Vector3;\n};\n\nexport const m2Scale = (scaleVector: Vector2): Matrix2 => {\n return [\n [scaleVector[0], 0],\n [0, scaleVector[1]],\n ];\n};\n\nexport const v2Scale = (scaleVector: Vector2, vector: Vector2): Vector2 => {\n return mMulVector(m2Scale(scaleVector), vector) as Vector2;\n};\n\n/**\n * homogeneous coordinates\n */\nexport const m2ScaleH = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, 1],\n ];\n};\n\nexport const m3Scale = (scaleVector: Vector3): Matrix3 => {\n return [\n [scaleVector[0], 0, 0],\n [0, scaleVector[1], 0],\n [0, 0, scaleVector[2]],\n ];\n};\n\nexport const m3ScaleH = (scaleVector: Vector4): Matrix4 => {\n return [\n [scaleVector[0], 0, 0, 0],\n [0, scaleVector[1], 0, 0],\n [0, 0, scaleVector[2], 0],\n [0, 0, 0, 1]\n ];\n};\n\nexport const v3Scale = (scaleVector: Vector3, vector: Vector3): Vector3 => {\n return mMulVector(m3Scale(scaleVector), vector) as Vector3;\n};\n\n/**\n * Stretch, parallel to the x-axis.\n */\nexport const m2ScaleX = (scale: number): Matrix2 => {\n return [\n [scale, 0],\n [0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the x-axis - homogeneous coordinates\n */\nexport const m2ScaleXH = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleX = (scale: number): Matrix3 => {\n return [\n [scale, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in x-direction\n */\nexport const m3ScaleXH = (scale: number): Matrix4 => {\n return [\n [scale, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleY = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Stretch in y-direction\n */\nexport const m3ScaleYH = (scale: number): Matrix => {\n return [\n [1, 0, 0, 0],\n [0, scale, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZ = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, scale],\n ];\n};\n\n/**\n * Stretch in z-direction\n */\nexport const m3ScaleZH = (scale: number): Matrix4 => {\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, scale, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis.\n */\nexport const m2ScaleY = (scale: number): Matrix2 => {\n return [\n [1, 0],\n [0, scale],\n ];\n};\n\n/**\n * Stretch, parallel to the y-axis - homogeneous coordinates\n */\nexport const m2ScaleYH = (scale: number): Matrix3 => {\n return [\n [1, 0, 0],\n [0, scale, 0],\n [0, 0, 1],\n ];\n};\n\n// ---------------- REFLECTION MATRICES -------------------------\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOrigin = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection about the origin.\n */\nexport const m2ReflectionOriginH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection about the origin in non-homogeneous coordinates\n */\nexport const m3ReflectionOrigin = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, -1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection about the origin in homogeneous coordinates\n */\nexport const m3ReflectionOriginH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection about y=-x\n */\nexport const m2ReflectionYmX = (): Matrix2 => {\n\n return [\n [0, -1],\n [-1, 0],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionX = (): Matrix2 => {\n\n return [\n [1, 0],\n [0, -1],\n ];\n};\n\n/**\n * Reflection in the x-axis.\n */\nexport const m2ReflectionXH = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection in the y-axis.\n */\nexport const m2ReflectionY = (): Matrix2 => {\n\n return [\n [-1, 0],\n [0, 1],\n ];\n};\n\nexport const m2ReflectionYH = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionYZ = (): Matrix3 => {\n\n return [\n [-1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to YZ plane in homogeneous coordinates\n */\nexport const m3ReflectionYZH = (): Matrix4 => {\n\n return [\n [-1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXZ = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, -1, 0],\n [0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XZ plane in homogeneous coordinates\n */\nexport const m3ReflectionXZH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, -1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in non-homogeneous coordinates\n */\nexport const m3ReflectionXY = (): Matrix3 => {\n\n return [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, -1],\n ];\n};\n\n/**\n * Reflection relative to XY plane in homogeneous coordinates\n */\nexport const m3ReflectionXYH = (): Matrix4 => {\n\n return [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, -1, 0],\n [0, 0, 0, 1],\n ];\n};\n\n// ---------------- SHEARING MATRICES -------------------------\n\n\n/**\n * Shearing in y-axis, with x-axis fixed with (0,1) moving to (factor, 1)\n */\nexport const m2ShearingY = (factor: number): Matrix2 => {\n\n return [\n [1, factor],\n [0, 1],\n ];\n};\n\n/**\n * Shearing in x-axis, with y-axis fixed with (1,0) moving to (1, factor)\n */\nexport const m2ShearingX = (factor: number): Matrix2 => {\n\n return [\n [1, 0],\n [factor, 1],\n ];\n};", "import { setDecimalPlaces } from './format';\n\n/**\n * Returns a random number in the [min,max] range.\n */\nexport const getRandom = (min: number, max: number, decimalPlaces = Infinity): number => {\n return setDecimalPlaces(Math.random() * (max - min) + min, decimalPlaces);\n};\n\n/**\n * Returns a random integer number in the [min,max] range.\n */\nexport const getRandomInt = (min: number, max: number): number => {\n return Math.floor(Math.random() * (max - min + 1) + min);\n};\n\nexport const getRandomBoolean = () => Math.random() < 0.5;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const getRandomItemFromArray = (array: any[]) => {\n const randomIndex = getRandomInt(0, array.length - 1);\n return array[randomIndex];\n};", "export const stringToNumber = (value: string|undefined|null|number, defaultNumber: number) => {\n if(value === undefined || value === null) return defaultNumber;\n const res = Number(value) ?? defaultNumber;\n return isNaN(res) ? defaultNumber : res;\n};", "import { setDecimalPlaces } from './format';\nimport { Vector2, Vector3 } from '../types';\n\n/**\n * u(x) and v(x) are functions ---------->\n *\n * dx(u + v) = dx(u) + dx(v)\n * dx(u - v) = dx(u) - dx(v)\n * dx(u * v) = dx(u) * v + u * dx(v)\n * dx(u / v) = (dx(u) * v - u * dx(v)) / (v ^ 2), when v(x) != 0\n */\n\n// ------------------ Derivatives of Polynomial ---------------------------\n\n/**\n * y = 3x+2\n * dxPolynomial(10, [[3, 1], [2, 0]])\n */\nexport const dxPolynomial = (x: number, polynomial: number[][], decimalPlaces = Infinity) => {\n let res = 0;\n\n for(const part of polynomial){\n if(part.length !== 2) return NaN;\n\n const coeff = part[0];\n const power = part[1];\n res += coeff * power * Math.pow(x, power - 1);\n }\n\n return setDecimalPlaces(res, decimalPlaces);\n}\n\n// ---------------------- Bezier Curves ---------------------------\n\n/**\n * Derivative of Bezier Curve is another Bezier Curve.\n * t must min in range [0, 1]\n */\nexport const dxV2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n // The derivative: P1 * (2t-2) + (2*P3-4*P2) * t + 2 * P2\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -2 * (1 - t); // Math.pow(1 - t, 2)\n const temp2 = 2 - 4 * t; // (1 - t) * 2 * t\n const temp3 = 2 * t; //t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\nexport const dxV2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const dxV3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = -3 * Math.pow(1 - t, 2); //Math.pow(1 - t, 3);\n const temp2 = 3 * (t - 1) * (3 * t - 1); //Math.pow(1 - t, 2) * 3 * t;\n const temp3 = 6 * t - 9 * t * t; // (1 - t) * 3 * t * t;\n const temp4 = 3 * t * t; //t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n\n// ----------------- Derivatives of trigonometry functions ---------------------------\n\nexport const dxSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(Math.cos(x), decimalPlaces);\n};\n\nexport const dxCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-Math.sin(x), decimalPlaces);\n};\n\nexport const dxTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.cos(x) ** 2), decimalPlaces);\n};\n\n/**\n * x != Math.PI * n, where n is an integer\n */\nexport const dxCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sin(x) ** 2), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcSin = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\n/**\n * -1 < x < 1\n */\nexport const dxArcCos = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (Math.sqrt(1 - x ** 2)), decimalPlaces);\n};\n\nexport const dxArcTan = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(1 / (1 + x ** 2), decimalPlaces);\n};\n\nexport const dxArcCot = (x: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(-1 / (1 + x ** 2), decimalPlaces);\n};\n", "import { Matrix, Matrix2, Matrix3, Vector, Vector2, Vector3 } from '../../types';\nimport { m2Inverse, m3Inverse, mInverse, mMulVector, mDelLastColumn, mGetLastColumn } from '../linear-algebra/matrix';\nimport { setDecimalPlaces } from '../format';\nimport { v2Sub } from '../linear-algebra/vector';\n\n/**\n * Linear equation\n * ax + b = c\n * x = (c - b) / a; a != 0\n */\nexport const linearEquation = (equation: Vector3, decimalPlaces = Infinity) : number => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n\n const diff = c - b;\n\n if(a === 0 && diff === 0) return Infinity; // any number is a solution\n if(a === 0) return NaN; // no solution\n\n return setDecimalPlaces(diff / a, decimalPlaces);\n};\n\n/**\n * System of 2 linear equations.\n * [x, y] = inverse(Matrix of equation parameters) x (vector of equation results)\n * ---------------\n * 3x + 2y = 7\n * -6x + 6y = 6\n */\nexport const linearEquationSystem2 = (equation1: Vector3, equation2: Vector3, decimalPlaces = Infinity) : Vector2 | null => {\n const equationParams: Matrix2 = [\n [equation1[0], equation1[1]],\n [equation2[0], equation2[1]],\n ];\n\n const inversed = m2Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector2 = [\n equation1[2],\n equation2[2]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector2;\n};\n\n/**\n * System of 3 linear equations.\n * ---------------------------------------\n * 3x + 2y + 5z = 7\n * -6x + 6y + 6z = 6\n * 2x + 7y - z = 4\n */\nexport const linearEquationSystem3 = (\n equation1: Vector,\n equation2: Vector,\n equation3: Vector,\n decimalPlaces = Infinity) : Vector3 | null => {\n const equationParams: Matrix3 = [\n [equation1[0], equation1[1], equation1[2]],\n [equation2[0], equation2[1], equation2[2]],\n [equation3[0], equation3[1], equation3[2]],\n ];\n\n const inversed = m3Inverse(equationParams);\n if(inversed === null) return null; // no results\n\n const equationResults: Vector3 = [\n equation1[3],\n equation2[3],\n equation3[3]\n ];\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector3;\n};\n\n/**\n * System of N linear equations.\n */\nexport const linearEquationSystemN = (equations: Matrix, decimalPlaces = Infinity) : Vector | null => {\n if(equations.length <= 0) return null;\n\n const equationParams = mDelLastColumn(equations);\n\n const inversed = mInverse(equationParams);\n if(inversed === null) return null; // no results\n\n // the last column of the equations matrix\n const equationResults = mGetLastColumn(equations);\n\n return mMulVector(inversed, equationResults, decimalPlaces) as Vector;\n};\n\n/**\n * Calculate the equation of a line given two points in a 2D space.\n * y = ax + b\n * y - y1 = m(x - x1)\n * m = (y2 - y1) / (x2 - x1)\n */\nexport const getLinearEquationBy2Points = (point1: Vector2, point2: Vector2) : {\n slope: number|undefined,\n yIntercept: number|undefined,\n xIntercept: number|undefined,\n formula: string,\n} => {\n const [deltaX, deltaY] = v2Sub(point2, point1);\n const [x, y] = point1;\n\n if(deltaX === 0) {\n return {\n slope: undefined,\n xIntercept: x,\n yIntercept: undefined,\n formula: `x = ${ x }`,\n };\n }\n\n const m = deltaY / deltaX;\n const b = y - m * x;\n let formula = '';\n\n if(m === 0) {\n formula = `y = ${ b }`;\n }\n else{\n formula = `y = ${ m === 1 ? '' : m }x`;\n\n if(b !== 0) {\n formula += ` ${ b < 0 ? '-' : '+' } ${ Math.abs(b) }`;\n }\n }\n\n return {\n slope: m,\n xIntercept: undefined,\n yIntercept: b,\n formula,\n };\n};", "import { Vector } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport { linearEquation } from './linear-equations';\nimport { isNumber } from '../other';\n\n/**\n * Quadratic Equation.\n * ax^2 + bx + c = d\n */\nexport const quadraticEquation = (equation: Vector, decimalPlaces = Infinity) : Vector => {\n const a = equation[0];\n const b = equation[1];\n const c = equation[2];\n const d = equation[3];\n\n if(a === 0){\n // it's a linear equation -------------------------------------------\n const res = linearEquation([b, c, d], decimalPlaces);\n if(isNumber(res)) return [res];\n return [];\n }\n\n const diff = c - d;\n\n const discriminant = b * b - (4 * a * diff);\n\n if(discriminant < 0){\n return []; // no results\n }\n\n if(discriminant === 0){\n return [ setDecimalPlaces(-b / (2 * a), decimalPlaces) ]; // 1 result\n }\n\n // if(determinant > 0) ---> 2 results\n const t1 = 2 * a;\n const t2 = Math.sqrt(discriminant);\n\n return [\n setDecimalPlaces((-b + t2) / t1, decimalPlaces),\n setDecimalPlaces((-b - t2) / t1, decimalPlaces),\n ];\n};", "import { IBBox, Vector, Vector2, Vector3 } from '../../types';\nimport { setDecimalPlaces } from '../format';\nimport {\n dxV2CubicBezierCurve,\n dxV2QuadraticBezierCurve,\n dxV3CubicBezierCurve,\n dxV3QuadraticBezierCurve\n} from '../derivative';\nimport { v2Normalize, v3Normalize } from '../linear-algebra/vector';\nimport { linearEquation } from '../equations/linear-equations';\nimport { quadraticEquation } from '../equations/quadratic-equations';\nimport { isNumber } from '../other';\n\n/**\n * B\u00E9zier Curves\n * quadratic: y = P1 * (1-t)\u00B2 + P2 * 2 * (1-t)t + P3 * t\u00B2\n * t in range [0, 1]\n */\n\n// -------------------- GET POINT ON CURVE --------------------------\n\n/**\n * Get a point on a quadratic B\u00E9zier curve as a function of time.\n */\nexport const v2QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3QuadraticBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 2);\n const temp2 = (1 - t) * 2 * t;\n const temp3 = t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * centerControlPoint[0] + temp3 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * centerControlPoint[1] + temp3 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * centerControlPoint[2] + temp3 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n/**\n * Get a point on a cubic B\u00E9zier curve as a function of time.\n */\nexport const v2CubicBezierCurve = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n ];\n};\n\nexport const v3CubicBezierCurve = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n\n const temp1 = Math.pow(1 - t, 3);\n const temp2 = Math.pow(1 - t, 2) * 3 * t;\n const temp3 = (1 - t) * 3 * t * t;\n const temp4 = t * t * t;\n\n return [\n setDecimalPlaces(temp1 * startControlPoint[0] + temp2 * center1ControlPoint[0] + temp3 * center2ControlPoint[0] + temp4 * endControlPoint[0], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[1] + temp2 * center1ControlPoint[1] + temp3 * center2ControlPoint[1] + temp4 * endControlPoint[1], decimalPlaces),\n setDecimalPlaces(temp1 * startControlPoint[2] + temp2 * center1ControlPoint[2] + temp3 * center2ControlPoint[2] + temp4 * endControlPoint[2], decimalPlaces),\n ];\n};\n\n// -------------------- TANGENT --------------------------\n\n/**\n * Tangent indicates the direction of travel at specific points along the B\u00E9zier curve,\n * and is literally just the first derivative of our curve.\n */\nexport const v2QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3QuadraticBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n centerControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3QuadraticBezierCurve(t, startControlPoint, centerControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\nexport const v2CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n const dxVector = dxV2CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v2Normalize(dxVector, decimalPlaces);\n};\n\nexport const v3CubicBezierCurveTangent = (\n t: number,\n startControlPoint: Vector3,\n center1ControlPoint: Vector3,\n center2ControlPoint: Vector3,\n endControlPoint: Vector3,\n decimalPlaces = Infinity\n) : Vector3 => {\n const dxVector = dxV3CubicBezierCurve(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n return v3Normalize(dxVector, decimalPlaces);\n};\n\n// -------------------- NORMAL --------------------------\n\n/**\n * Normal is a vector that runs at a right angle to the direction of the curve, and is typically of length 1.\n * To find it, we take the normalised tangent vector, and then rotate it by a 90 degrees.\n */\nexport const v2QuadraticBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2QuadraticBezierCurveTangent(t, startControlPoint, centerControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\nexport const v2CubicBezierCurveNormal = (\n t: number,\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2 => {\n\n const tangent = v2CubicBezierCurveTangent(t, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint, decimalPlaces);\n return [-tangent[1], tangent[0]];\n};\n\n// -------------------- EXTREMA --------------------------\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2QuadraticBezierCurveExtrema = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector => {\n\n /*\n (-2 * (1 - t)) * startControlPoint[0] + (2 - 4 * t) * centerControlPoint[0] + (2 * t) * endControlPoint[0]\n 2 * t * startControlPoint[0] - 4 * t * centerControlPoint[0] + 2 * t * endControlPoint[0] - 2 * startControlPoint[0] + 2 * centerControlPoint[0]\n t * (2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0]) + (- 2 * startControlPoint[0] + 2 * centerControlPoint[0])\n */\n\n const a1 = 2 * startControlPoint[0] - 4 * centerControlPoint[0] + 2 * endControlPoint[0];\n const b1 = -2 * startControlPoint[0] + 2 * centerControlPoint[0];\n const equation1: Vector3 = [a1, b1, 0];\n const res1 = linearEquation(equation1, decimalPlaces);\n\n const a2 = 2 * startControlPoint[1] - 4 * centerControlPoint[1] + 2 * endControlPoint[1];\n const b2 = -2 * startControlPoint[1] + 2 * centerControlPoint[1];\n const equation2: Vector3 = [a2, b2, 0];\n const res2 = linearEquation(equation2, decimalPlaces);\n\n const res: Vector = [];\n\n if(isNumber(res1)){\n res.push(res1);\n }\n\n if(isNumber(res2)){\n res.push(res2);\n }\n\n return res;\n};\n\n/**\n * Find maxima and minima by solving the equation B'(t) = 0\n * Returns result in [0, 1] range.\n */\nexport const v2CubicBezierCurveExtrema = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : Vector2|null => {\n\n const a1 = -3 * startControlPoint[0] + 9 * center1ControlPoint[0] - 9 * center2ControlPoint[0] + 3 * endControlPoint[0];\n const b1 = 6 * startControlPoint[0] - 12 * center1ControlPoint[0] + 6 * center2ControlPoint[0];\n const c1 = -3 * startControlPoint[0] + 3 * center1ControlPoint[0];\n const equation1: Vector = [a1, b1, c1, 0];\n\n const a2 = -3 * startControlPoint[1] + 9 * center1ControlPoint[1] - 9 * center2ControlPoint[1] + 3 * endControlPoint[1];\n const b2 = 6 * startControlPoint[1] - 12 * center1ControlPoint[1] + 6 * center2ControlPoint[1];\n const c2 = -3 * startControlPoint[1] + 3 * center1ControlPoint[1];\n const equation2: Vector = [a2, b2, c2, 0];\n\n // Any value between 0 and 1 is a root that matters for B\u00E9zier curves, anything below or above that is irrelevant (because B\u00E9zier curves are only defined over the interval [0,1]).\n const res1 = quadraticEquation(equation1, decimalPlaces).filter(num => num >= 0 && num <= 1);\n const res2 = quadraticEquation(equation2, decimalPlaces).filter(num => num >= 0 && num <= 1);\n\n const res = [...res1, ...res2];\n if(res.length === 2){\n return [...res1, ...res2] as Vector2;\n }\n\n return null;\n};\n\n// -------------------- BOUNDING BOX --------------------------\n\nexport const v2QuadraticBezierBBox = (\n startControlPoint: Vector2,\n centerControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2QuadraticBezierCurveExtrema(startControlPoint, centerControlPoint, endControlPoint);\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2QuadraticBezierCurve(percent, startControlPoint, centerControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\nexport const v2CubicBezierBBox = (\n startControlPoint: Vector2,\n center1ControlPoint: Vector2,\n center2ControlPoint: Vector2,\n endControlPoint: Vector2,\n decimalPlaces = Infinity\n) : IBBox => {\n\n const extrema = v2CubicBezierCurveExtrema(startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint) || [];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for(const percent of extrema){\n const point = v2CubicBezierCurve(percent, startControlPoint, center1ControlPoint, center2ControlPoint, endControlPoint);\n\n const x = point[0];\n const y = point[1];\n\n minX = Math.min(minX, x ?? Infinity);\n maxX = Math.max(maxX, x ?? -Infinity);\n\n minY = Math.min(minY, y ?? Infinity);\n maxY = Math.max(maxY, y ?? -Infinity);\n }\n\n minX = setDecimalPlaces(Math.min(minX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n maxX = setDecimalPlaces(Math.max(maxX, startControlPoint[0], endControlPoint[0]), decimalPlaces);\n minY = setDecimalPlaces(Math.min(minY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n maxY = setDecimalPlaces(Math.max(maxY, startControlPoint[1], endControlPoint[1]), decimalPlaces);\n\n return {\n x: minX,\n y: minY,\n w: Math.abs(maxX - minX),\n h: Math.abs(maxY - minY),\n x2: maxX,\n y2: maxY,\n }\n};\n\n\n", "import { Vector2 } from '../types';\nimport { v2Sub } from './linear-algebra/vector';\nimport { getV2Angle } from './angle';\nimport { convertRange } from './other';\n\n/**\n * Circle Equation\n * x^2 + y^2 = radius^2\n * ----------------------\n * Circle Parametric Equation\n * x(t) = radius * cos(t)\n * y(t) = radius * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const circleMovement = (center: Vector2, angle: number, radius: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius,\n center[1] + Math.sin(angle) * radius\n ];\n};\n\n/**\n * Circle Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const circleMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radius: number\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return circleMovement(center, angle, radius);\n};\n\n/**\n * Ellipse Equation\n * (x - centerX)^2 / (radius1^2) + (y - centerY)^2 / (radius2^2) = 1\n * -----------------------------------------------------------------\n * Ellipse Parametric Equation\n * x(t) = radius1 * cos(t)\n * y(t) = radius2 * sin(t)\n * t is the parameter = angle\n *\n * Angle should be in the range [0, Math.PI]\n */\nexport const ellipseMovement = (center: Vector2, angle: number, radius1: number, radius2: number): Vector2 => {\n angle = angle % Math.PI * 2;\n\n return [\n center[0] + Math.cos(angle) * radius1,\n center[1] + Math.sin(angle) * radius2\n ];\n};\n\n/**\n * Ellipse Movement After Mouse.\n * Mouse Positions:\n * - pageX/Y coordinates are relative to the top left corner of the whole rendered page (including parts hidden by scrolling),\n * - screenX and screenY: Relative to the top left of the physical screen/monitor, this reference point only moves if you increase or decrease the number of monitors or the monitor resolution.\n * - clientX/Y coordinates are relative to the top left corner of the visible part of the page, \"seen\" through browser window.\n * - offsetX and offsetY are relative to the parent container,\n */\nexport const ellipseMovementAfterMouse = (\n mouse: Vector2,\n center: Vector2,\n radii: Vector2\n): Vector2 => {\n\n const vector = v2Sub(mouse, center);\n\n let angle = getV2Angle(vector);\n\n // convert the angle from the range [0, Math.PI*2] to the range [0, Math.PI]\n angle = convertRange(angle, 0, Math.PI*2, 0, Math.PI);\n\n return ellipseMovement(center, angle, radii[0], radii[1]);\n};\n\n/**\n * Sine Wave Equation (Sinusoid)\n * -----------------------------\n * const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n * amplitude = the peak deviation of the function from zero\n * frequency = number of cycles\n * phase = specifies (in radians) where in its cycle the oscillation is at t = 0.\n * think of it as \"shifting\" the starting point of the function to the right (positive p) or left (negative)\n */\nexport const sineWaveMovement = (x: number, amplitude: number, frequency: number, phase: number) : Vector2 => {\n /*\n example values:\n const amplitude = 50;\n const frequency = 0.005;\n const phase = 0;\n x: [0, 1000]\n */\n const y = amplitude * Math.sin(2 * Math.PI * frequency * x + phase);\n\n return [x, y];\n};\n\n/**\n * Lissajous curve (Lissajous figure or Bowditch curve)\n * Parametric equation #1\n * f(t) = A * sin(k * t + m)\n * f(t) = B * sin(n * t)\n * 0 <= m <= PI/2\n * k, n >= 1\n * -----------------------\n * Parametric equation #2\n * f(t) = A * cos(k * t - m)\n * f(t) = B * cos(n * t - p)\n * -----------------------------\n * Shapes:\n * k = 1, n = 1, m = 0, p = 0 ---> line\n * A = B, k = 1, n = 1, m = PI/2, p = PI/2 ----> circle\n * A != B, k = 1, n = 1, m = PI/2, p = PI/2 ----> ellipse\n * k = 2, n = 2, m = PI/2, p = PI/2 ----> section of a parabola\n */\nexport const lissajousCurve = (\n width: number,\n height: number,\n t: number,\n k: number,\n n: number,\n m: number,\n p: number\n) :Vector2 => {\n return [\n width * Math.cos(k * t - m),\n height * Math.cos(n * t - p),\n ];\n};\n", "import { getRandom } from './random';\nimport { HSLColor, LABColor, RGBColor } from '../types';\nimport { mod } from './other';\nimport { setDecimalPlaces } from './format';\n\n// ------------------------ RANDOM COLOR -------------------------------------\n\nexport const getRandomRGBColor = () : RGBColor => {\n const hslColor = getRandomHSLColor();\n return hslToRgb(hslColor);\n};\n\nexport const getRandomHexColor = () : string => {\n const hslColor = getRandomHSLColor();\n return hslToHex(hslColor);\n};\n\nexport const getRandomHSLColor = () : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given hue\n */\nexport const getRandomHSLColorWithHue = (h: number) : HSLColor => {\n const s = getRandom(0, 100);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given saturation\n */\nexport const getRandomHSLColorWithSaturation = (s: number) : HSLColor => {\n const h = getRandom(1, 360);\n const l = getRandom(0, 100);\n return [h, s, l];\n};\n\n/**\n * generate random color with the given lightness\n */\nexport const getRandomHSLColorWithLightness = (l: number) : HSLColor => {\n const h = getRandom(1, 360);\n const s = getRandom(0, 100);\n return [h, s, l];\n};\n\nexport const getRandomGrayscaleHSLColor = () : HSLColor => {\n const l = getRandom(0, 100);\n return [0, 0, l];\n};\n\nexport const getRandomHSLColorWithinRanges = (\n hueStart = 1, hueEnd = 360,\n saturationStart = 0, saturationEnd = 100,\n lightStart = 0, lightEnd = 100\n) : HSLColor => {\n const h = getRandom(hueStart, hueEnd);\n const s = getRandom(saturationStart, saturationEnd);\n const l = getRandom(lightStart, lightEnd);\n return [h, s, l];\n};\n\n// ----------------------- CONVERT COLORS --------------------------------------\n\n/**\n * helper: convert hue value to degrees.\n * @param {number} h\n * @return {number} [0, 360] degrees\n */\nconst convertHueToDegrees = (h : number) : number => {\n\n // the hue value needs to be multiplied by 60 to convert it to degrees\n h *= 60;\n\n // if hue becomes negative, you need to add 360 to, because a circle has 360 degrees\n if(h < 0){\n h += 360;\n }\n\n return h;\n // convert huw to %\n // return h * 100 / 360;\n};\n\n/**\n * get hue from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] % - we use here % instead of [0, 359] degrees\n */\nconst getHue = (r : number, g : number, b : number, min : number | undefined = undefined, max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (max === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no hue, as it's gray\n if(min === max) return 0;\n\n const diff = max - min;\n\n let h = 0;\n\n // if red is max\n if(max === r){\n h = (g - b) / diff + (g < b ? 6 : 0);\n }\n\n // if green is max\n if(max === g){\n h = 2 + (b - r) / diff;\n }\n\n // if blue is max\n if(max === b){\n h = 4 + (r - g) / diff;\n }\n\n return convertHueToDegrees(h);\n};\n\n/**\n * get luminance from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @return {number} [0, 100] %\n */\nconst getLuminance = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // calculate the luminance value\n // @ts-ignore\n const l = (min + max) / 2; // [0, 1]\n\n // return l value in %\n return l * 100;\n};\n\n/**\n * get saturation from RGB\n * @param {number} r [0, 255]\n * @param {number} g [0, 255]\n * @param {number} b [0, 255]\n * @param {number|undefined=} min - min number of [r, g, b]\n * @param {number|undefined=} max - max number of [r, g, b]\n * @param {number|undefined=} l - luminance in [0, 100] %\n * @return {number} [0, 100] %\n */\nconst getSaturation = (\n r : number,\n g : number,\n b : number,\n min : number | undefined = undefined,\n max : number | undefined = undefined,\n l : number | undefined = undefined) : number => {\n\n // find the minimum and maximum values of r, g, and b if they are not provided\n min = (min === undefined) ? Math.min(r, g, b) : min;\n max = (min === undefined) ? Math.max(r, g, b) : max;\n\n // if the min and max value are the same -> no saturation, as it's gray\n if(min === max) return 0;\n\n // calculate luminance if it's not provided\n l = (l === undefined) ? getLuminance(r, g, b) : l;\n\n // check the level of luminance\n const s = (l <= 50) ?\n // @ts-ignore\n ((max - min) / (max + min)) : // this formula is used when luminance <= 50%\n // @ts-ignore\n (max - min) / (2.0 - max - min); // this formula is used when luminance > 50%\n\n // return saturation in %\n return s * 100;\n};\n\nexport const rgbToHsl = (rgb: RGBColor, decimalPlaces = Infinity): HSLColor => {\n\n // convert rgb values to the range [0, 1]\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n // find the minimum and maximum values of r, g, and b\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n\n // calculate the luminance value in %\n const l = getLuminance(r, g, b, min, max);\n\n // calculate the saturation in %\n const s = getSaturation(r, g, b, min, max, l);\n\n // calculate the hue in % (not in degrees!)\n const h = getHue(r, g, b, min, max);\n\n if(h > 360 || s > 100 || l > 100){\n return [0, 0, 100];\n }\n\n if(h < 0 || s < 0 || l < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(h, decimalPlaces),\n setDecimalPlaces(s, decimalPlaces),\n setDecimalPlaces(l, decimalPlaces),\n ];\n};\n\n/**\n * helper: HSL to RGB\n */\nconst hslToRgbHelper = (helper1 : number, helper2 : number, colorHelper : number) : number => {\n\n // all values need to be between 0 and 1\n // if you get a negative value you need to add 1 to it\n if(colorHelper < 0) colorHelper += 1;\n\n // if you get a value above 1 you need to subtract 1 from it.\n if(colorHelper > 1) colorHelper -= 1;\n\n if(colorHelper * 6 < 1) return helper2 + (helper1 - helper2) * 6 * colorHelper;\n\n if(colorHelper * 2 < 1) return helper1;\n\n if(colorHelper * 3 < 2){\n return helper2 + (helper1 - helper2) * (0.666 - colorHelper) * 6;\n }\n else{\n return helper2;\n }\n};\n\nexport const hslToRgb = (hsl: HSLColor, decimalPlaces = Infinity): RGBColor => {\n\n // convert all values to [0, 1] from %\n const h = hsl[0] / 100;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n // if there is no saturation -> it\u2019s grey\n if(s === 0){\n // convert the luminance from [0, 1] to [0, 255]\n const gray = l * 255;\n return [gray, gray, gray];\n }\n\n // check the level of luminance\n const helper1 = (l < 0.5) ?\n (l * (1.0 + s)) :\n (l + s - l * s);\n\n const helper2 = 2 * l - helper1;\n\n const rHelper = h + 0.333;\n const gHelper = h;\n const bHelper = h - 0.333;\n\n let r = hslToRgbHelper(helper1, helper2, rHelper);\n let g = hslToRgbHelper(helper1, helper2, gHelper);\n let b = hslToRgbHelper(helper1, helper2, bHelper);\n\n // convert rgb to [0, 255]\n r *= 255;\n g *= 255;\n b *= 255;\n\n if(r > 255 || g > 255 || b > 255){\n return [255, 255, 255];\n }\n\n if(r < 0 || g < 0 || b < 0){\n return [0, 0, 0];\n }\n\n return [\n setDecimalPlaces(r, decimalPlaces),\n setDecimalPlaces(g, decimalPlaces),\n setDecimalPlaces(b, decimalPlaces),\n ];\n};\n\n/**\n * HSL to hex\n * hslToHex(360, 100, 50) // [360, 100, 5] ==> \"#ff0000\" (red)\n */\nexport const hslToHex = (hsl: HSLColor) => {\n\n if(hsl[0] > 360 || hsl[1] > 100 || hsl[2] > 100){\n return '#ffffff';\n }\n\n if(hsl[0] < 0 || hsl[1] < 0 || hsl[2] < 0){\n return '#000000';\n }\n\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n\n let r, g, b;\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n const toHex = (x: number) => {\n const hex = Math.round(x * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n};\n\n/**\n * RGB to HEX\n * rgbToHex([235, 64, 52]) // #eb4034\n */\nexport const rgbToHex = (rgb: RGBColor) => {\n const [r, g, b] = rgb;\n return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);\n};\n\nexport const hexToRgb = (hex: string) : RGBColor | null => {\n\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n const _hex = hex.replace(shorthandRegex, (_m, r, g, b) => {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(_hex);\n if(!result) return null;\n\n const r = parseInt(result[1], 16);\n const g = parseInt(result[2], 16);\n const b = parseInt(result[3], 16);\n\n return [r, g, b];\n};\n\nexport const rgbToLab = (rgb: RGBColor, decimalPlaces = Infinity) : LABColor => {\n\n let r = rgb[0] / 255;\n let g = rgb[1] / 255;\n let b = rgb[2] / 255;\n\n r = (r > 0.04045) ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;\n g = (g > 0.04045) ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;\n b = (b > 0.04045) ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;\n\n let x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;\n let y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.00000;\n let z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;\n\n x = (x > 0.008856) ? Math.pow(x, 1/3) : (7.787 * x) + 16/116;\n y = (y > 0.008856) ? Math.pow(y, 1/3) : (7.787 * y) + 16/116;\n z = (z > 0.008856) ? Math.pow(z, 1/3) : (7.787 * z) + 16/116;\n\n return [\n setDecimalPlaces((116 * y) - 16, decimalPlaces),\n setDecimalPlaces(500 * (x - y), decimalPlaces),\n setDecimalPlaces(200 * (y - z), decimalPlaces),\n ];\n};\n\nexport const labToRgb = (lab: LABColor, decimalPlaces = Infinity) : RGBColor => {\n let y = (lab[0] + 16) / 116;\n let x = lab[1] / 500 + y;\n let z = y - lab[2] / 200;\n\n x = 0.95047 * ((x * x * x > 0.008856) ? x * x * x : (x - 16/116) / 7.787);\n y = 1.00000 * ((y * y * y > 0.008856) ? y * y * y : (y - 16/116) / 7.787);\n z = 1.08883 * ((z * z * z > 0.008856) ? z * z * z : (z - 16/116) / 7.787);\n\n let r = x * 3.2406 + y * -1.5372 + z * -0.4986;\n let g = x * -0.9689 + y * 1.8758 + z * 0.0415;\n let b = x * 0.0557 + y * -0.2040 + z * 1.0570;\n\n r = (r > 0.0031308) ? (1.055 * Math.pow(r, 1/2.4) - 0.055) : 12.92 * r;\n g = (g > 0.0031308) ? (1.055 * Math.pow(g, 1/2.4) - 0.055) : 12.92 * g;\n b = (b > 0.0031308) ? (1.055 * Math.pow(b, 1/2.4) - 0.055) : 12.92 * b;\n\n return [\n setDecimalPlaces(Math.max(0, Math.min(1, r)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, g)) * 255, decimalPlaces),\n setDecimalPlaces(Math.max(0, Math.min(1, b)) * 255, decimalPlaces),\n ];\n};\n\n// ----------------------- GET SHIFTED COLORS --------------------------------------\n\nexport const getShiftedHue = (color: HSLColor, shift = 180) : HSLColor => {\n let hue = color[0];\n hue += shift;\n\n if (hue > 360 || hue < 0) {\n hue = mod(hue, 360);\n }\n\n return [hue, color[1], color[2]];\n};\n\nexport const getShiftedLightness = (color: HSLColor, shift = 10) : HSLColor => {\n let lightness = color[2];\n lightness += shift;\n\n if (lightness > 100 || lightness < 0) {\n lightness = mod(lightness, 100);\n }\n\n return [color[0], color[1], lightness];\n};\n\nexport const getShiftedSaturation = (color: HSLColor, shift = 10) : HSLColor => {\n let saturation = color[1];\n saturation += shift;\n\n if (saturation > 100) {\n saturation -= 100;\n }\n\n if(saturation < 0){\n saturation += 100;\n }\n\n return [color[0], saturation, color[2]];\n};\n\n// ----------------------- SIMILAR COLORS --------------------------------------\n\n/**\n * Measure the perceptual difference between two RGB colors using the CIE76 color difference formula:\n * delta = Math.sqrt((L2 - L1)^2 + (a2 - a1)^2 + (b2 - b1)^2)\n * https://en.wikipedia.org/wiki/Color_difference\n * https://stackoverflow.com/questions/13586999/color-difference-similarity-between-two-values-with-js\n * <= 1.0 Not perceptible by human eyes.\n * 1 - 2 Perceptible through close observation.\n * 2 - 10 Perceptible at a glance.\n * 11 - 49 Colors are more similar than opposite\n * 100 Colors are exact opposite\n */\nexport const getColorsDelta = (rgbA: RGBColor, rgbB: RGBColor, decimalPlaces = Infinity) => {\n const labA = rgbToLab(rgbA, decimalPlaces);\n const labB = rgbToLab(rgbB, decimalPlaces);\n\n // differences between the LAB components of the two colors\n const deltaL = labA[0] - labB[0];\n const deltaA = labA[1] - labB[1];\n const deltaB = labA[2] - labB[2];\n\n // chroma components\n const c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);\n const c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);\n const deltaC = c1 - c2;\n\n // difference in hue, deltaH, which takes into account both the differences\n // in the a* and b* components of LAB and the differences in chroma.\n let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;\n deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);\n\n const sc = 1.0 + 0.045 * c1;\n const sh = 1.0 + 0.015 * c1;\n\n // It applies weighting factors to the differences in lightness (deltaL),\n // chroma (deltaC), and hue (deltaH).\n const deltaLKlsl = deltaL / (1.0);\n const deltaCkcsc = deltaC / (sc);\n const deltaHkhsh = deltaH / (sh);\n\n // It computes the final color difference using the CIE76 formula:\n // deltaE = sqrt(deltaLKlsl^2 + deltaCkcsc^2 + deltaHkhsh^2),\n // where deltaLKlsl is the weighted lightness difference,\n // deltaCkcsc is the weighted chroma difference,\n // and deltaHkhsh is the weighted hue difference.\n const i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;\n\n // It returns the calculated color difference,\n // optionally rounded to the specified number of decimal places.\n return i < 0 ? 0 : Math.sqrt(i);\n};\n", "/**\n * guid like '932ade5e-c515-4807-ac01-73b20ab3fb66'\n */\nexport const guid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = Math.random() * 16 | 0;\n return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);\n });\n};\n\n/**\n * id like 'df4unio1opulby2uqh4'\n */\nexport const newId = () => {\n return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);\n};\n", "import { ICircle, IPolygon, IRect, Matrix2, Vector2 } from '../types';\nimport { mod } from './other';\nimport { v2GetNormal, v2DotProduct } from './linear-algebra/vector';\n\n/**\n * Rectangles collision detection.\n * Rectangles should not be rotated.\n * The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles.\n * Any gap means a collision does not exist.\n * Returns true if collision is detected.\n */\nexport const rectCollide = (rect1: IRect, rect2: IRect) : boolean => {\n return rect1.x <= rect2.x + rect2.w &&\n rect1.x + rect1.w >= rect2.x &&\n rect1.y <= rect2.y + rect2.h &&\n rect1.h + rect1.y >= rect2.y;\n};\n\n/**\n * Circles collision detection.\n * This algorithm works by taking the center points of the two circles\n * and ensuring the distance between the center points\n * are less than the two radii added together.\n * Returns true if collision is detected.\n */\nexport const circleCollide = (circle1: ICircle, circle2: ICircle) => {\n const dx = Math.abs(circle1.cx - circle2.cx);\n const dy = Math.abs(circle1.cy - circle2.cy);\n const distance = Math.sqrt(dx * dx + dy * dy);\n return distance <= circle1.r + circle2.r;\n};\n\n//-------------------- Separating Axis Theorem (SAT) Collision detection -------------------------\n\nconst getEdges = (poly: IPolygon) : Matrix2[] => {\n const edges: Matrix2[] = [];\n\n for(let i= 0; i {\n const edges: Matrix2[] = [];\n\n // collect polygon edges, and combine then into a single array\n edges.push(...getEdges(poly1));\n edges.push(...getEdges(poly2));\n\n // for each edge, find the normal vector and project both polygons onto it\n for (const edge of edges) {\n const normal = v2GetNormal(edge[0], edge[1]);\n const p1Proj = projectPolygon(poly1, normal);\n const p2Proj = projectPolygon(poly2, normal);\n\n // Check if the projections overlap\n const isOverlap = p1Proj.max >= p2Proj.min && p2Proj.max >= p1Proj.min;\n\n // Check if the projections overlap; if not, the polygons do not collide\n if (!isOverlap) return false;\n }\n\n // If all tests pass, the polygons overlap and collide\n return true;\n};\n\n/**\n * Project every polygon point onto the normal.\n * Then find min and max.\n */\nconst projectPolygon = (polygon: IPolygon, normal: Vector2): { min: number, max: number } => {\n let min = Infinity;\n let max = -Infinity;\n\n // Project each vertex of the polygon onto the axis\n for (const vertex of polygon) {\n const projection = v2DotProduct(vertex, normal);\n min = Math.min(min, projection);\n max = Math.max(max, projection);\n }\n\n return { min, max };\n};", "export interface IAnimationProps {\n duration?: number;\n callback: (result: IAnimationResult) => void;\n restartOnResize?: boolean;\n resizeCallback?: (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => void;\n}\n\nexport interface IAnimationResult {\n start: () => void;\n stop: () => void;\n pause: () => void;\n resume: () => void;\n restart: () => void;\n isAnimating: () => boolean;\n getStartTime: () => number|undefined;\n getElapsedTime: () => number|undefined;\n getPercent: () => number|undefined;\n getResizeObserver: () => ResizeObserver|undefined;\n}\n\nexport const animate = (props: IAnimationProps) : IAnimationResult => {\n\n const _duration = props.duration !== undefined ? props.duration : Infinity;\n\n let startTime: number|undefined = undefined; // in milliseconds\n let animationId: number|undefined = undefined;\n\n // the time elapsed since the start of the animation (in milliseconds)\n let elapsed: number|undefined = undefined;\n let previousTimeStamp: number|undefined = undefined;\n\n let animating = false;\n let observer: ResizeObserver|undefined = undefined;\n\n // -------------------- COMMANDS ---------------------\n\n const stop = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = false;\n\n /*if(observer !== undefined){\n observer.disconnect();\n observer = undefined;\n }*/\n\n if(animationId === undefined) return;\n window.cancelAnimationFrame(animationId);\n };\n\n const restart = () => {\n stop();\n start();\n };\n\n const pause = () => {\n animating = false;\n };\n\n const resume = () => {\n animating = true;\n };\n\n /**\n * Animation Step.\n * @param {number} timeStamp in milliseconds\n */\n const step = (timeStamp: DOMHighResTimeStamp) => {\n\n if (startTime === undefined) {\n startTime = timeStamp;\n }\n\n // the time elapsed since the start of the animation (in milliseconds)\n elapsed = timeStamp - startTime;\n\n if (animating && previousTimeStamp !== timeStamp && typeof props.callback === 'function') {\n\n // do the rendering .............\n props.callback(getResult());\n }\n\n if(elapsed <= _duration){\n previousTimeStamp = timeStamp;\n animationId = window.requestAnimationFrame(step);\n }\n else{\n stop();\n }\n };\n\n const observerHandler = (_entries: ResizeObserverEntry[], _observer: ResizeObserver) => {\n restart();\n\n if(typeof props.resizeCallback === 'function'){\n props.resizeCallback(_entries, _observer);\n }\n };\n\n const start = () => {\n startTime = undefined;\n elapsed = undefined;\n previousTimeStamp = undefined;\n animating = true;\n\n if(props.restartOnResize && window.ResizeObserver && observer === undefined){\n observer = new ResizeObserver(observerHandler);\n observer.observe(document.body, { box: 'border-box' });\n }\n else{\n animationId = window.requestAnimationFrame(step);\n }\n };\n\n // --------------- GET INFO ----------------------\n\n /**\n * the time elapsed since the start of the animation (in milliseconds)\n */\n const getElapsedTime = () : number|undefined => {\n return elapsed;\n };\n\n const isAnimating = () => {\n return animating;\n };\n\n const getStartTime = () => {\n return startTime;\n };\n\n const getPercent = () => {\n if(_duration === Infinity || elapsed === undefined) return undefined;\n return elapsed * 100 / _duration;\n };\n\n const getResizeObserver = () => {\n return observer;\n };\n\n const getResult = () : IAnimationResult => {\n return {\n\n // commands --------------\n start,\n stop,\n pause,\n resume,\n restart,\n\n // information -------\n isAnimating,\n getElapsedTime,\n getStartTime,\n getPercent,\n getResizeObserver,\n };\n };\n\n return getResult();\n};\n", "import { setDecimalPlaces } from './format';\n\nexport const getCircleCircumference = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * radius, decimalPlaces);\n};\n\nexport const getEllipseCircumference = (radius1: number, radius2: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(2 * Math.PI * Math.sqrt((radius1 ** 2 + radius2 ** 2) / 2), decimalPlaces);\n};\n\nexport const isAngleInCircleArc = (startAngleDeg: number, endAngleDeg: number, currentDegrees: number) : boolean => {\n\n if(startAngleDeg > endAngleDeg) {\n endAngleDeg += 360;\n }\n\n return currentDegrees >= startAngleDeg && currentDegrees <= endAngleDeg ||\n (currentDegrees + 360) >= startAngleDeg && (currentDegrees + 360) <= endAngleDeg;\n};\n\n/**\n * get the side of a square inscribed in a circle\n */\nexport const getSquareInCircleSide = (radius: number, decimalPlaces = Infinity) => {\n return setDecimalPlaces(radius * 2 / Math.sqrt(2), decimalPlaces);\n};\n", "/**\n * 1 + 2 + ... + n = n * (n + 1) / 2\n */\nexport const naturalNumbersSequenceSum = (n: number) => {\n return n * (n + 1) / 2;\n};\n\n/**\n * n = the number of terms to be added\n * a = the first term in the sequence\n * d = the constant value between terms\n */\nexport const arithmeticSequenceSum = (n: number, a: number, d: number) => {\n return (n / 2) * (2 * a + (n - 1) * d);\n};", "import { setDecimalPlaces } from './format';\n\n// -------------------- CENTRAL TENDENCY ----------------------------\n\n/**\n * Central tendency: Calculate the Average (mean = \u03BC)\n * Sum of all numbers divided by the array length.\n */\nexport const getArithmeticMean = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const sum = data.reduce((acc, val) => acc + val, 0);\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Frequency map: number ---> it's frequency\n */\nexport const getArithmeticMeanFromFrequency = (frequencyMap: Map, decimalPlaces = Infinity) => {\n\n let mean = 0;\n\n for(const [val, frequency] of frequencyMap) {\n mean += val * frequency;\n }\n\n return setDecimalPlaces(mean, decimalPlaces);\n};\n\n/**\n * Central tendency: What is the central number in the sorted array?\n * Good for lists like [3, 3, 3, 3, 3, 3, 100] - 100 here is called \"Outlier\"\n */\nexport const getMedian = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const copy = [...data].sort((num1, num2) => num1 - num2);\n const mid = Math.floor(copy.length / 2);\n\n if(copy.length % 2 === 0) {\n return setDecimalPlaces((copy[mid] + copy[mid - 1]) / 2, decimalPlaces);\n }\n else {\n return setDecimalPlaces(copy[mid], decimalPlaces);\n }\n};\n\n/**\n * Central tendency: What number is most common in the set.\n * If all numbers have the same frequency, there is no mode.\n */\nexport const getMode = (data: number[]) : number[]|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n // Count frequency of each number in the data array.\n const frequencyMap: Map = new Map();\n for (const num of data) {\n frequencyMap.set(num, (frequencyMap.get(num) || 0) + 1);\n }\n\n let maxFrequency = 0;\n let modes: number[] = [];\n\n // Find the maximum frequency\n for (const [num, frequency] of frequencyMap) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency;\n modes = [num];\n }\n else if (frequency === maxFrequency) {\n modes.push(num);\n }\n }\n\n // If all numbers have the same frequency, there is no mode\n if (modes.length === data.length) {\n return undefined;\n }\n\n // Return the mode(s)\n return modes.length === 1 ? [modes[0]] : modes;\n};\n\n/*\nTODO:\n- geometric mean\n- harmonic mean\n */\n\n// -------------------- DISPERSION ----------------------------\n\n/**\n * Dispersion: the average square distance from the mean.\n * Sum of (x - mean)^2 / N\n */\nexport const getVariance1 = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + ((val - mean) ** 2), 0);\n\n return setDecimalPlaces(sum / data.length, decimalPlaces);\n};\n\n/**\n * Another formula of dispersion - the average square distance from the mean.\n * (Sum of x^2) / N - (mean ^ 2)\n */\nexport const getVariance = (data: number[], decimalPlaces = Infinity) : number|undefined => {\n if(!data || data.length <= 0) return undefined;\n\n const mean = getArithmeticMean(data);\n if(mean === undefined) return undefined;\n\n const sum = data.reduce((acc, val) => acc + (val ** 2), 0);\n\n return setDecimalPlaces((sum / data.length) - (mean ** 2), decimalPlaces);\n};\n\n/**\n * \u03C3\n */\nexport const getStandardDeviation = (data: number[], decimalPlaces = Infinity) => {\n const variance = getVariance(data) ?? 0;\n return setDecimalPlaces(Math.sqrt(variance), decimalPlaces);\n};", "import { setDecimalPlaces } from './format';\nimport { getArithmeticMean, getStandardDeviation } from './statistics';\nimport { IMlNormalizeResult, IMlStandardizeResult } from '../types';\n\n// --------------------- NORMALIZE --------------------------------\n\n/**\n * Changes value to be in the range [0, 1].\n */\nexport const mlNormalizeValue = (value: number, min: number, max: number, decimalPlaces = Infinity) : number => {\n const diff = max - min;\n if(diff === 0) return 0;\n return setDecimalPlaces((value - min) / diff, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [0, 1].\n */\nexport const mlNormalizeArray = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n const copy = [...data];\n\n for(let i=0; i {\n const min = Math.min(...data);\n const max = Math.max(...data);\n const _data = mlNormalizeArray(data, min, max, decimalPlaces);\n\n return {\n min: setDecimalPlaces(min, decimalPlaces),\n max: setDecimalPlaces(max, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlNormalizeUnseenData = (data: number[], min: number, max: number, decimalPlaces = Infinity): number[] => {\n return mlNormalizeArray(data, min, max, decimalPlaces);\n};\n\n// --------------------- STANDARDIZE --------------------------------\n\n/**\n * Changes value to be in the range [-1, 1].\n */\nexport const mlStandardizeValue = (value: number, mean: number, stdDev: number, decimalPlaces = Infinity) : number => {\n if(stdDev === 0) return 0;\n return setDecimalPlaces((value - mean) / stdDev, decimalPlaces);\n};\n\n/**\n * Returns a copy of array, where each value will be in the range [-1, 1].\n */\nexport const mlStandardizeArray = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity) : number[] => {\n return [...data].map(value => mlStandardizeValue(value, mean, stdDev, decimalPlaces));\n};\n\nexport const mlStandardizeTestData = (data: number[], decimalPlaces = Infinity): IMlStandardizeResult => {\n const mean = getArithmeticMean(data) ?? 0;\n const stdDev = getStandardDeviation(data);\n const _data = mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n\n return {\n mean: setDecimalPlaces(mean, decimalPlaces),\n stdDev: setDecimalPlaces(stdDev, decimalPlaces),\n data: _data,\n };\n};\n\n/**\n * Alias.\n */\nexport const mlStandardizeUnseenData = (data: number[], mean: number, stdDev: number, decimalPlaces = Infinity): number[] => {\n return mlStandardizeArray(data, mean, stdDev, decimalPlaces);\n};", "/**\n * Sum of 1 to n numbers:\n * (n * (n + 1)) / 2\n */\nexport const naturalNumbersSum1ToN = (n: number): number => {\n return (n / 2) * (n + 1);\n};\n\n/**\n * Sum of m to n numbers.\n */\nexport const naturalNumbersSumMToN = (m: number, n: number): number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AAwB,CAACT,EAAgBJ,EAAgB,MAAmC,CAhEzG,IAAAc,EAiEI,IAAMJ,GAAOI,EAAAC,EAAkBX,CAAI,IAAtB,KAAAU,EAA2B,EAClCH,EAASK,GAAqBZ,CAAI,EAClCG,EAAQK,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa,EAElE,MAAO,CACH,KAAME,EAAiBQ,EAAMV,CAAa,EAC1C,OAAQE,EAAiBS,EAAQX,CAAa,EAC9C,KAAMO,CACV,CACJ,EAKaU,GAA0B,CAACb,EAAgBM,EAAcC,EAAgBX,EAAgB,MAC3FY,GAAmBR,EAAMM,EAAMC,EAAQX,CAAa,EC5ExD,IAAMkB,GAAyBC,GAC1BA,EAAI,GAAMA,EAAI,GAMbC,GAAwB,CAACC,EAAWF,KACrCA,EAAIE,EAAI,IAAMA,EAAIF,GAAK", + "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", "getArithmeticMeanFromFrequency", "getCircleCircumference", "getColorsDelta", "getEllipseCircumference", "getLinearEquationBy2Points", "getMedian", "getMode", "getRandom", "getRandomBoolean", "getRandomGrayscaleHSLColor", "getRandomHSLColor", "getRandomHSLColorWithHue", "getRandomHSLColorWithLightness", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithinRanges", "getRandomHexColor", "getRandomInt", "getRandomItemFromArray", "getRandomRGBColor", "getShiftedHue", "getShiftedLightness", "getShiftedSaturation", "getSquareInCircleSide", "getStandardDeviation", "getV2Angle", "getV2AngleBetween", "getV2AngleInEllipse", "getV3AngleBetween", "getVNAngleBetween", "getVariance", "getVariance1", "guid", "hexToRgb", "hslToHex", "hslToRgb", "identity2", "identity3", "identity4", "identityN", "isAngleBetween", "isAngleInCircleArc", "isClockwise", "isNumber", "isSingularMatrix", "labToRgb", "linearEquation", "linearEquationSystem2", "linearEquationSystem3", "linearEquationSystemN", "lissajousCurve", "m2Adjugate", "m2AppendRow", "m2DeepCopy", "m2Determinant", "m2DivideScalar", "m2Inverse", "m2MulScalar", "m2PrependRow", "m2ReflectionOrigin", "m2ReflectionOriginH", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m2ReflectionYmX", "m2Reset", "m2RotateAroundPointH", "m2Rotation", "m2RotationAroundPointH", "m2RotationH", "m2Scale", "m2ScaleAtPointH", "m2ScaleAtPointHMatrix", "m2ScaleH", "m2ScaleX", "m2ScaleXH", "m2ScaleY", "m2ScaleYH", "m2ShearingX", "m2ShearingY", "m2Sub", "m2Sum", "m2ToCSS", "m2Translation", "m2TranslationH", "m2Transpose", "m2hToCSS", "m2hToCSS3d", "m2x2", "m3Adjugate", "m3AppendRow", "m3DeepCopy", "m3Determinant", "m3DivideScalar", "m3Inverse", "m3MulScalar", "m3PrependRow", "m3ReflectionOrigin", "m3ReflectionOriginH", "m3ReflectionXY", "m3ReflectionXYH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionYZ", "m3ReflectionYZH", "m3Reset", "m3RotationX", "m3RotationXH", "m3RotationY", "m3RotationYH", "m3RotationZ", "m3RotationZH", "m3Scale", "m3ScaleH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m3Sub", "m3Sum", "m3Translation", "m3TranslationH", "m3Transpose", "m3hToCSS3d", "m3x3", "m4x4", "mAdjugate", "mAppendCol", "mAppendRow", "mDeepCopy", "mDelFirstColumn", "mDelFirstRow", "mDelLastColumn", "mDelLastRow", "mDeterminant", "mDivideScalar", "mEqual", "mGetColumn", "mGetFirstColumn", "mGetLastColumn", "mInverse", "mMinor", "mMul", "mMulScalar", "mMulVector", "mNxM", "mPrependCol", "mPrependRow", "mReset", "mSub", "mSum", "mTranspose", "mlNormalizeArray", "mlNormalizeTestData", "mlNormalizeUnseenData", "mlNormalizeValue", "mlStandardizeArray", "mlStandardizeTestData", "mlStandardizeUnseenData", "mlStandardizeValue", "mod", "naturalNumbersSequenceSum", "naturalNumbersSum1ToN", "naturalNumbersSumMToN", "newId", "percentToAngle", "polarToCartesian", "radiansToDegrees", "rectCollide", "rgbToHex", "rgbToHsl", "rgbToLab", "setDecimalPlaces", "setV2Angle", "sineWaveMovement", "stringToNumber", "v2", "v2CubicBezierBBox", "v2CubicBezierCurve", "v2CubicBezierCurveExtrema", "v2CubicBezierCurveNormal", "v2CubicBezierCurveTangent", "v2Distance", "v2DivideScalar", "v2DotProduct", "v2FromPolarCoords", "v2GetNormal", "v2Length", "v2MulScalar", "v2Normalize", "v2QuadraticBezierBBox", "v2QuadraticBezierCurve", "v2QuadraticBezierCurveExtrema", "v2QuadraticBezierCurveNormal", "v2QuadraticBezierCurveTangent", "v2Rotate", "v2RotateH", "v2Scale", "v2SetLength", "v2Sub", "v2Sum", "v3", "v3CrossProduct", "v3CubicBezierCurve", "v3CubicBezierCurveTangent", "v3Distance", "v3DivideScalar", "v3DotProduct", "v3Length", "v3MulScalar", "v3Normalize", "v3QuadraticBezierCurve", "v3QuadraticBezierCurveTangent", "v3RotateX", "v3RotateY", "v3RotateZ", "v3Scale", "v3Sub", "v3Sum", "v4", "vDistance", "vDivideScalar", "vDotProduct", "vEqual", "vLength", "vMulScalar", "vN", "vNormalize", "vSub", "vSum", "__toCommonJS", "setDecimalPlaces", "num", "decimalPlaces", "coefficient", "__pow", "mod", "n", "m", "convertRange", "x", "a", "b", "c", "d", "doRangesOverlap", "isNumber", "value", "polarToCartesian", "center", "radii", "angleInRad", "decimalPlaces", "cx", "cy", "rx", "ry", "setDecimalPlaces", "getV2Angle", "v2", "decimalPlaces", "angle", "setDecimalPlaces", "getV2AngleInEllipse", "radii", "setV2Angle", "newAngleRad", "length", "v2Length", "radiansToDegrees", "radians", "res", "degreesToRadians", "degrees", "getVNAngleBetween", "vector1", "vector2", "unitVector1", "vNormalize", "unitVector2", "dotProduct", "vDotProduct", "getV2AngleBetween", "diff", "vSub", "getV3AngleBetween", "isAngleBetween", "angleDegrees", "startAngleDegrees", "endAngleDegrees", "distance", "getAnglesSub", "distance1", "distance2", "totalDistance", "isClockwise", "angle1Deg", "angle2Deg", "startAngleDeg", "angleDegrees1", "angleDegrees2", "angleDistance", "mod", "getAnglesDistance", "percentToAngle", "percent", "endAngleDeg", "circleStartAngle", "vSum", "vector1", "vector2", "decimalPlaces", "vector", "i", "setDecimalPlaces", "v2Sum", "v3Sum", "vSub", "v2Sub", "v3Sub", "vMulScalar", "v", "scalar", "v2MulScalar", "v2", "v3MulScalar", "v3", "vDivideScalar", "v2DivideScalar", "v3DivideScalar", "vLength", "sum", "v2Length", "v3Length", "v2SetLength", "newLength", "angle", "getV2Angle", "vDistance", "diff", "v2Distance", "v3Distance", "vNormalize", "length", "unitVector", "v2Normalize", "v3Normalize", "vDotProduct", "v2DotProduct", "v3DotProduct", "v3CrossProduct", "defaultValue", "v4", "vN", "N", "v2FromPolarCoords", "distance", "angleRad", "setV2Angle", "vEqual", "v2GetNormal", "sub", "mSum", "matrix1", "matrix2", "decimalPlaces", "matrix", "i", "vSum", "m2Sum", "m3Sum", "mSub", "vSub", "m2Sub", "m3Sub", "mMulScalar", "m", "scalar", "v", "vMulScalar", "m2MulScalar", "m2", "m3MulScalar", "m3", "mDivideScalar", "vDivideScalar", "m2DivideScalar", "m3DivideScalar", "mTranspose", "vectorsCount", "vectorLength", "j", "m2Transpose", "m3Transpose", "mReset", "defaultValue", "res", "size", "vector", "m2Reset", "m3Reset", "m2x2", "m3x3", "m4x4", "mNxM", "N", "M", "vN", "identity2", "identity3", "identity4", "identityN", "mDeepCopy", "m2DeepCopy", "m3DeepCopy", "mAppendCol", "col", "copy", "mPrependCol", "mAppendRow", "row", "m2AppendRow", "m3AppendRow", "mPrependRow", "m2PrependRow", "m3PrependRow", "mDelLastRow", "mDelFirstRow", "mDelLastColumn", "mDelFirstColumn", "mGetFirstColumn", "mGetLastColumn", "mGetColumn", "colIndex", "mMul", "transposed", "vector1", "vector2", "product", "vDotProduct", "mMulVector", "mEqual", "vEqual", "mMinorHelper", "mMinor", "mDeterminant", "m2Determinant", "d", "minor", "param", "m3Determinant", "m2Adjugate", "m3Adjugate", "mAdjugate", "cofactors", "sign", "isSingularMatrix", "m2Inverse", "adj", "m3Inverse", "mInverse", "m2ToCSS", "m", "a", "b", "c", "d", "m2hToCSS", "tx", "ty", "m2hToCSS3d", "m3hToCSS3d", "m2Translation", "position", "decimalPlaces", "setDecimalPlaces", "m3Translation", "m2TranslationH", "m3TranslationH", "m2Rotation", "angleRad", "isClockwise", "cos", "sin", "m2RotationH", "m2RotationAroundPointH", "transformOrigin", "translation", "rotation", "translationBack", "v3MulScalar", "temp1", "mMul", "m2RotateAroundPointH", "mat3h", "mMulVector", "v2Rotate", "vector", "unitVector", "v2Normalize", "v2RotateH", "v3Normalize", "m3RotationX", "m3RotationXH", "v3RotateX", "m3RotationY", "m3RotationYH", "v3RotateY", "m3RotationZ", "m3RotationZH", "v3RotateZ", "m2ScaleAtPointHMatrix", "scaleVector", "scale", "m2ScaleH", "m2ScaleAtPointH", "point", "m2Scale", "v2Scale", "m3Scale", "m3ScaleH", "v3Scale", "m2ScaleX", "m2ScaleXH", "m3ScaleX", "m3ScaleXH", "m3ScaleY", "m3ScaleYH", "m3ScaleZ", "m3ScaleZH", "m2ScaleY", "m2ScaleYH", "m2ReflectionOrigin", "m2ReflectionOriginH", "m3ReflectionOrigin", "m3ReflectionOriginH", "m2ReflectionYmX", "m2ReflectionX", "m2ReflectionXH", "m2ReflectionY", "m2ReflectionYH", "m3ReflectionYZ", "m3ReflectionYZH", "m3ReflectionXZ", "m3ReflectionXZH", "m3ReflectionXY", "m3ReflectionXYH", "m2ShearingY", "factor", "m2ShearingX", "getRandom", "min", "max", "decimalPlaces", "setDecimalPlaces", "getRandomInt", "getRandomBoolean", "getRandomItemFromArray", "array", "randomIndex", "stringToNumber", "value", "defaultNumber", "_a", "res", "dxPolynomial", "x", "polynomial", "decimalPlaces", "res", "part", "coeff", "power", "setDecimalPlaces", "dxV2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "temp1", "temp2", "temp3", "dxV3QuadraticBezierCurve", "dxV2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "dxV3CubicBezierCurve", "dxSin", "dxCos", "dxTan", "__pow", "dxCot", "dxArcSin", "dxArcCos", "dxArcTan", "dxArcCot", "linearEquation", "equation", "decimalPlaces", "a", "b", "diff", "setDecimalPlaces", "linearEquationSystem2", "equation1", "equation2", "equationParams", "inversed", "m2Inverse", "equationResults", "mMulVector", "linearEquationSystem3", "equation3", "m3Inverse", "linearEquationSystemN", "equations", "mDelLastColumn", "mInverse", "mGetLastColumn", "getLinearEquationBy2Points", "point1", "point2", "deltaX", "deltaY", "v2Sub", "x", "y", "m", "formula", "quadraticEquation", "equation", "decimalPlaces", "a", "b", "c", "d", "res", "linearEquation", "isNumber", "diff", "discriminant", "setDecimalPlaces", "t1", "t2", "v2QuadraticBezierCurve", "startControlPoint", "centerControlPoint", "endControlPoint", "decimalPlaces", "temp1", "temp2", "temp3", "setDecimalPlaces", "v3QuadraticBezierCurve", "v2CubicBezierCurve", "center1ControlPoint", "center2ControlPoint", "temp4", "v3CubicBezierCurve", "v2QuadraticBezierCurveTangent", "dxVector", "dxV2QuadraticBezierCurve", "v2Normalize", "v3QuadraticBezierCurveTangent", "dxV3QuadraticBezierCurve", "v3Normalize", "v2CubicBezierCurveTangent", "dxV2CubicBezierCurve", "v3CubicBezierCurveTangent", "dxV3CubicBezierCurve", "v2QuadraticBezierCurveNormal", "tangent", "v2CubicBezierCurveNormal", "v2QuadraticBezierCurveExtrema", "a1", "b1", "res1", "linearEquation", "a2", "b2", "res2", "res", "isNumber", "v2CubicBezierCurveExtrema", "c1", "equation1", "c2", "equation2", "quadraticEquation", "num", "v2QuadraticBezierBBox", "extrema", "minX", "minY", "maxX", "maxY", "percent", "point", "x", "y", "v2CubicBezierBBox", "circleMovement", "center", "angle", "radius", "circleMovementAfterMouse", "mouse", "vector", "v2Sub", "getV2Angle", "convertRange", "ellipseMovement", "radius1", "radius2", "ellipseMovementAfterMouse", "radii", "sineWaveMovement", "x", "amplitude", "frequency", "phase", "y", "lissajousCurve", "width", "height", "t", "k", "n", "m", "p", "getRandomRGBColor", "hslColor", "getRandomHSLColor", "hslToRgb", "getRandomHexColor", "hslToHex", "h", "getRandom", "s", "l", "getRandomHSLColorWithHue", "getRandomHSLColorWithSaturation", "getRandomHSLColorWithLightness", "getRandomGrayscaleHSLColor", "getRandomHSLColorWithinRanges", "hueStart", "hueEnd", "saturationStart", "saturationEnd", "lightStart", "lightEnd", "convertHueToDegrees", "getHue", "r", "g", "b", "min", "max", "diff", "getLuminance", "getSaturation", "rgbToHsl", "rgb", "decimalPlaces", "setDecimalPlaces", "hslToRgbHelper", "helper1", "helper2", "colorHelper", "hsl", "gray", "rHelper", "gHelper", "bHelper", "hue2rgb", "q", "t", "p", "toHex", "hex", "rgbToHex", "hexToRgb", "shorthandRegex", "_hex", "_m", "result", "rgbToLab", "x", "y", "z", "labToRgb", "lab", "getShiftedHue", "color", "shift", "hue", "mod", "getShiftedLightness", "lightness", "getShiftedSaturation", "saturation", "getColorsDelta", "rgbA", "rgbB", "labA", "labB", "deltaL", "deltaA", "deltaB", "c1", "c2", "deltaC", "deltaH", "sc", "sh", "deltaLKlsl", "deltaCkcsc", "deltaHkhsh", "i", "guid", "c", "newId", "rectCollide", "rect1", "rect2", "circleCollide", "circle1", "circle2", "dx", "dy", "getEdges", "poly", "edges", "i", "nextIndex", "mod", "edge", "convexPolygonsCollide", "poly1", "poly2", "normal", "v2GetNormal", "p1Proj", "projectPolygon", "p2Proj", "polygon", "min", "max", "vertex", "projection", "v2DotProduct", "animate", "props", "_duration", "startTime", "animationId", "elapsed", "previousTimeStamp", "animating", "observer", "stop", "restart", "start", "pause", "resume", "step", "timeStamp", "getResult", "observerHandler", "_entries", "_observer", "getElapsedTime", "isAnimating", "getStartTime", "getPercent", "getResizeObserver", "getCircleCircumference", "radius", "decimalPlaces", "setDecimalPlaces", "getEllipseCircumference", "radius1", "radius2", "__pow", "isAngleInCircleArc", "startAngleDeg", "endAngleDeg", "currentDegrees", "getSquareInCircleSide", "naturalNumbersSequenceSum", "n", "arithmeticSequenceSum", "a", "d", "getArithmeticMean", "data", "decimalPlaces", "sum", "acc", "val", "setDecimalPlaces", "getArithmeticMeanFromFrequency", "frequencyMap", "mean", "frequency", "getMedian", "copy", "num1", "num2", "mid", "getMode", "num", "maxFrequency", "modes", "getVariance1", "__pow", "getVariance", "getStandardDeviation", "_a", "variance", "mlNormalizeValue", "value", "min", "max", "decimalPlaces", "diff", "setDecimalPlaces", "mlNormalizeArray", "data", "copy", "mlNormalizeTestData", "_data", "mlNormalizeUnseenData", "mlStandardizeValue", "mean", "stdDev", "mlStandardizeArray", "mlStandardizeTestData", "_a", "getArithmeticMean", "getStandardDeviation", "mlStandardizeUnseenData", "naturalNumbersSum1ToN", "n", "naturalNumbersSumMToN", "m"] } diff --git a/docs/css/styles.1710494664434.css b/docs/css/styles.1710585004234.css similarity index 100% rename from docs/css/styles.1710494664434.css rename to docs/css/styles.1710585004234.css diff --git a/docs/index.html b/docs/index.html index d81aeb5c..96a231cc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,8 +16,8 @@ - - + + @@ -74,6 +74,6 @@

+ \ No newline at end of file diff --git a/docs/js/index.1710494664434.js b/docs/js/index.1710585004234.js similarity index 99% rename from docs/js/index.1710494664434.js rename to docs/js/index.1710585004234.js index 9f859b71..42a2883a 100644 --- a/docs/js/index.1710494664434.js +++ b/docs/js/index.1710585004234.js @@ -1,3 +1,3 @@ (()=>{var et="side-menu",rt=()=>{let t=document.querySelector(".side-menu");if(!t)return;let a=window.location.pathname,e=t.querySelector(`a[href='${a}']`);!e||e.scrollIntoView({block:"center"})},It=()=>{let t=window.localStorage.getItem(et);if(!t)return[];let a=[];try{a=JSON.parse(t)||[]}catch(e){}return a},$t=()=>{let t=document.querySelectorAll(".side-menu [data-collapsible-title]"),a=[];for(let e of t){let r=e.getAttribute("data-id")||"";if(!r)continue;let n=e.getAttribute("data-opened")==="true";a.push({id:r,opened:n})}window.localStorage.setItem(et,JSON.stringify(a))},Ht=()=>{let t=It();if(!!Array.isArray(t))for(let a of t){let e=document.querySelector(`.side-menu [data-id="${a.id}"]`);!e||nt(e,a.opened,!1)}},nt=(t,a,e)=>{var n;t.setAttribute("data-opened",a.toString());let r=t.querySelector("[data-arrow]");!r||(r.classList.toggle("rotate-90",a),(n=t.nextElementSibling)==null||n.classList.toggle("hidden",!a),e&&$t())},it=()=>{let t=document.querySelectorAll(".side-menu [data-collapsible-title]");for(let a of t)a.addEventListener("click",()=>{let e=a.getAttribute("data-opened")==="true";nt(a,!e,!0)});Ht()};var ot=()=>{let t=document.getElementById("mobile-menu-btn");if(!t)return;t.addEventListener("click",r=>{r.stopPropagation(),document.body.classList.toggle("mobile-menu-opened")}),document.body.addEventListener("click",()=>{document.body.classList.remove("mobile-menu-opened")});let a=document.getElementById("side-menu");if(!a)return;a.addEventListener("click",r=>{r.stopPropagation()});let e=document.getElementById("mobile-menu-close-btn");!e||e.addEventListener("click",()=>{document.body.classList.remove("mobile-menu-opened")})};var W="mode",st=()=>{let t=window.localStorage.getItem(W)||"light";document.documentElement.classList.toggle("dark",t==="dark");let a=document.getElementById("move-to-dark-mode-btn"),e=document.getElementById("move-to-light-mode-btn"),r=()=>{document.documentElement.classList.add("dark"),a.classList.add("hidden"),e.classList.remove("hidden"),window.localStorage.setItem(W,"dark")},n=()=>{document.documentElement.classList.remove("dark"),e.classList.add("hidden"),a.classList.remove("hidden"),window.localStorage.setItem(W,"light")};t==="dark"?r():n(),a==null||a.addEventListener("click",r),e==null||e.addEventListener("click",n)};var Nt=Object.defineProperty,lt=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,ct=(t,a,e)=>a in t?Nt(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,q=(t,a)=>{for(var e in a||(a={}))Dt.call(a,e)&&ct(t,e,a[e]);if(lt)for(var e of lt(a))Ft.call(a,e)&&ct(t,e,a[e]);return t},qt=(t,a)=>{for(let e of a){let r=e[1];if(r===void 0)continue;let n=e[0];t.setAttribute(n,r.toString())}},wt=(t,a)=>{for(let e of t){let r=e[1];if(r===void 0)continue;let n=e[0];a[n]=r}},jt=t=>{let a=document.createElement("canvas");qt(a,[["id",t.id],["class",t.classes],["style",t.style],["title",t.title],["tabindex",t.tabindex],["role",t.role],["aria-label",t.ariaLabel]]),t.fallback&&(a.textContent=t.fallback);let e=typeof a.getContext=="function"?a.getContext("2d",t.contextAttributes):null;return a.width=t.width,a.height=t.height,{ctx:e,$canvas:a}},D=(t,a)=>{wt([["lineWidth",t.lineWidth],["strokeStyle",t.strokeStyle],["lineCap",t.lineCap],["lineJoin",t.lineJoin],["miterLimit",t.miterLimit],["lineDashOffset",t.lineDashOffset]],a),t.lineDashSegments&&a.setLineDash(t.lineDashSegments)},J=(t,a)=>{t.fillStyle!==void 0&&(a.fillStyle=t.fillStyle),wt([["shadowOffsetX",t.shadowOffsetX],["shadowOffsetY",t.shadowOffsetY],["shadowBlur",t.shadowBlur],["shadowColor",t.shadowColor]],a)},Bt=(t,a)=>{let{x1:e,y1:r,x2:n,y2:i}=t;a.save(),a.beginPath(),a.moveTo(e,r),a.lineTo(n,i),t.strokeStyle&&(D(t,a),a.stroke()),a.restore()},Ut=(t,a)=>{let{x:e,y:r,w:n,h:i}=t;if(t.clear){a.clearRect(e,r,n,i);return}if(t.radii){a.save(),J(t,a),D(t,a),a.beginPath(),a.roundRect(e,r,n,i,t.radii),t.fillStyle&&a.fill(),t.strokeStyle&&a.stroke(),a.restore();return}a.save(),t.fillStyle&&(J(t,a),a.fillRect(e,r,n,i)),t.strokeStyle&&(D(t,a),a.strokeRect(e,r,n,i)),a.restore()},Vt=(t,a)=>{let{cx:e,cy:r,r:n}=t,i=t.startAngleRad===void 0?0:t.startAngleRad,o=t.endAngleRad===void 0?2*Math.PI:t.endAngleRad;a.save(),a.beginPath(),J(t,a),D(t,a),a.arc(e,r,n,i,o,t.counterclockwise),t.fillStyle&&a.fill(),t.strokeStyle&&(D(t,a),a.stroke()),a.restore()},Wt=Math.pow,at=(t,a=1/0)=>{if(a===1/0)return t;a<0&&(a=0);let e=Wt(10,a);return Math.round(t*e)/e},Qt=(t,a,e=1/0)=>{let r=[];for(let n=0;n{let e=0;for(let r=0;r{let r=Qt(t,a);return Zt(r,e)},$=(t,a,e=1/0)=>at(Math.random()*(a-t)+t,e),Yt=(t,a)=>Math.floor(Math.random()*(a-t+1)+t),Gt=()=>Math.random()<.5,F=t=>{let a=Yt(0,t.length-1);return t[a]},Xt=()=>{let t=Kt();return ta(t)},Kt=()=>{let t=$(1,360),a=$(0,100),e=$(0,100);return[t,a,e]},ta=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 a=t[0]/360,e=t[1]/100,r=t[2]/100,n,i,o;if(e===0)n=i=o=r;else{let l=(u,d,f)=>(f<0&&(f+=1),f>1&&(f-=1),f<.16666666666666666?u+(d-u)*6*f:f<.5?d:f<.6666666666666666?u+(d-u)*(.6666666666666666-f)*6:u),c=r<.5?r*(1+e):r+e-r*e,h=2*r-c;n=l(h,c,a+1/3),i=l(h,c,a),o=l(h,c,a-1/3)}let s=l=>{let c=Math.round(l*255).toString(16);return c.length===1?"0"+c:c};return`#${s(n)}${s(i)}${s(o)}`},aa=t=>{let a=t.duration!==void 0?t.duration:1/0,e,r,n,i,o=!1,s,l=()=>{e=void 0,n=void 0,i=void 0,o=!1,r!==void 0&&window.cancelAnimationFrame(r)},c=()=>{l(),g()},h=()=>{o=!1},u=()=>{o=!0},d=M=>{e===void 0&&(e=M),n=M-e,o&&i!==M&&typeof t.callback=="function"&&t.callback(y()),n<=a?(i=M,r=window.requestAnimationFrame(d)):l()},f=(M,b)=>{c(),typeof t.resizeCallback=="function"&&t.resizeCallback(M,b)},g=()=>{e=void 0,n=void 0,i=void 0,o=!0,t.restartOnResize&&window.ResizeObserver&&s===void 0?(s=new ResizeObserver(f),s.observe(document.body,{box:"border-box"})):r=window.requestAnimationFrame(d)},k=()=>n,A=()=>o,p=()=>e,v=()=>{if(!(a===1/0||n===void 0))return n*100/a},x=()=>s,y=()=>({start:g,stop:l,pause:h,resume:u,restart:c,isAnimating:A,getElapsedTime:k,getStartTime:p,getPercent:v,getResizeObserver:x});return y()},Y=(t,a,e,r)=>`rgba(${t}, ${a}, ${e}, ${r} )`,_t=640,At=768,Ct=1024,Lt=()=>{let t=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),a=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0);return[t,a]},ea=(t,a)=>{let e=Lt()[0];return t.smConnectionSize!==void 0&&e<=_t?t.smConnectionSize*a:t.mdConnectionSize!==void 0&&e<=At?t.mdConnectionSize*a:t.lgConnectionSize!==void 0&&e<=Ct?t.lgConnectionSize*a:t.connectionSize*a},ut=t=>{let a=Lt()[0];return t.smParticlesNumber!==void 0&&a<=_t?t.smParticlesNumber:t.mdParticlesNumber!==void 0&&a<=At?t.mdParticlesNumber:t.lgParticlesNumber!==void 0&&a<=Ct?t.lgParticlesNumber:t.particlesNumber},ra=(t,a)=>{var e;let{particles:r,ctx:n,connectionRgbColor:i}=a,o=(e=t.$placeholder)==null?void 0:e.getBoundingClientRect(),s=(o==null?void 0:o.width)||0,l=ea(t,s);for(let c=0;c{if(a===1/0)return t;a<0&&(a=0);let e=na(10,a);return Math.round(t*e)/e},ia=(t,a=1/0)=>{let e=t*(Math.PI/180);return C(e,a)},G=t=>!isNaN(parseFloat(t))&&isFinite(t),X=(t,a=1/0)=>{let e=t[0],r=t[1],n=t[2]-r;return e===0&&n===0?1/0:e===0?NaN:C(n/e,a)},ht=(t,a=1/0)=>{let e=t[0],r=t[1],n=t[2],i=t[3];if(e===0){let h=X([r,n,i],a);return G(h)?[h]:[]}let o=n-i,s=r*r-4*e*o;if(s<0)return[];if(s===0)return[C(-r/(2*e),a)];let l=2*e,c=Math.sqrt(s);return[C((-r+c)/l,a),C((-r-c)/l,a)]},oa=(t,a,e,r,n=1/0)=>{let i=Math.pow(1-t,2),o=(1-t)*2*t,s=t*t;return[C(i*a[0]+o*e[0]+s*r[0],n),C(i*a[1]+o*e[1]+s*r[1],n)]},sa=(t,a,e,r,n,i=1/0)=>{let o=Math.pow(1-t,3),s=Math.pow(1-t,2)*3*t,l=(1-t)*3*t*t,c=t*t*t;return[C(o*a[0]+s*e[0]+l*r[0]+c*n[0],i),C(o*a[1]+s*e[1]+l*r[1]+c*n[1],i)]},la=(t,a,e,r=1/0)=>{let n=2*t[0]-4*a[0]+2*e[0],i=-2*t[0]+2*a[0],o=X([n,i,0],r),s=2*t[1]-4*a[1]+2*e[1],l=-2*t[1]+2*a[1],c=X([s,l,0],r),h=[];return G(o)&&h.push(o),G(c)&&h.push(c),h},ca=(t,a,e,r,n=1/0)=>{let i=-3*t[0]+9*a[0]-9*e[0]+3*r[0],o=6*t[0]-12*a[0]+6*e[0],s=-3*t[0]+3*a[0],l=[i,o,s,0],c=-3*t[1]+9*a[1]-9*e[1]+3*r[1],h=6*t[1]-12*a[1]+6*e[1],u=-3*t[1]+3*a[1],d=[c,h,u,0],f=ht(l,n).filter(k=>k>=0&&k<=1),g=ht(d,n).filter(k=>k>=0&&k<=1);return[...f,...g].length===2?[...f,...g]:null},ua=(t,a,e,r=1/0)=>{let n=la(t,a,e),i=1/0,o=1/0,s=-1/0,l=-1/0;for(let c of n){let h=oa(c,t,a,e),u=h[0],d=h[1];i=Math.min(i,u),s=Math.max(s,u),o=Math.min(o,d),l=Math.max(l,d)}return i=C(Math.min(i,t[0],e[0]),r),s=C(Math.max(s,t[0],e[0]),r),o=C(Math.min(o,t[1],e[1]),r),l=C(Math.max(l,t[1],e[1]),r),{x:i,y:o,w:Math.abs(s-i),h:Math.abs(l-o),x2:s,y2:l}},ha=(t,a,e,r,n=1/0)=>{let i=ca(t,a,e,r)||[],o=1/0,s=1/0,l=-1/0,c=-1/0;for(let h of i){let u=sa(h,t,a,e,r),d=u[0],f=u[1];o=Math.min(o,d!=null?d:1/0),l=Math.max(l,d!=null?d:-1/0),s=Math.min(s,f!=null?f:1/0),c=Math.max(c,f!=null?f:-1/0)}return o=C(Math.min(o,t[0],r[0]),n),l=C(Math.max(l,t[0],r[0]),n),s=C(Math.min(s,t[1],r[1]),n),c=C(Math.max(c,t[1],r[1]),n),{x:o,y:s,w:Math.abs(l-o),h:Math.abs(c-s),x2:l,y2:c}},ft=new RegExp("^[+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d+)?(?:(?<=\\d)(?:[eE][+-]?\\d+))?"),fa=t=>{let a={tokens:[],errors:[]};if(!t||t.trim()==="")return a;let e=0,r=0,n=0,i=()=>e>=t.length,o=u=>{a.tokens.push({tokenType:u,line:r,col:n})},s=u=>{a.tokens.push({tokenType:"num",value:u,line:r,col:n})},l=u=>{a.errors.push({line:r,col:n,msg:u})},c=()=>i()?!1:ft.test(t.substring(e)),h=()=>{let u=t[e];if(u.charAt(0)===` `||u.charAt(0)==="\r"){e++,n=0,r++;return}if(/\s/.test(u)||u===","){e++,n++;return}if(c()){let d=t.substring(e).match(ft);if(d&&d.length>0){let f=d[0];s(f),e+=f.length,n+=f.length;return}}switch(u){case"M":o("M");break;case"m":o("m");break;case"Z":o("Z");break;case"z":o("z");break;case"L":o("L");break;case"l":o("l");break;case"H":o("H");break;case"h":o("h");break;case"V":o("V");break;case"v":o("v");break;case"C":o("C");break;case"c":o("c");break;case"S":o("S");break;case"s":o("s");break;case"Q":o("Q");break;case"q":o("q");break;case"T":o("T");break;case"t":o("t");break;case"A":o("A");break;case"a":o("a");break;default:{l(`Unexpected character ${u}`);break}}e++,n++};for(;!i();)h();return a},ma=t=>{let a={commands:[],errors:t.errors||[]};if(t.errors.length>0||t.tokens.length===0)return a;let{tokens:e,errors:r}=t,n=(h,u)=>{r.push({line:h==null?void 0:h.line,col:h==null?void 0:h.col,msg:u})};if(e[0].tokenType!=="M"&&e[0].tokenType!=="m")return n(e[0],"A path data segment must begin with a 'moveto' command 'M' or 'm'."),a;let i=0,o=()=>i>=e.length,s=h=>{var u,d;if(!h||h.toLowerCase()!=="a")return!0;let f=(((u=e[i+4])==null?void 0:u.value)||"").toString(),g=(((d=e[i+5])==null?void 0:d.value)||"").toString();return(f==="0"||f==="1")&&(g==="0"||g==="1")},l=(h,u,d)=>{var f;let g=e[i].tokenType,k=[];if(h>0)for(let v=1;v<=h;v++){if(!e[i+v]||e[i+v].tokenType!=="num"){n(e[i],`Expected number(s) after command ${g}.`),i+=h;return}k.push(Number(e[i+v].value))}if(!s(g)){n(e[i],"Arc flags must be 0 or 1."),i+=h+1;return}if(!s(g)){n(e[i],"Arc flags must be 0 or 1."),i+=h+1;return}if(a.commands.push({command:e[i].tokenType,params:k}),i+=h+1,h<=0)return;let A=[];for(;((f=e[i])==null?void 0:f.tokenType)==="num";)A.push(e[i]),i++;if(A.length%h!==0){n(A[A.length-1],"Expected a number.");return}let p=d?u.toLowerCase():u.toUpperCase();for(let v=0;v{let h=e[i],u=h.tokenType.toLowerCase()===h.tokenType;switch(h.tokenType){case"M":case"m":case"L":case"l":{l(2,"L",u);break}case"Z":case"z":{l(0,"L",u);break}case"H":case"h":case"V":case"v":{l(1,h.tokenType,u);break}case"C":case"c":{l(6,h.tokenType,u);break}case"S":case"s":case"Q":case"q":{l(4,h.tokenType,u);break}case"T":case"t":{l(2,h.tokenType,u);break}case"A":case"a":{l(7,h.tokenType,u);break}default:{n(e[i],"Wrong path command."),i++;break}}};for(l(2,"L",e[0].tokenType==="m");!o();)c();return a},da=t=>{let{commands:a}=t;if(a.length<=0)return t;let e=a[0].params[0],r=a[0].params[1],n=e,i=r;a[0].command="M";for(let o=1;o{let{commands:a}=t;if(a.length<=0)return t;a[0].command="M";for(let e=1;e{let a=fa(t);return ma(a)},R=(t,a)=>{let e=2*Math.PI,r=a>0?1:-1;return(e+r*Math.acos(t/Math.sqrt(t*t+a*a)))%e},Q=(t,a,e,r)=>({x:t,y:e,w:Math.abs(r-e),h:Math.abs(a-t),x2:a,y2:r}),ga=(t,a,e,r,n,i,o,s,l)=>{let c,h,u,d;if(e<0&&(e*=-1),r<0&&(r*=-1),e===0||r===0)return c=ts?t:s,u=al?a:l,Q(c,h,u,d);let f=Math.cos(n)*(t-s)/2+Math.sin(n)*(a-l)/2,g=-Math.sin(n)*(t-s)/2+Math.cos(n)*(a-l)/2,k=e*e*r*r-e*e*g*g-r*r*f*f;k/=e*e*g*g+r*r*f*f;let A=0,p=0;if(k<0){let O=e/r;if(k=g*g+f*f/(O*O),k<0)return c=ts?t:s,u=al?a:l,Q(c,h,u,d);r=Math.sqrt(k),e=O*r}else{let O=(i==o?-1:1)*Math.sqrt(k);A=O*e*g/r,p=-O*r*f/e}let v=A*Math.cos(n)-p*Math.sin(n)+(t+s)/2,x=A*Math.sin(n)+p*Math.cos(n)+(a+l)/2,y,M,b,S;if(n===0||n===Math.PI)c=v-e,y=R(-e,0),h=v+e,M=R(e,0),u=x-r,b=R(0,-r),d=x+r,S=R(0,r);else if(n===Math.PI/2||n===3*Math.PI/2)c=v-r,y=R(-r,0),h=v+r,M=R(r,0),u=x-e,b=R(0,-e),d=x+e,S=R(0,e);else{y=-Math.atan(r*Math.tan(n)/e),M=Math.PI-Math.atan(r*Math.tan(n)/e),c=v+e*Math.cos(M)*Math.cos(n)-r*Math.sin(y)*Math.sin(n),h=v+e*Math.cos(M)*Math.cos(n)-r*Math.sin(M)*Math.sin(n),c>h&&([c,h]=[h,c],[y,M]=[M,y]);let O=x+e*Math.cos(y)*Math.sin(n)+r*Math.sin(y)*Math.cos(n);y=R(c-v,O-x),O=x+e*Math.cos(M)*Math.sin(n)+r*Math.sin(M)*Math.cos(n),M=R(h-v,O-x),b=Math.atan(r/(Math.tan(n)*e)),S=Math.atan(r/(Math.tan(n)*e))+Math.PI,u=x+e*Math.cos(b)*Math.sin(n)+r*Math.sin(b)*Math.cos(n),d=x+e*Math.cos(S)*Math.sin(n)+r*Math.sin(S)*Math.cos(n),u>d&&([u,d]=[d,u],[b,S]=[S,b]);let V=v+e*Math.cos(b)*Math.cos(n)-r*Math.sin(b)*Math.sin(n);b=R(V-v,u-x),V=v+e*Math.cos(S)*Math.cos(n)-r*Math.sin(S)*Math.sin(n),S=R(V-v,d-x)}let L=R(t-v,a-x),w=R(s-v,l-x);o||([L,w]=[w,L]);let z=!1;return L>w&&([L,w]=[w,L],z=!0),(!z&&(L>y||wy||wM||wM||wb||wb||wS||wS||w{var e,r,n,i;if(!t||t.trim()==="")return null;let o=ba(t);if(o.errors.length>0)return null;let s=da(o);if(!s||s.commands.length<=0)return null;let l=1/0,c=1/0,h=-1/0,u=-1/0,d=pa(s),f=d.commands[0].params[0],g=d.commands[0].params[1],k=f,A=g;for(let p of d.commands)switch(p.command){case"M":{l=Math.min(l,p.params[0]),c=Math.min(c,p.params[1]),h=Math.max(h,p.params[0]),u=Math.max(u,p.params[1]),k=p.params[0],A=p.params[1];break}case"Z":{f=k,g=A;break}case"L":{l=Math.min(l,p.params[0]),c=Math.min(c,p.params[1]),h=Math.max(h,p.params[0]),u=Math.max(u,p.params[1]),f=p.params[0],g=p.params[1];break}case"C":{let v=[f,g],x=[p.params[0],p.params[1]],y=[p.params[2],p.params[3]],M=[p.params[4],p.params[5]],b=ha(v,x,y,M);l=Math.min(l,b.x),c=Math.min(c,b.y),h=Math.max(h,b.x2),u=Math.max(u,b.y2),f=p.params[4],g=p.params[5];break}case"Q":{let v=[f,g],x=[p.params[0],p.params[1]],y=[p.params[2],p.params[3]],M=ua(v,x,y);l=Math.min(l,M.x),c=Math.min(c,M.y),h=Math.max(h,M.x2),u=Math.max(u,M.y2),f=p.params[2],g=p.params[3];break}case"A":{let v=p.params[0],x=p.params[1],y=p.params[2],M=p.params[3],b=p.params[4],S=p.params[5],L=p.params[6],w=ga(f,g,v,x,ia(y),M===1,b===1,S,L);l=Math.min(l,(e=w==null?void 0:w.x)!=null?e:0),c=Math.min(c,(r=w==null?void 0:w.y)!=null?r:0),h=Math.max(h,(n=w==null?void 0:w.x2)!=null?n:0),u=Math.max(u,(i=w==null?void 0:w.y2)!=null?i:0),f=p.params[5],g=p.params[6];break}}return{x:C(l,a),y:C(c,a),w:C(Math.abs(h-l),a),h:C(Math.abs(u-c),a),x2:C(h,a),y2:C(u,a)}};function j(t){return j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},j(t)}var Ma=/^\s+/,ya=/\s+$/;function m(t,a){if(t=t||"",a=a||{},t instanceof m)return t;if(!(this instanceof m))return new m(t,a);var e=ka(t);this._originalInput=t,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=a.format||e.format,this._gradientType=a.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}m.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),a,e,r,n,i,o;return a=t.r/255,e=t.g/255,r=t.b/255,a<=.03928?n=a/12.92:n=Math.pow((a+.055)/1.055,2.4),e<=.03928?i=e/12.92:i=Math.pow((e+.055)/1.055,2.4),r<=.03928?o=r/12.92:o=Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*o},setAlpha:function(t){return this._a=Rt(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=dt(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=dt(this._r,this._g,this._b),a=Math.round(t.h*360),e=Math.round(t.s*100),r=Math.round(t.v*100);return this._a==1?"hsv("+a+", "+e+"%, "+r+"%)":"hsva("+a+", "+e+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=mt(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=mt(this._r,this._g,this._b),a=Math.round(t.h*360),e=Math.round(t.s*100),r=Math.round(t.l*100);return this._a==1?"hsl("+a+", "+e+"%, "+r+"%)":"hsla("+a+", "+e+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return pt(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return _a(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(_(this._r,255)*100)+"%",g:Math.round(_(this._g,255)*100)+"%",b:Math.round(_(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(_(this._r,255)*100)+"%, "+Math.round(_(this._g,255)*100)+"%, "+Math.round(_(this._b,255)*100)+"%)":"rgba("+Math.round(_(this._r,255)*100)+"%, "+Math.round(_(this._g,255)*100)+"%, "+Math.round(_(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:Ha[pt(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var a="#"+bt(this._r,this._g,this._b,this._a),e=a,r=this._gradientType?"GradientType = 1, ":"";if(t){var n=m(t);e="#"+bt(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+a+",endColorstr="+e+")"},toString:function(t){var a=!!t;t=t||this._format;var e=!1,r=this._a<1&&this._a>=0,n=!a&&r&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(e=this.toRgbString()),t==="prgb"&&(e=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(e=this.toHexString()),t==="hex3"&&(e=this.toHexString(!0)),t==="hex4"&&(e=this.toHex8String(!0)),t==="hex8"&&(e=this.toHex8String()),t==="name"&&(e=this.toName()),t==="hsl"&&(e=this.toHslString()),t==="hsv"&&(e=this.toHsvString()),e||this.toHexString())},clone:function(){return m(this.toString())},_applyModification:function(t,a){var e=t.apply(null,[this].concat([].slice.call(a)));return this._r=e._r,this._g=e._g,this._b=e._b,this.setAlpha(e._a),this},lighten:function(){return this._applyModification(Ra,arguments)},brighten:function(){return this._applyModification(Pa,arguments)},darken:function(){return this._applyModification(Ea,arguments)},desaturate:function(){return this._applyModification(Aa,arguments)},saturate:function(){return this._applyModification(Ca,arguments)},greyscale:function(){return this._applyModification(La,arguments)},spin:function(){return this._applyModification(Ta,arguments)},_applyCombination:function(t,a){return t.apply(null,[this].concat([].slice.call(a)))},analogous:function(){return this._applyCombination(Ia,arguments)},complement:function(){return this._applyCombination(Oa,arguments)},monochromatic:function(){return this._applyCombination($a,arguments)},splitcomplement:function(){return this._applyCombination(za,arguments)},triad:function(){return this._applyCombination(gt,[3])},tetrad:function(){return this._applyCombination(gt,[4])}};m.fromRatio=function(t,a){if(j(t)=="object"){var e={};for(var r in t)t.hasOwnProperty(r)&&(r==="a"?e[r]=t[r]:e[r]=N(t[r]));t=e}return m(t,a)};function ka(t){var a={r:0,g:0,b:0},e=1,r=null,n=null,i=null,o=!1,s=!1;return typeof t=="string"&&(t=qa(t)),j(t)=="object"&&(I(t.r)&&I(t.g)&&I(t.b)?(a=xa(t.r,t.g,t.b),o=!0,s=String(t.r).substr(-1)==="%"?"prgb":"rgb"):I(t.h)&&I(t.s)&&I(t.v)?(r=N(t.s),n=N(t.v),a=wa(t.h,r,n),o=!0,s="hsv"):I(t.h)&&I(t.s)&&I(t.l)&&(r=N(t.s),i=N(t.l),a=Sa(t.h,r,i),o=!0,s="hsl"),t.hasOwnProperty("a")&&(e=t.a)),e=Rt(e),{ok:o,format:t.format||s,r:Math.min(255,Math.max(a.r,0)),g:Math.min(255,Math.max(a.g,0)),b:Math.min(255,Math.max(a.b,0)),a:e}}function xa(t,a,e){return{r:_(t,255)*255,g:_(a,255)*255,b:_(e,255)*255}}function mt(t,a,e){t=_(t,255),a=_(a,255),e=_(e,255);var r=Math.max(t,a,e),n=Math.min(t,a,e),i,o,s=(r+n)/2;if(r==n)i=o=0;else{var l=r-n;switch(o=s>.5?l/(2-r-n):l/(r+n),r){case t:i=(a-e)/l+(a1&&(u-=1),u<1/6?c+(h-c)*6*u:u<1/2?h:u<2/3?c+(h-c)*(2/3-u)*6:c}if(a===0)r=n=i=e;else{var s=e<.5?e*(1+a):e+a-e*a,l=2*e-s;r=o(l,s,t+1/3),n=o(l,s,t),i=o(l,s,t-1/3)}return{r:r*255,g:n*255,b:i*255}}function dt(t,a,e){t=_(t,255),a=_(a,255),e=_(e,255);var r=Math.max(t,a,e),n=Math.min(t,a,e),i,o,s=r,l=r-n;if(o=r===0?0:l/r,r==n)i=0;else{switch(r){case t:i=(a-e)/l+(a>1)+720)%360;--a;)r.h=(r.h+n)%360,i.push(m(r));return i}function $a(t,a){a=a||6;for(var e=m(t).toHsv(),r=e.h,n=e.s,i=e.v,o=[],s=1/a;a--;)o.push(m({h:r,s:n,v:i})),i=(i+s)%1;return o}m.mix=function(t,a,e){e=e===0?0:e||50;var r=m(t).toRgb(),n=m(a).toRgb(),i=e/100,o={r:(n.r-r.r)*i+r.r,g:(n.g-r.g)*i+r.g,b:(n.b-r.b)*i+r.b,a:(n.a-r.a)*i+r.a};return m(o)};m.readability=function(t,a){var e=m(t),r=m(a);return(Math.max(e.getLuminance(),r.getLuminance())+.05)/(Math.min(e.getLuminance(),r.getLuminance())+.05)};m.isReadable=function(t,a,e){var r=m.readability(t,a),n,i;switch(i=!1,n=ja(e),n.level+n.size){case"AAsmall":case"AAAlarge":i=r>=4.5;break;case"AAlarge":i=r>=3;break;case"AAAsmall":i=r>=7;break}return i};m.mostReadable=function(t,a,e){var r=null,n=0,i,o,s,l;e=e||{},o=e.includeFallbackColors,s=e.level,l=e.size;for(var c=0;cn&&(n=i,r=m(a[c]));return m.isReadable(t,r,{level:s,size:l})||!o?r:(e.includeFallbackColors=!1,m.mostReadable(t,["#fff","#000"],e))};var K=m.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Ha=m.hexNames=Na(K);function Na(t){var a={};for(var e in t)t.hasOwnProperty(e)&&(a[t[e]]=e);return a}function Rt(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function _(t,a){Da(t)&&(t="100%");var e=Fa(t);return t=Math.min(a,Math.max(0,parseFloat(t))),e&&(t=parseInt(t*a,10)/100),Math.abs(t-a)<1e-6?1:t%a/parseFloat(a)}function U(t){return Math.min(1,Math.max(0,t))}function P(t){return parseInt(t,16)}function Da(t){return typeof t=="string"&&t.indexOf(".")!=-1&&parseFloat(t)===1}function Fa(t){return typeof t=="string"&&t.indexOf("%")!=-1}function T(t){return t.length==1?"0"+t:""+t}function N(t){return t<=1&&(t=t*100+"%"),t}function Pt(t){return Math.round(parseFloat(t)*255).toString(16)}function vt(t){return P(t)/255}var E=function(){var t="[-\\+]?\\d+%?",a="[-\\+]?\\d*\\.\\d+%?",e="(?:"+a+")|(?:"+t+")",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",n="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+n),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+n),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function I(t){return!!E.CSS_UNIT.exec(t)}function qa(t){t=t.replace(Ma,"").replace(ya,"").toLowerCase();var a=!1;if(K[t])t=K[t],a=!0;else if(t=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=E.rgb.exec(t))?{r:e[1],g:e[2],b:e[3]}:(e=E.rgba.exec(t))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=E.hsl.exec(t))?{h:e[1],s:e[2],l:e[3]}:(e=E.hsla.exec(t))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=E.hsv.exec(t))?{h:e[1],s:e[2],v:e[3]}:(e=E.hsva.exec(t))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=E.hex8.exec(t))?{r:P(e[1]),g:P(e[2]),b:P(e[3]),a:vt(e[4]),format:a?"name":"hex8"}:(e=E.hex6.exec(t))?{r:P(e[1]),g:P(e[2]),b:P(e[3]),format:a?"name":"hex"}:(e=E.hex4.exec(t))?{r:P(e[1]+""+e[1]),g:P(e[2]+""+e[2]),b:P(e[3]+""+e[3]),a:vt(e[4]+""+e[4]),format:a?"name":"hex8"}:(e=E.hex3.exec(t))?{r:P(e[1]+""+e[1]),g:P(e[2]+""+e[2]),b:P(e[3]+""+e[3]),format:a?"name":"hex"}:!1}function ja(t){var a,e;return t=t||{level:"AA",size:"small"},a=(t.level||"AA").toUpperCase(),e=(t.size||"small").toLowerCase(),a!=="AA"&&a!=="AAA"&&(a="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:a,size:e}}var Mt=(t,a)=>{let{$canvas:e}=a,r=[],n,i,o=t.minSize,s=t.maxSize,l=t.minSpeed,c=t.maxSpeed,h=t.maxScale,u=t.minScale;for(let d=0;d0){n=F(t.svgPathData);let p=va(n);p&&(i=[g[0]/p.w,g[1]/p.h])}let k;t.particlesColors&&t.particlesColors.length>0?k=F(t.particlesColors):k=Xt();let A=m(k).toRgb();r.push({center:[$(0,e.width),$(0,e.height)],speed:[$(l,c),$(l,c)],size:g,color:k,rgbaColor:[A.r,A.g,A.b,A.a],svgPathData:n,svgSize:i,angleRad:0,rotateCounterClockwise:Gt(),scale:(u+h)/2,scaleDirection:F([-1,1]),opacity:$(0,1),opacityDirection:F([-1,1])})}return r},Ba=(t,a,e)=>{let{$canvas:r}=e,n=q({},t),[i,o]=t.center,s=[...t.speed];if((i>r.width||i<0)&&(s[0]=-s[0]),(o>r.height||o<0)&&(s[1]=-s[1]),n.speed=s,n.center=[i+n.speed[0],o+n.speed[1]],a.rotate&&(t.rotateCounterClockwise?n.angleRad+=Math.PI/180:n.angleRad-=Math.PI/180),a.scaleInOut){let l=a.scaleStep,c=a.maxScale,h=a.minScale;n.scaleDirection>0?n.scale+=l:n.scale-=l,n.scale>c&&(n.scale=c,n.scaleDirection=-1),n.scale0?n.opacity+=l:n.opacity-=l,n.opacity>1&&(n.scale=1,n.opacityDirection=-1),n.opacity<0&&(n.opacity=0,n.opacityDirection=1)}return n},Ua=(t,a,e)=>{let{ctx:r}=e;if(!a.svgPathData){r.save();let{size:u}=t,d=u[0];a.scaleInOut&&(d*=t.scale);let f=a.fadeInOut?Y(t.rgbaColor[0],t.rgbaColor[1],t.rgbaColor[2],t.opacity):t.color;Vt({cx:t.center[0],cy:t.center[1],r:d,fillStyle:f},r),r.restore();return}let[n,i]=t.size,o=new Path2D(t.svgPathData);r.save();let s=n/2,l=i/2,[c,h]=[t.center[0]-s,t.center[1]-l];r.translate(c,h),t.svgSize&&(r.translate(s,l),r.scale(...t.svgSize),r.translate(-s,-l)),a.rotate&&(r.translate(s,l),r.rotate(t.angleRad),r.translate(-s,-l)),a.scaleInOut&&(r.translate(s,l),r.scale(t.scale,t.scale),r.translate(-s,-l)),a.fadeInOut?r.fillStyle=Y(t.rgbaColor[0],t.rgbaColor[1],t.rgbaColor[2],t.opacity):r.fillStyle=t.color,r.fill(o),r.restore()},Va={particlesNumber:70,lgParticlesNumber:60,mdParticlesNumber:50,smParticlesNumber:30,resizeDebounceTime:1e3,particlesColors:[],minSpeed:-2,maxSpeed:2,minSize:5,maxSize:10,connected:!0,connectionColor:"rgb(70,126,150)",connectionSize:.09,lgConnectionSize:.15,mdConnectionSize:.2,smConnectionSize:.2,maxScale:2,minScale:.5,scaleStep:.01,opacityStep:.001},Wa=(t,a)=>a?q(q({},t),a):q({},t);function Qa(t){var a=typeof t;return t!=null&&(a=="object"||a=="function")}var tt=Qa,Za=typeof global=="object"&&global&&global.Object===Object&&global,Ja=Za,Ya=typeof self=="object"&&self&&self.Object===Object&&self,Ga=Ja||Ya||Function("return this")(),Et=Ga,Xa=function(){return Et.Date.now()},Z=Xa,Ka=/\s/;function te(t){for(var a=t.length;a--&&Ka.test(t.charAt(a)););return a}var ae=te,ee=/^\s+/;function re(t){return t&&t.slice(0,ae(t)+1).replace(ee,"")}var ne=re,ie=Et.Symbol,B=ie,Tt=Object.prototype,oe=Tt.hasOwnProperty,se=Tt.toString,H=B?B.toStringTag:void 0;function le(t){var a=oe.call(t,H),e=t[H];try{t[H]=void 0;var r=!0}catch(i){}var n=se.call(t);return r&&(a?t[H]=e:delete t[H]),n}var ce=le,ue=Object.prototype,he=ue.toString;function fe(t){return he.call(t)}var me=fe,de="[object Null]",pe="[object Undefined]",yt=B?B.toStringTag:void 0;function be(t){return t==null?t===void 0?pe:de:yt&&yt in Object(t)?ce(t):me(t)}var ge=be;function ve(t){return t!=null&&typeof t=="object"}var Me=ve,ye="[object Symbol]";function ke(t){return typeof t=="symbol"||Me(t)&&ge(t)==ye}var xe=ke,kt=0/0,Se=/^[-+]0x[0-9a-f]+$/i,we=/^0b[01]+$/i,_e=/^0o[0-7]+$/i,Ae=parseInt;function Ce(t){if(typeof t=="number")return t;if(xe(t))return kt;if(tt(t)){var a=typeof t.valueOf=="function"?t.valueOf():t;t=tt(a)?a+"":a}if(typeof t!="string")return t===0?t:+t;t=ne(t);var e=we.test(t);return e||_e.test(t)?Ae(t.slice(2),e?2:8):Se.test(t)?kt:+t}var xt=Ce,Le="Expected a function",Re=Math.max,Pe=Math.min;function Ee(t,a,e){var r,n,i,o,s,l,c=0,h=!1,u=!1,d=!0;if(typeof t!="function")throw new TypeError(Le);a=xt(a)||0,tt(e)&&(h=!!e.leading,u="maxWait"in e,i=u?Re(xt(e.maxWait)||0,a):i,d="trailing"in e?!!e.trailing:d);function f(b){var S=r,L=n;return r=n=void 0,c=b,o=t.apply(L,S),o}function g(b){return c=b,s=setTimeout(p,a),h?f(b):o}function k(b){var S=b-l,L=b-c,w=a-S;return u?Pe(w,i-L):w}function A(b){var S=b-l,L=b-c;return l===void 0||S>=a||S<0||u&&L>=i}function p(){var b=Z();if(A(b))return v(b);s=setTimeout(p,k(b))}function v(b){return s=void 0,d&&r?f(b):(r=n=void 0,o)}function x(){s!==void 0&&clearTimeout(s),c=0,r=l=n=s=void 0}function y(){return s===void 0?o:v(Z())}function M(){var b=Z(),S=A(b);if(r=arguments,n=this,l=b,S){if(s===void 0)return g(l);if(u)return clearTimeout(s),s=setTimeout(p,a),f(l)}return s===void 0&&(s=setTimeout(p,a)),o}return M.cancel=x,M.flush=y,M}var Te=Ee,St=(t,a)=>{let{$canvas:e,ctx:r}=a,n={x:0,y:0,w:e.width,h:e.height};t.canvasColor?n.fillStyle=t.canvasColor:n.clear=!0,Ut(n,r),t.connected&&ra(t,a);for(let i=0;i{let a=Wa(Va,t);if(!a.$placeholder)return;let e=a.$placeholder.getBoundingClientRect(),r={width:e.width,height:e.height},{ctx:n,$canvas:i}=jt(r);if(!n)return;a.$placeholder.append(i);let o=m(a.connectionColor).toRgb(),s={connectionRgbColor:[o.r,o.g,o.b,o.a],particles:[],ctx:n,$canvas:i,vpParticlesNumber:ut(a)};s.particles=Mt(a,s);let l=Te(()=>{let c=ut(a);s.vpParticlesNumber!==c&&(s.vpParticlesNumber=c,s.particles=Mt(a,s))},a.resizeDebounceTime);return aa({callback:()=>{n&&St(a,s)},restartOnResize:!0,resizeCallback:()=>{if(!a.$placeholder)return;let c=a.$placeholder.getBoundingClientRect();i.width=c.width,i.height=c.height,St(a,s),l()}}).start(),i};window.particles=Ot;var zt=Ot;var Oe=()=>{let t=document.getElementById("hp-animation");!t||zt({$placeholder:t,particlesNumber:100,minSize:10,maxSize:30,particlesColors:["#366d8c","#368c8c","#fffc00","#92fae7","#5daed2","#366d8c"],connectionColor:"#7fb2b7",svgPathData:["m14.5 21.75-8.52289 4.48075 1.62773-9.49038-6.89516-6.72112 9.52888-1.38462L14.5 0l4.26144 8.63463 9.52888 1.38462-6.89516 6.72112 1.62773 9.49038z","M14.5 21.75 4.24695 24.75305 7.25 14.5 4.24695 4.24695 14.5 7.25l10.25305-3.00305L21.75 14.5l3.00305 10.25305z","m14.5 21.75-5.54891 6.14625.42239-8.26973-8.26973.42239L7.25 14.5 1.10375 8.95109l8.26973.42239-.42239-8.26973L14.5 7.25l5.54891-6.14625-.42239 8.26973 8.26973-.42239L21.75 14.5l6.14625 5.54891-8.26973-.42239.42239 8.26973z"],rotate:!0,scaleInOut:!0,maxScale:1.2,minScale:.7,scaleStep:.005})},ze=()=>{if(document.getElementById("special-page")){Oe();return}ot(),rt(),it(),st()};document.addEventListener("DOMContentLoaded",()=>{ze()});})(); -//# sourceMappingURL=index.1710494664434.js.map +//# sourceMappingURL=index.1710585004234.js.map diff --git a/docs/js/index.1710494664434.js.map b/docs/js/index.1710585004234.js.map similarity index 100% rename from docs/js/index.1710494664434.js.map rename to docs/js/index.1710585004234.js.map diff --git a/docs/pages/Check-if-value-is-number.html b/docs/pages/Check-if-value-is-number.html index 9f0b3627..b032ce39 100644 --- a/docs/pages/Check-if-value-is-number.html +++ b/docs/pages/Check-if-value-is-number.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -288,6 +288,6 @@ - + \ No newline at end of file diff --git a/docs/pages/adjugate-matrix.html b/docs/pages/adjugate-matrix.html index 0f762344..6db33577 100644 --- a/docs/pages/adjugate-matrix.html +++ b/docs/pages/adjugate-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -332,6 +332,6 @@ - + \ No newline at end of file diff --git a/docs/pages/angle-between-vectors.html b/docs/pages/angle-between-vectors.html index c6c29aed..50b6d91f 100644 --- a/docs/pages/angle-between-vectors.html +++ b/docs/pages/angle-between-vectors.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -299,6 +299,6 @@ - + \ No newline at end of file diff --git a/docs/pages/angles-distance.html b/docs/pages/angles-distance.html index b8f7eebb..d1b8b4f8 100644 --- a/docs/pages/angles-distance.html +++ b/docs/pages/angles-distance.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -306,6 +306,6 @@

Angles Subtraction (Angular Distance)

- + \ No newline at end of file diff --git a/docs/pages/animation.html b/docs/pages/animation.html index cc3cca3b..294cb822 100644 --- a/docs/pages/animation.html +++ b/docs/pages/animation.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -333,6 +333,6 @@ - + \ No newline at end of file diff --git a/docs/pages/append-or-prepend-column.html b/docs/pages/append-or-prepend-column.html index 29ceaeac..03084370 100644 --- a/docs/pages/append-or-prepend-column.html +++ b/docs/pages/append-or-prepend-column.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -298,6 +298,6 @@ - + \ No newline at end of file diff --git a/docs/pages/append-or-prepend-row.html b/docs/pages/append-or-prepend-row.html index 754a09bc..fdd963a4 100644 --- a/docs/pages/append-or-prepend-row.html +++ b/docs/pages/append-or-prepend-row.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -347,6 +347,6 @@ - + \ No newline at end of file diff --git a/docs/pages/arithmetic-sequence-sum.html b/docs/pages/arithmetic-sequence-sum.html index cb54b472..d35072b9 100644 --- a/docs/pages/arithmetic-sequence-sum.html +++ b/docs/pages/arithmetic-sequence-sum.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -290,6 +290,6 @@ - + \ No newline at end of file diff --git a/docs/pages/bezier-curves.html b/docs/pages/bezier-curves.html index d07c6cd1..0d3ed632 100644 --- a/docs/pages/bezier-curves.html +++ b/docs/pages/bezier-curves.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -343,6 +343,6 @@ - + \ No newline at end of file diff --git a/docs/pages/bounding-box.html b/docs/pages/bounding-box.html index 00f9a523..d0c4126c 100644 --- a/docs/pages/bounding-box.html +++ b/docs/pages/bounding-box.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -316,6 +316,6 @@ - + \ No newline at end of file diff --git a/docs/pages/browser-usage.html b/docs/pages/browser-usage.html index 2a3cdf7c..ec3d1fd5 100644 --- a/docs/pages/browser-usage.html +++ b/docs/pages/browser-usage.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -289,6 +289,6 @@ - + \ No newline at end of file diff --git a/docs/pages/check-if-ranges-overlap.html b/docs/pages/check-if-ranges-overlap.html index 177ede41..36909b01 100644 --- a/docs/pages/check-if-ranges-overlap.html +++ b/docs/pages/check-if-ranges-overlap.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -284,6 +284,6 @@ - + \ No newline at end of file diff --git a/docs/pages/circle-movement.html b/docs/pages/circle-movement.html index 6507e151..361bf7d0 100644 --- a/docs/pages/circle-movement.html +++ b/docs/pages/circle-movement.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -293,6 +293,6 @@

Circle movement after mouse

- + \ No newline at end of file diff --git a/docs/pages/circles-collision.html b/docs/pages/circles-collision.html index da36d7c2..73838a92 100644 --- a/docs/pages/circles-collision.html +++ b/docs/pages/circles-collision.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -290,6 +290,6 @@ - + \ No newline at end of file diff --git a/docs/pages/circumference.html b/docs/pages/circumference.html index 24253c96..49f3cd70 100644 --- a/docs/pages/circumference.html +++ b/docs/pages/circumference.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -292,6 +292,6 @@ - + \ No newline at end of file diff --git a/docs/pages/color.html b/docs/pages/color.html index 2b2ea683..55a4566c 100644 --- a/docs/pages/color.html +++ b/docs/pages/color.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -288,6 +288,6 @@ - + \ No newline at end of file diff --git a/docs/pages/convert-colors.html b/docs/pages/convert-colors.html index 8ec03983..3536286a 100644 --- a/docs/pages/convert-colors.html +++ b/docs/pages/convert-colors.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -306,6 +306,6 @@ - + \ No newline at end of file diff --git a/docs/pages/convert-range.html b/docs/pages/convert-range.html index 14e3ea25..738cb5d9 100644 --- a/docs/pages/convert-range.html +++ b/docs/pages/convert-range.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -282,6 +282,6 @@ - + \ No newline at end of file diff --git a/docs/pages/convert-string-to-number.html b/docs/pages/convert-string-to-number.html index afa963de..6cd04ed8 100644 --- a/docs/pages/convert-string-to-number.html +++ b/docs/pages/convert-string-to-number.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -284,6 +284,6 @@ - + \ No newline at end of file diff --git a/docs/pages/convex-polygons-collision.html b/docs/pages/convex-polygons-collision.html index e1c4bf55..84de5a7b 100644 --- a/docs/pages/convex-polygons-collision.html +++ b/docs/pages/convex-polygons-collision.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -286,6 +286,6 @@ - + \ No newline at end of file diff --git a/docs/pages/cross-product.html b/docs/pages/cross-product.html index d34d0104..5769ac59 100644 --- a/docs/pages/cross-product.html +++ b/docs/pages/cross-product.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -287,6 +287,6 @@ - + \ No newline at end of file diff --git a/docs/pages/degrees-and-radians.html b/docs/pages/degrees-and-radians.html index 16b05db8..dee30942 100644 --- a/docs/pages/degrees-and-radians.html +++ b/docs/pages/degrees-and-radians.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -288,6 +288,6 @@

Radians to degrees

- + \ No newline at end of file diff --git a/docs/pages/distance-between-vectors.html b/docs/pages/distance-between-vectors.html index 98b69aab..3913d9a3 100644 --- a/docs/pages/distance-between-vectors.html +++ b/docs/pages/distance-between-vectors.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -295,6 +295,6 @@ - + \ No newline at end of file diff --git a/docs/pages/divide-by-scalar.html b/docs/pages/divide-by-scalar.html index dc8382a1..400a6321 100644 --- a/docs/pages/divide-by-scalar.html +++ b/docs/pages/divide-by-scalar.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -351,6 +351,6 @@ - + \ No newline at end of file diff --git a/docs/pages/divide-vector-by-scalar.html b/docs/pages/divide-vector-by-scalar.html index 7bbce3fa..f82a3e93 100644 --- a/docs/pages/divide-vector-by-scalar.html +++ b/docs/pages/divide-vector-by-scalar.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -296,6 +296,6 @@ - + \ No newline at end of file diff --git a/docs/pages/dot-product.html b/docs/pages/dot-product.html index 96eb4a68..3ebcd475 100644 --- a/docs/pages/dot-product.html +++ b/docs/pages/dot-product.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -291,6 +291,6 @@ - + \ No newline at end of file diff --git a/docs/pages/ellipse-movement.html b/docs/pages/ellipse-movement.html index 7ed1110e..b7cde41c 100644 --- a/docs/pages/ellipse-movement.html +++ b/docs/pages/ellipse-movement.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -293,6 +293,6 @@

Ellipse movement after mouse

- + \ No newline at end of file diff --git a/docs/pages/extrema.html b/docs/pages/extrema.html index aa082423..5b8116a4 100644 --- a/docs/pages/extrema.html +++ b/docs/pages/extrema.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -307,6 +307,6 @@ - + \ No newline at end of file diff --git a/docs/pages/general-case.html b/docs/pages/general-case.html index 4218177c..5357624d 100644 --- a/docs/pages/general-case.html +++ b/docs/pages/general-case.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -286,6 +286,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-animation-data.html b/docs/pages/get-animation-data.html index 6b5f320e..31f63d7d 100644 --- a/docs/pages/get-animation-data.html +++ b/docs/pages/get-animation-data.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -290,6 +290,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-column.html b/docs/pages/get-column.html index d96410d6..6254eb6c 100644 --- a/docs/pages/get-column.html +++ b/docs/pages/get-column.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -289,6 +289,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-linear-equation-by-2-points.html b/docs/pages/get-linear-equation-by-2-points.html index cc11c8a6..d9e3c9f5 100644 --- a/docs/pages/get-linear-equation-by-2-points.html +++ b/docs/pages/get-linear-equation-by-2-points.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -326,6 +326,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-matrix-minor.html b/docs/pages/get-matrix-minor.html index f374a1bf..8bfee0e2 100644 --- a/docs/pages/get-matrix-minor.html +++ b/docs/pages/get-matrix-minor.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -288,6 +288,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-normal.html b/docs/pages/get-normal.html index 930dd9e8..7b045a72 100644 --- a/docs/pages/get-normal.html +++ b/docs/pages/get-normal.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -284,6 +284,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-point-on-cubic-bezier-curve.html b/docs/pages/get-point-on-cubic-bezier-curve.html index e8c87132..be1b00f4 100644 --- a/docs/pages/get-point-on-cubic-bezier-curve.html +++ b/docs/pages/get-point-on-cubic-bezier-curve.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -340,6 +340,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-point-on-quadratic-bezier-curve.html b/docs/pages/get-point-on-quadratic-bezier-curve.html index d666dace..4ec0f2a6 100644 --- a/docs/pages/get-point-on-quadratic-bezier-curve.html +++ b/docs/pages/get-point-on-quadratic-bezier-curve.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -334,6 +334,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-random-boolean.html b/docs/pages/get-random-boolean.html index 1fbb2c29..50e8437b 100644 --- a/docs/pages/get-random-boolean.html +++ b/docs/pages/get-random-boolean.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -280,6 +280,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-random-integer.html b/docs/pages/get-random-integer.html index 4aef7009..7322c902 100644 --- a/docs/pages/get-random-integer.html +++ b/docs/pages/get-random-integer.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -281,6 +281,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-random-item-from-array.html b/docs/pages/get-random-item-from-array.html index 85cf08fd..a1d3f31f 100644 --- a/docs/pages/get-random-item-from-array.html +++ b/docs/pages/get-random-item-from-array.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -282,6 +282,6 @@ - + \ No newline at end of file diff --git a/docs/pages/get-random-number-in-range.html b/docs/pages/get-random-number-in-range.html index 238c2f26..f97c4e62 100644 --- a/docs/pages/get-random-number-in-range.html +++ b/docs/pages/get-random-number-in-range.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -282,6 +282,6 @@ - + \ No newline at end of file diff --git a/docs/pages/inverse-matrix.html b/docs/pages/inverse-matrix.html index 10c6ffe1..0dbe8f97 100644 --- a/docs/pages/inverse-matrix.html +++ b/docs/pages/inverse-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -329,6 +329,6 @@ - + \ No newline at end of file diff --git a/docs/pages/is-angle-between.html b/docs/pages/is-angle-between.html index 176e2e1c..d6f5b730 100644 --- a/docs/pages/is-angle-between.html +++ b/docs/pages/is-angle-between.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -282,6 +282,6 @@ - + \ No newline at end of file diff --git a/docs/pages/is-angle-in-circle-arc.html b/docs/pages/is-angle-in-circle-arc.html index 53d77f14..3ee6f8a5 100644 --- a/docs/pages/is-angle-in-circle-arc.html +++ b/docs/pages/is-angle-in-circle-arc.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -292,6 +292,6 @@ - + \ No newline at end of file diff --git a/docs/pages/is-clockwise.html b/docs/pages/is-clockwise.html index e7f3a8a2..8c66273a 100644 --- a/docs/pages/is-clockwise.html +++ b/docs/pages/is-clockwise.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -290,6 +290,6 @@ - + \ No newline at end of file diff --git a/docs/pages/lerp.html b/docs/pages/lerp.html index 62e68720..6f95d332 100644 --- a/docs/pages/lerp.html +++ b/docs/pages/lerp.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -361,6 +361,6 @@ - + \ No newline at end of file diff --git a/docs/pages/linear-equation.html b/docs/pages/linear-equation.html index faa2466d..6ca402d0 100644 --- a/docs/pages/linear-equation.html +++ b/docs/pages/linear-equation.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -284,6 +284,6 @@ - + \ No newline at end of file diff --git a/docs/pages/lissajous-curve.html b/docs/pages/lissajous-curve.html index 7c4f454a..2583ca2f 100644 --- a/docs/pages/lissajous-curve.html +++ b/docs/pages/lissajous-curve.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -305,6 +305,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-deep-copy.html b/docs/pages/matrix-deep-copy.html index e1761ea8..297cee1f 100644 --- a/docs/pages/matrix-deep-copy.html +++ b/docs/pages/matrix-deep-copy.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -299,6 +299,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-determinant.html b/docs/pages/matrix-determinant.html index 069eb22d..d67eb8e0 100644 --- a/docs/pages/matrix-determinant.html +++ b/docs/pages/matrix-determinant.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -308,6 +308,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-equality.html b/docs/pages/matrix-equality.html index 2795c480..0468a9d7 100644 --- a/docs/pages/matrix-equality.html +++ b/docs/pages/matrix-equality.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -299,6 +299,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-initialization.html b/docs/pages/matrix-initialization.html index 1100c8a7..5d9b0ed2 100644 --- a/docs/pages/matrix-initialization.html +++ b/docs/pages/matrix-initialization.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -380,6 +380,6 @@

Identity Matrix

- + \ No newline at end of file diff --git a/docs/pages/matrix-multiplication.html b/docs/pages/matrix-multiplication.html index 3791c59d..f4754cdd 100644 --- a/docs/pages/matrix-multiplication.html +++ b/docs/pages/matrix-multiplication.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -319,6 +319,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-singularity.html b/docs/pages/matrix-singularity.html index 1b342d46..75ab5233 100644 --- a/docs/pages/matrix-singularity.html +++ b/docs/pages/matrix-singularity.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -294,6 +294,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-subtraction.html b/docs/pages/matrix-subtraction.html index 4f4382d3..45a0c3fc 100644 --- a/docs/pages/matrix-subtraction.html +++ b/docs/pages/matrix-subtraction.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -338,6 +338,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-sum.html b/docs/pages/matrix-sum.html index 0f7d103f..2c038765 100644 --- a/docs/pages/matrix-sum.html +++ b/docs/pages/matrix-sum.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -338,6 +338,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-to-CSS-transform.html b/docs/pages/matrix-to-CSS-transform.html index b8542d28..f159259f 100644 --- a/docs/pages/matrix-to-CSS-transform.html +++ b/docs/pages/matrix-to-CSS-transform.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -330,6 +330,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix-transposition.html b/docs/pages/matrix-transposition.html index bc16fa4a..3a1d9494 100644 --- a/docs/pages/matrix-transposition.html +++ b/docs/pages/matrix-transposition.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -326,6 +326,6 @@ - + \ No newline at end of file diff --git a/docs/pages/matrix.html b/docs/pages/matrix.html index d8e65a27..33c0a6d2 100644 --- a/docs/pages/matrix.html +++ b/docs/pages/matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -357,6 +357,6 @@ - + \ No newline at end of file diff --git a/docs/pages/modulo.html b/docs/pages/modulo.html index a09f7ca0..31f9651f 100644 --- a/docs/pages/modulo.html +++ b/docs/pages/modulo.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -282,6 +282,6 @@ - + \ No newline at end of file diff --git a/docs/pages/multiply-by-scalar.html b/docs/pages/multiply-by-scalar.html index af252368..0d6ac296 100644 --- a/docs/pages/multiply-by-scalar.html +++ b/docs/pages/multiply-by-scalar.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -336,6 +336,6 @@ - + \ No newline at end of file diff --git a/docs/pages/multiply-matrix-by-vector.html b/docs/pages/multiply-matrix-by-vector.html index 1e01f541..099184a2 100644 --- a/docs/pages/multiply-matrix-by-vector.html +++ b/docs/pages/multiply-matrix-by-vector.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -288,6 +288,6 @@ - + \ No newline at end of file diff --git a/docs/pages/multiply-vector-by-scalar.html b/docs/pages/multiply-vector-by-scalar.html index e6d47e88..d6996523 100644 --- a/docs/pages/multiply-vector-by-scalar.html +++ b/docs/pages/multiply-vector-by-scalar.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -296,6 +296,6 @@ - + \ No newline at end of file diff --git a/docs/pages/natural-numbers-sequence-sum.html b/docs/pages/natural-numbers-sequence-sum.html index 66c00f15..9f936ff8 100644 --- a/docs/pages/natural-numbers-sequence-sum.html +++ b/docs/pages/natural-numbers-sequence-sum.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -280,6 +280,6 @@ - + \ No newline at end of file diff --git a/docs/pages/nodejs-usage.html b/docs/pages/nodejs-usage.html index 05d6265d..8ff5ef45 100644 --- a/docs/pages/nodejs-usage.html +++ b/docs/pages/nodejs-usage.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -286,6 +286,6 @@ - + \ No newline at end of file diff --git a/docs/pages/normal.html b/docs/pages/normal.html index d38de630..de4ff66a 100644 --- a/docs/pages/normal.html +++ b/docs/pages/normal.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -311,6 +311,6 @@ - + \ No newline at end of file diff --git a/docs/pages/normalize-vector.html b/docs/pages/normalize-vector.html index cb787415..44fc06e7 100644 --- a/docs/pages/normalize-vector.html +++ b/docs/pages/normalize-vector.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -291,6 +291,6 @@ - + \ No newline at end of file diff --git a/docs/pages/percent-to-angle.html b/docs/pages/percent-to-angle.html index 9263e97f..a38cf0fb 100644 --- a/docs/pages/percent-to-angle.html +++ b/docs/pages/percent-to-angle.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -291,6 +291,6 @@ - + \ No newline at end of file diff --git a/docs/pages/polar-to-cartesian.html b/docs/pages/polar-to-cartesian.html index 91eaa629..92d5af23 100644 --- a/docs/pages/polar-to-cartesian.html +++ b/docs/pages/polar-to-cartesian.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -285,6 +285,6 @@ - + \ No newline at end of file diff --git a/docs/pages/polynomial.html b/docs/pages/polynomial.html index f7483cbf..4feebbd7 100644 --- a/docs/pages/polynomial.html +++ b/docs/pages/polynomial.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -289,6 +289,6 @@ - + \ No newline at end of file diff --git a/docs/pages/quadratic-equation.html b/docs/pages/quadratic-equation.html index 7aa2ec01..07b75520 100644 --- a/docs/pages/quadratic-equation.html +++ b/docs/pages/quadratic-equation.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -306,6 +306,6 @@ - + \ No newline at end of file diff --git a/docs/pages/random-color.html b/docs/pages/random-color.html index 3e9a26e0..9f5d5ab9 100644 --- a/docs/pages/random-color.html +++ b/docs/pages/random-color.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -312,6 +312,6 @@ - + \ No newline at end of file diff --git a/docs/pages/random-id-or-GUID.html b/docs/pages/random-id-or-GUID.html index de397519..272134fc 100644 --- a/docs/pages/random-id-or-GUID.html +++ b/docs/pages/random-id-or-GUID.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -281,6 +281,6 @@ - + \ No newline at end of file diff --git a/docs/pages/rectangles-collision.html b/docs/pages/rectangles-collision.html index f60721a0..5ecddde5 100644 --- a/docs/pages/rectangles-collision.html +++ b/docs/pages/rectangles-collision.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -291,6 +291,6 @@ - + \ No newline at end of file diff --git a/docs/pages/reflection-matrix.html b/docs/pages/reflection-matrix.html index 0d9a918f..5280ecf1 100644 --- a/docs/pages/reflection-matrix.html +++ b/docs/pages/reflection-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -454,6 +454,6 @@ - + \ No newline at end of file diff --git a/docs/pages/remove-row-or-column.html b/docs/pages/remove-row-or-column.html index c41446d1..acdf6703 100644 --- a/docs/pages/remove-row-or-column.html +++ b/docs/pages/remove-row-or-column.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -335,6 +335,6 @@ - + \ No newline at end of file diff --git a/docs/pages/reset-matrix.html b/docs/pages/reset-matrix.html index 8d39d337..ac6607b5 100644 --- a/docs/pages/reset-matrix.html +++ b/docs/pages/reset-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -365,6 +365,6 @@ - + \ No newline at end of file diff --git a/docs/pages/rotate-around-point.html b/docs/pages/rotate-around-point.html index 2553377f..680cd379 100644 --- a/docs/pages/rotate-around-point.html +++ b/docs/pages/rotate-around-point.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -303,6 +303,6 @@ - + \ No newline at end of file diff --git a/docs/pages/rotation-matrix.html b/docs/pages/rotation-matrix.html index 5b862fbb..86f520d1 100644 --- a/docs/pages/rotation-matrix.html +++ b/docs/pages/rotation-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -387,6 +387,6 @@ - + \ No newline at end of file diff --git a/docs/pages/scale-and-stretch-matrix.html b/docs/pages/scale-and-stretch-matrix.html index 1c8fc78d..6be6a690 100644 --- a/docs/pages/scale-and-stretch-matrix.html +++ b/docs/pages/scale-and-stretch-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -436,6 +436,6 @@ - + \ No newline at end of file diff --git a/docs/pages/scale-around-point.html b/docs/pages/scale-around-point.html index 5e5c89be..126a772e 100644 --- a/docs/pages/scale-around-point.html +++ b/docs/pages/scale-around-point.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -299,6 +299,6 @@ - + \ No newline at end of file diff --git a/docs/pages/series.html b/docs/pages/series.html new file mode 100644 index 00000000..b6067e9c --- /dev/null +++ b/docs/pages/series.html @@ -0,0 +1,275 @@ + + + + mzMath Documentation + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ + + + + + + mzMath on GitHub + +
+
+
+ +
+
+ +
+
+ + + + +
+ Main + + + + + +
+ Vectors + + + + + +
+ Matrix + + + + + +
+ Matrix Manipulation + + + + + +
+ Transformation Matrices + + + + + +
+ Angles + + + + + +
+ Random + + + + + +
+ Bezier Curve + + + + + +
+ Equations + + + + + +
+ Path Movement + + + + + +
+ Color + + + + + +
+ Linear Interpolation + + + + + +
+ Derivatives + + + + + +
+ Collision Detection + + + + + +
+ Animation + + + + + +
+ Circle And Ellipse + + + + + +
+ Sequence + + + + + +
+ Other + + + + + +
+
+
+ +
+

Series

+
import { naturalNumbersSum1ToN } from 'mz-math';
+
+// 1 + 2 + 3
+const sum = naturalNumbersSum1ToN(3); // 6;
+
import { naturalNumbersSumMToN } from 'mz-math';
+
+// 5 + 6 + 7
+const sum = naturalNumbersSumMToN(5, 7); // 18
+
+ +
+ +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/docs/pages/set-decimal-places.html b/docs/pages/set-decimal-places.html index f559d318..2d4b4818 100644 --- a/docs/pages/set-decimal-places.html +++ b/docs/pages/set-decimal-places.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -285,6 +285,6 @@ - + \ No newline at end of file diff --git a/docs/pages/shearing-matrix.html b/docs/pages/shearing-matrix.html index 347839db..2e935992 100644 --- a/docs/pages/shearing-matrix.html +++ b/docs/pages/shearing-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -299,6 +299,6 @@ - + \ No newline at end of file diff --git a/docs/pages/shift-colors.html b/docs/pages/shift-colors.html index 02586244..48d437b7 100644 --- a/docs/pages/shift-colors.html +++ b/docs/pages/shift-colors.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -287,6 +287,6 @@ - + \ No newline at end of file diff --git a/docs/pages/similar-colors.html b/docs/pages/similar-colors.html index 0a88cd5c..2a9051cc 100644 --- a/docs/pages/similar-colors.html +++ b/docs/pages/similar-colors.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -318,6 +318,6 @@ - + \ No newline at end of file diff --git a/docs/pages/sine-wave-movement.html b/docs/pages/sine-wave-movement.html index 068c9cf4..5e985dee 100644 --- a/docs/pages/sine-wave-movement.html +++ b/docs/pages/sine-wave-movement.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -285,6 +285,6 @@ - + \ No newline at end of file diff --git a/docs/pages/square-in-circle.html b/docs/pages/square-in-circle.html index 18e1a82f..4bf63a60 100644 --- a/docs/pages/square-in-circle.html +++ b/docs/pages/square-in-circle.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -284,6 +284,6 @@ - + \ No newline at end of file diff --git a/docs/pages/system-of-linear-equations.html b/docs/pages/system-of-linear-equations.html index 0c36340c..a394e16b 100644 --- a/docs/pages/system-of-linear-equations.html +++ b/docs/pages/system-of-linear-equations.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -326,6 +326,6 @@ - + \ No newline at end of file diff --git a/docs/pages/tangent.html b/docs/pages/tangent.html index bd69cbd6..2048acf2 100644 --- a/docs/pages/tangent.html +++ b/docs/pages/tangent.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -345,6 +345,6 @@ - + \ No newline at end of file diff --git a/docs/pages/temperature-conversion.html b/docs/pages/temperature-conversion.html index 46d5d5dd..135ea7ed 100644 --- a/docs/pages/temperature-conversion.html +++ b/docs/pages/temperature-conversion.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -264,7 +264,7 @@ const fahrenheit = kelvinToFahrenheit(273.15); // 32 - - + \ No newline at end of file diff --git a/docs/pages/translation-matrix.html b/docs/pages/translation-matrix.html index ee188d4a..cbabe981 100644 --- a/docs/pages/translation-matrix.html +++ b/docs/pages/translation-matrix.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -328,6 +328,6 @@ - + \ No newline at end of file diff --git a/docs/pages/trigonometric-functions.html b/docs/pages/trigonometric-functions.html index a97ee250..13f71114 100644 --- a/docs/pages/trigonometric-functions.html +++ b/docs/pages/trigonometric-functions.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -317,6 +317,6 @@ - + \ No newline at end of file diff --git a/docs/pages/typescript-usage.html b/docs/pages/typescript-usage.html index 5bd58c07..f9106fd5 100644 --- a/docs/pages/typescript-usage.html +++ b/docs/pages/typescript-usage.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -274,6 +274,6 @@ - + \ No newline at end of file diff --git a/docs/pages/vector-angle.html b/docs/pages/vector-angle.html index 1957694e..775d0dd5 100644 --- a/docs/pages/vector-angle.html +++ b/docs/pages/vector-angle.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -296,6 +296,6 @@

getV2AngleInEllipse()

- + \ No newline at end of file diff --git a/docs/pages/vector-initialization.html b/docs/pages/vector-initialization.html index 487f98af..f35d9d26 100644 --- a/docs/pages/vector-initialization.html +++ b/docs/pages/vector-initialization.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -297,6 +297,6 @@ - + \ No newline at end of file diff --git a/docs/pages/vector-length.html b/docs/pages/vector-length.html index d021badc..ede10913 100644 --- a/docs/pages/vector-length.html +++ b/docs/pages/vector-length.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -297,6 +297,6 @@

Set Vector Length

- + \ No newline at end of file diff --git a/docs/pages/vectors-equality.html b/docs/pages/vectors-equality.html index 7bfe072d..46b98047 100644 --- a/docs/pages/vectors-equality.html +++ b/docs/pages/vectors-equality.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -283,6 +283,6 @@ - + \ No newline at end of file diff --git a/docs/pages/vectors-subtraction.html b/docs/pages/vectors-subtraction.html index 9323d6f5..2bb25692 100644 --- a/docs/pages/vectors-subtraction.html +++ b/docs/pages/vectors-subtraction.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -300,6 +300,6 @@ - + \ No newline at end of file diff --git a/docs/pages/vectors-sum.html b/docs/pages/vectors-sum.html index d341ec82..5e7a7503 100644 --- a/docs/pages/vectors-sum.html +++ b/docs/pages/vectors-sum.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -300,6 +300,6 @@ - + \ No newline at end of file diff --git a/docs/pages/vectors.html b/docs/pages/vectors.html index 53d939e4..02ef61cf 100644 --- a/docs/pages/vectors.html +++ b/docs/pages/vectors.html @@ -16,8 +16,8 @@ - - + + @@ -235,7 +235,7 @@ - + @@ -287,6 +287,6 @@ - + \ No newline at end of file diff --git a/docs/sitemap.txt b/docs/sitemap.txt index 44eb1584..2bde69fc 100644 --- a/docs/sitemap.txt +++ b/docs/sitemap.txt @@ -98,3 +98,4 @@ https://math.mzsoft.org/pages/check-if-ranges-overlap.html https://math.mzsoft.org/pages/check-if-value-is-number.html https://math.mzsoft.org/pages/polar-to-cartesian.html https://math.mzsoft.org/pages/temperature-conversion.html +https://math.mzsoft.org/pages/series.html diff --git a/package.json b/package.json index d544af30..4a1cd875 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mz-math", - "version": "3.0.24", + "version": "3.0.25", "description": "mzMath - a collection of TypeScript-based math helpers.", "main": "./dist/mz-math.min.js", "module": "./dist/mz-math.esm.js", diff --git a/src/docs/data/pages/1000-other/10-series.md b/src/docs/data/pages/1000-other/10-series.md new file mode 100644 index 00000000..f98a48e1 --- /dev/null +++ b/src/docs/data/pages/1000-other/10-series.md @@ -0,0 +1,15 @@ +# Series + +```js +import { naturalNumbersSum1ToN } from 'mz-math'; + +// 1 + 2 + 3 +const sum = naturalNumbersSum1ToN(3); // 6; +``` + +```js +import { naturalNumbersSumMToN } from 'mz-math'; + +// 5 + 6 + 7 +const sum = naturalNumbersSumMToN(5, 7); // 18 +``` diff --git a/src/index-esm.ts b/src/index-esm.ts index a892ad09..ec2f722d 100644 --- a/src/index-esm.ts +++ b/src/index-esm.ts @@ -18,4 +18,5 @@ export * from './main/animation'; export * from './main/circle-ellipse'; export * from './main/sequence'; export * from './main/statistics'; -export * from './main/ml'; \ No newline at end of file +export * from './main/ml'; +export * from './main/series'; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 40d5dc2d..f87037c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,7 @@ import * as circleEllipse from './main/circle-ellipse'; import * as sequence from './main/sequence'; import * as statistics from './main/statistics'; import * as ml from './main/ml'; +import * as series from './main/series'; const api = { ...vector, @@ -42,6 +43,7 @@ const api = { ...sequence, ...statistics, ...ml, + ...series, }; declare global { @@ -72,4 +74,5 @@ export * from './main/animation'; export * from './main/circle-ellipse'; export * from './main/sequence'; export * from './main/statistics'; -export * from './main/ml'; \ No newline at end of file +export * from './main/ml'; +export * from './main/series'; \ No newline at end of file diff --git a/src/main/series.ts b/src/main/series.ts new file mode 100644 index 00000000..41729b73 --- /dev/null +++ b/src/main/series.ts @@ -0,0 +1,14 @@ +/** + * Sum of 1 to n numbers: + * (n * (n + 1)) / 2 + */ +export const naturalNumbersSum1ToN = (n: number): number => { + return (n / 2) * (n + 1); +}; + +/** + * Sum of m to n numbers. + */ +export const naturalNumbersSumMToN = (m: number, n: number): number => { + return (n - m + 1) * (m + n) / 2; +}; \ No newline at end of file diff --git a/test/series.test.ts b/test/series.test.ts new file mode 100644 index 00000000..b002f71f --- /dev/null +++ b/test/series.test.ts @@ -0,0 +1,31 @@ +import { + naturalNumbersSum1ToN, + naturalNumbersSumMToN, +} from '../src/main/series'; + +describe('Series', () => { + + describe('naturalNumbersSum1ToN()', () => { + test('1', () => { + expect(naturalNumbersSum1ToN(1)).toStrictEqual(1); + }); + + test('2', () => { + expect(naturalNumbersSum1ToN(2)).toStrictEqual(3); + }); + + test('3', () => { + expect(naturalNumbersSum1ToN(3)).toStrictEqual(6); + }); + }); + + describe('naturalNumbersSumMToN()', () => { + test('1, 1', () => { + expect(naturalNumbersSumMToN(1,1)).toStrictEqual(1); + }); + + test('5, 7', () => { + expect(naturalNumbersSumMToN(5,7)).toStrictEqual(18); + }); + }); +}); \ No newline at end of file