UNPKG

davinci-newton

Version:

Physics Modeling and Engine using Geometric Algebra

1 lines 238 kB
const t=[0,0],e=[];class s{numer_;denom_;constructor(t,e){let s;if(0===e)throw new Error("denominator must not be zero");s=0===t?1:function(t,e){let s;for(t<0&&(t=-t),e<0&&(e=-e),e>t&&(s=t,t=e,e=s);;){if(0==(t%=e))return e;if(0==(e%=t))return t}}(Math.abs(t),Math.abs(e)),e<0&&(t=-t,e=-e),this.numer_=t/s,this.denom_=e/s}get numer(){return this.numer_}get denom(){return this.denom_}add(t){return s.valueOf(this.numer_*t.denom_+this.denom_*t.numer_,this.denom_*t.denom_)}sub(t){return s.valueOf(this.numer_*t.denom_-this.denom_*t.numer_,this.denom_*t.denom_)}mul(t){return s.valueOf(this.numer_*t.numer_,this.denom_*t.denom_)}div(t){const e=this.numer_*t.denom_,i=this.denom_*t.numer_;return 0===e?0===i?s.valueOf(e,i):s.ZERO:s.valueOf(e,i)}isOne(){return 1===this.numer_&&1===this.denom_}isZero(){return 0===this.numer_&&1===this.denom_}hashCode(){return 37*this.numer_+13*this.denom_}inv(){return s.valueOf(this.denom_,this.numer_)}neg(){return s.valueOf(-this.numer_,this.denom_)}equals(t){return this===t||t instanceof s&&this.numer_*t.denom_==this.denom_*t.numer_}toString(t){return this.numer_.toString(t)+"/"+this.denom_.toString(t)}__add__(t){return t instanceof s?this.add(t):void 0}__radd__(t){return t instanceof s?t.add(this):void 0}__sub__(t){return t instanceof s?this.sub(t):void 0}__rsub__(t){return t instanceof s?t.sub(this):void 0}__mul__(t){return t instanceof s?this.mul(t):void 0}__rmul__(t){return t instanceof s?t.mul(this):void 0}__div__(t){return t instanceof s?this.div(t):void 0}__rdiv__(t){return t instanceof s?t.div(this):void 0}__pos__(){return this}__neg__(){return this.neg()}static ZERO=new s(0,1);static valueOf(i,r){!function(t,e,s){let i;if(0===e)throw new Error("denominator must not be zero");i=0===t?1:function(t,e){let s;for(t<0&&(t=-t),e<0&&(e=-e),e>t&&(s=t,t=e,e=s);;){if(0==(t%=e))return e;if(0==(e%=t))return t}}(Math.abs(t),Math.abs(e)),e<0&&(t=-t,e=-e),s[0]=t/i,s[1]=e/i}(i,r,t),i=t[0],r=t[1];for(const t of e)if(t.numer_===i&&t.denom_===r)return t;const o=new s(i,r);return e.push(o),o}}var i;!function(t){t[t.AMOUNT_OF_SUBSTANCE=0]="AMOUNT_OF_SUBSTANCE",t[t.ANGULAR_MOMENTUM=1]="ANGULAR_MOMENTUM",t[t.AREA=2]="AREA",t[t.ELECTRIC_CHARGE=3]="ELECTRIC_CHARGE",t[t.ELECTRIC_CURRENT=4]="ELECTRIC_CURRENT",t[t.ELECTRIC_FIELD=5]="ELECTRIC_FIELD",t[t.ELECTRIC_PERMITTIVITY_TIMES_AREA=6]="ELECTRIC_PERMITTIVITY_TIMES_AREA",t[t.ENERGY_OR_TORQUE=7]="ENERGY_OR_TORQUE",t[t.FORCE=8]="FORCE",t[t.FRICTION_COEFFICIENT=9]="FRICTION_COEFFICIENT",t[t.INV_LENGTH=10]="INV_LENGTH",t[t.INV_MASS=11]="INV_MASS",t[t.INV_MOMENT_OF_INERTIA=12]="INV_MOMENT_OF_INERTIA",t[t.INV_TIME=13]="INV_TIME",t[t.LENGTH=14]="LENGTH",t[t.LUMINOUS_INTENSITY=15]="LUMINOUS_INTENSITY",t[t.MASS=16]="MASS",t[t.MOMENT_OF_INERTIA=17]="MOMENT_OF_INERTIA",t[t.MOMENTUM=18]="MOMENTUM",t[t.MOMENTUM_SQUARED=19]="MOMENTUM_SQUARED",t[t.ONE=20]="ONE",t[t.RATE_OF_CHANGE_OF_AREA=21]="RATE_OF_CHANGE_OF_AREA",t[t.STIFFNESS=22]="STIFFNESS",t[t.THERMODYNAMIC_TEMPERATURE=23]="THERMODYNAMIC_TEMPERATURE",t[t.TIME=24]="TIME",t[t.TIME_SQUARED=25]="TIME_SQUARED",t[t.VELOCITY=26]="VELOCITY",t[t.VELOCITY_SQUARED=27]="VELOCITY_SQUARED",t[t.VOLUME=28]="VOLUME"}(i||(i={}));const r=[],o=s.valueOf(0,1),n=s.valueOf(1,1),h=s.valueOf(2,1),a=s.valueOf(3,1),u=s.valueOf(-1,1),c=s.valueOf(-2,1);function m(t,e){if(e instanceof s)return e;throw new Error(`Argument ${t} => ${e} must be a QQ`)}let l="strict";function d(t){switch(t){case"strict":case"none":l=t;break;default:throw new Error("mode must be 'none' or 'strict'.")}}class _{static ONE=new _(o,o,o,o,o,o,o,i.ONE);static MASS=new _(n,o,o,o,o,o,o,i.MASS);static LENGTH=new _(o,n,o,o,o,o,o,i.LENGTH);static AREA=new _(o,h,o,o,o,o,o,i.AREA);static VOLUME=new _(o,a,o,o,o,o,o,i.VOLUME);static INV_LENGTH=new _(o,u,o,o,o,o,o,i.INV_LENGTH);static TIME=new _(o,o,n,o,o,o,o,i.TIME);static ELECTRIC_CHARGE=new _(o,o,o,n,o,o,o,i.ELECTRIC_CHARGE);static ELECTRIC_CURRENT=new _(o,o,u,n,o,o,o,i.ELECTRIC_CURRENT);static THERMODYNAMIC_TEMPERATURE=new _(o,o,o,o,n,o,o,i.THERMODYNAMIC_TEMPERATURE);static AMOUNT_OF_SUBSTANCE=new _(o,o,o,o,o,n,o,i.AMOUNT_OF_SUBSTANCE);static LUMINOUS_INTENSITY=new _(o,o,o,o,o,o,n,i.LUMINOUS_INTENSITY);static ANGULAR_MOMENTUM=new _(n,h,u,o,o,o,o,i.ANGULAR_MOMENTUM);static RATE_OF_CHANGE_OF_AREA=new _(o,h,u,o,o,o,o,i.RATE_OF_CHANGE_OF_AREA);static ELECTRIC_FIELD=new _(n,n,c,u,o,o,o,i.ELECTRIC_FIELD);static ELECTRIC_PERMITTIVITY_TIMES_AREA=new _(u,u,h,h,o,o,o,i.ELECTRIC_PERMITTIVITY_TIMES_AREA);static ENERGY_OR_TORQUE=new _(n,h,c,o,o,o,o,i.ENERGY_OR_TORQUE);static FORCE=new _(n,n,c,o,o,o,o,i.FORCE);static INV_MASS=new _(u,o,o,o,o,o,o,i.INV_MASS);static INV_MOMENT_OF_INERTIA=new _(u,c,o,o,o,o,o,i.INV_MOMENT_OF_INERTIA);static INV_TIME=new _(o,o,u,o,o,o,o,i.INV_TIME);static MOMENT_OF_INERTIA=new _(n,h,o,o,o,o,o,i.MOMENT_OF_INERTIA);static MOMENTUM=new _(n,n,u,o,o,o,o,i.MOMENTUM);static MOMENTUM_SQUARED=new _(h,h,c,o,o,o,o,i.MOMENTUM_SQUARED);static STIFFNESS=new _(n,o,c,o,o,o,o,i.STIFFNESS);static FRICTION_COEFFICIENT=new _(n,o,u,o,o,o,o,i.FRICTION_COEFFICIENT);static TIME_SQUARED=new _(o,o,h,o,o,o,o,i.TIME_SQUARED);static VELOCITY=new _(o,n,u,o,o,o,o,i.VELOCITY);static VELOCITY_SQUARED=new _(o,h,c,o,o,o,o,i.VELOCITY_SQUARED);M;L;T;Q;temperature;amount;intensity;summary_;constructor(t,e,s,i,r,o,n,h){this.M=m("M",t),this.L=m("L",e),this.T=m("T",s),this.Q=m("Q",i),this.temperature=m("temperature",r),this.amount=m("amount",o),this.intensity=m("intensity",n),this.summary_=h}get summary(){return this.summary_}compatible(t){if("number"==typeof this.summary_&&this.summary_===t.summary_)return this;if(this.M.equals(t.M)&&this.L.equals(t.L)&&this.T.equals(t.T)&&this.Q.equals(t.Q)&&this.temperature.equals(t.temperature)&&this.amount.equals(t.amount)&&this.intensity.equals(t.intensity))return this;if(this.isOne()){if(t.isOne())throw new Error;if("none"===l)return t;throw new Error(`Dimensions must be equal (dimensionless, ${t})`)}if(t.isOne()){if("none"===l)return this;throw new Error(`Dimensions must be equal (${this}, dimensionless)`)}if("none"===l)return this;throw new Error(`Dimensions must be equal (${this}, ${t})`)}equals(t){return this===t||this.M.equals(t.M)&&this.L.equals(t.L)&&this.T.equals(t.T)&&this.Q.equals(t.Q)&&this.temperature.equals(t.temperature)&&this.amount.equals(t.amount)&&this.intensity.equals(t.intensity)}mul(t){return _.valueOf(this.M.add(t.M),this.L.add(t.L),this.T.add(t.T),this.Q.add(t.Q),this.temperature.add(t.temperature),this.amount.add(t.amount),this.intensity.add(t.intensity))}div(t){return _.valueOf(this.M.sub(t.M),this.L.sub(t.L),this.T.sub(t.T),this.Q.sub(t.Q),this.temperature.sub(t.temperature),this.amount.sub(t.amount),this.intensity.sub(t.intensity))}pow(t){return _.valueOf(this.M.mul(t),this.L.mul(t),this.T.mul(t),this.Q.mul(t),this.temperature.mul(t),this.amount.mul(t),this.intensity.mul(t))}sqrt(){return _.valueOf(this.M.div(h),this.L.div(h),this.T.div(h),this.Q.div(h),this.temperature.div(h),this.amount.div(h),this.intensity.div(h))}isOne(){return this===_.ONE||this.M.isZero()&&this.L.isZero()&&this.T.isZero()&&this.Q.isZero()&&this.temperature.isZero()&&this.amount.isZero()&&this.intensity.isZero()}inv(){return _.valueOf(this.M.neg(),this.L.neg(),this.T.neg(),this.Q.neg(),this.temperature.neg(),this.amount.neg(),this.intensity.neg())}toString(){const t=function(t,e){return 0===t.numer?null:1===t.denom?1===t.numer?""+e:e+" ** "+t.numer:e+" ** "+t};return[t(this.M,"mass"),t(this.L,"length"),t(this.T,"time"),t(this.Q,"charge"),t(this.temperature,"thermodynamic temperature"),t(this.amount,"amount of substance"),t(this.intensity,"luminous intensity")].filter((function(t){return"string"==typeof t})).join(" * ")}__add__(t){return t instanceof _?this.compatible(t):void 0}__radd__(t){return t instanceof _?t.compatible(this):void 0}__sub__(t){return t instanceof _?this.compatible(t):void 0}__rsub__(t){return t instanceof _?t.compatible(this):void 0}__mul__(t){return t instanceof _?this.mul(t):void 0}__rmul__(t){return t instanceof _?t.mul(this):void 0}__div__(t){return t instanceof _?this.div(t):void 0}__rdiv__(t){return t instanceof _?t.div(this):void 0}__pos__(){return this}__neg__(){return this}static valueOf(t,e,s,o,n,h,a){const u=function(t,e,s,r,o,n,h){if(-1===t.numer){if(1===t.denom)if(-2===e.numer){if(1===e.denom&&0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.INV_MOMENT_OF_INERTIA}else if(-1===e.numer){if(1===e.denom&&2===s.numer&&1===s.denom&&2===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.ELECTRIC_PERMITTIVITY_TIMES_AREA}else if(0===e.numer&&1===e.denom&&0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.INV_MASS}else if(0===t.numer){if(1===t.denom)if(-1===e.numer){if(1===e.denom&&0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.INV_LENGTH}else if(0===e.numer){if(1===e.denom)if(-1===s.numer){if(1===s.denom)if(0===r.numer){if(1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.INV_TIME}else if(1===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.ELECTRIC_CURRENT}else if(0===s.numer){if(1===s.denom)if(0===r.numer){if(1===r.denom)if(0===o.numer){if(1===o.denom)if(0===n.numer){if(1===n.denom)if(0===h.numer){if(1===h.denom)return i.ONE}else if(1===h.numer&&1===h.denom)return i.LUMINOUS_INTENSITY}else if(1===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.AMOUNT_OF_SUBSTANCE}else if(1===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.THERMODYNAMIC_TEMPERATURE}else if(1===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.ELECTRIC_CHARGE}else if(1===s.numer){if(1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.TIME}else if(2===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.TIME_SQUARED}else if(1===e.numer){if(1===e.denom)if(-1===s.numer){if(1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.VELOCITY}else if(0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.LENGTH}else if(2===e.numer){if(1===e.denom){if(-2===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.VELOCITY_SQUARED;if(-1===s.numer){if(1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.RATE_OF_CHANGE_OF_AREA}else if(0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.AREA}}else if(3===e.numer&&1===e.denom&&0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.VOLUME}else if(1===t.numer){if(1===t.denom)if(0===e.numer){if(1===e.denom)if(-2===s.numer){if(1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.STIFFNESS}else if(0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.MASS}else if(1===e.numer){if(1===e.denom)if(-2===s.numer){if(1===s.denom)if(-1===r.numer){if(1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.ELECTRIC_FIELD}else if(0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.FORCE}else if(-1===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.MOMENTUM}else if(2===e.numer&&1===e.denom)if(-2===s.numer){if(1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.ENERGY_OR_TORQUE}else if(-1===s.numer){if(1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.ANGULAR_MOMENTUM}else if(0===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.MOMENT_OF_INERTIA}else if(2===t.numer&&1===t.denom&&2===e.numer&&1===e.denom&&-2===s.numer&&1===s.denom&&0===r.numer&&1===r.denom&&0===o.numer&&1===o.denom&&0===n.numer&&1===n.denom&&0===h.numer&&1===h.denom)return i.MOMENTUM_SQUARED}(t,e,s,o,n,h,a);switch(u){case i.AMOUNT_OF_SUBSTANCE:return _.AMOUNT_OF_SUBSTANCE;case i.ANGULAR_MOMENTUM:return _.ANGULAR_MOMENTUM;case i.AREA:return _.AREA;case i.ELECTRIC_CHARGE:return _.ELECTRIC_CHARGE;case i.ELECTRIC_CURRENT:return _.ELECTRIC_CURRENT;case i.ELECTRIC_FIELD:return _.ELECTRIC_FIELD;case i.ELECTRIC_PERMITTIVITY_TIMES_AREA:return _.ELECTRIC_PERMITTIVITY_TIMES_AREA;case i.ENERGY_OR_TORQUE:return _.ENERGY_OR_TORQUE;case i.FORCE:return _.FORCE;case i.LUMINOUS_INTENSITY:return _.LUMINOUS_INTENSITY;case i.INV_LENGTH:return _.INV_LENGTH;case i.INV_MASS:return _.INV_MASS;case i.INV_MOMENT_OF_INERTIA:return _.INV_MOMENT_OF_INERTIA;case i.INV_TIME:return _.INV_TIME;case i.LENGTH:return _.LENGTH;case i.MASS:return _.MASS;case i.MOMENT_OF_INERTIA:return _.MOMENT_OF_INERTIA;case i.MOMENTUM:return _.MOMENTUM;case i.MOMENTUM_SQUARED:return _.MOMENTUM_SQUARED;case i.ONE:return _.ONE;case i.RATE_OF_CHANGE_OF_AREA:return _.RATE_OF_CHANGE_OF_AREA;case i.STIFFNESS:return _.STIFFNESS;case i.THERMODYNAMIC_TEMPERATURE:return _.THERMODYNAMIC_TEMPERATURE;case i.TIME:return _.TIME;case i.TIME_SQUARED:return _.TIME_SQUARED;case i.VELOCITY:return _.VELOCITY;case i.VELOCITY_SQUARED:return _.VELOCITY_SQUARED;case i.VOLUME:return _.VOLUME;default:{for(const i of r)if(i.M.equals(t)&&i.L.equals(e)&&i.T.equals(s)&&i.Q.equals(o)&&i.temperature.equals(n)&&i.amount.equals(h)&&i.intensity.equals(a))return i;const i=new _(t,e,s,o,n,h,a,u);return r.push(i),i}}}}function y(t,e,s,i){e||function(t,e,s){const i=e?e():"satisfy some condition",r=s?" in "+s():"";throw new Error(t+" must "+i+r+".")}(t,s,i)}function p(){return"be a string"}function f(t,e,s){return y(t,"string"==typeof e,p,s),e}function E(t){return f("name",t),{get message(){return"Property `"+t+"` is readonly."}}}const g=-1*Math.random();class b{$unit;lock_=g;constructor(t){this.$unit=t}get uom(){return this.$unit}set uom(t){if(!this.isMutable())throw new Error(E("uom").message);this.$unit=t}isLocked(){return this.lock_!==g}isMutable(){return this.lock_===g}lock(){if(this.lock_!==g)throw new Error("already locked");return this.lock_=Math.random(),this.lock_}unlock(t){if(this.lock_===g)throw new Error("not locked");if(this.lock_===t)return this.lock_=g,this;throw new Error("unlock denied")}permlock(){return this.lock(),this}}const M=Math.abs;function x(t,e,s){let i=M(t[e][e]),r=e;for(let o=e+1;o<s;o++)M(t[o][e])>i&&(i=M(t[o][e]),r=o);return r}function w(t,e,s,i){const r=i+1;for(let i=e;i<r;i++){const r=t[s][i];t[s][i]=t[e][i],t[e][i]=r}}function v(t,e,s){for(let i=e+1;i<s;i++){const r=-t[i][e]/t[e][e];for(let o=e;o<s+1;o++)e===o?t[i][o]=0:t[i][o]+=r*t[e][o]}}function $(t,e){const s=t.length;for(let i=0;i<s;i++){const s=t[i],r=e[i];s.push(r)}for(let e=0;e<s;e++)w(t,e,x(t,e,s),s),v(t,e,s);return function(t,e){const s=function(t,e){const s=[];for(let e=0;e<t;e++)s.push(0);return s}(e);for(let i=e-1;i>-1;i--){s[i]=t[i][e]/t[i][i];for(let r=i-1;r>-1;r--)t[r][e]-=t[r][i]*s[i]}return s}(t,s)}const L=[],T=["kg","m","s","C","K","mol","cd"],R=[[-1,1,-3,1,2,1,2,1,0,1,0,1,0,1],[-1,1,-2,1,1,1,2,1,0,1,0,1,0,1],[-1,1,-2,1,2,1,2,1,0,1,0,1,0,1],[-1,1,-1,1,2,1,2,1,0,1,0,1,0,1],[-1,1,0,1,0,1,1,1,0,1,0,1,0,1],[-1,1,3,1,-2,1,0,1,0,1,0,1,0,1],[0,1,-3,1,0,1,1,1,0,1,0,1,0,1],[0,1,-2,1,0,1,1,1,0,1,0,1,0,1],[0,1,-1,1,0,1,1,1,0,1,0,1,0,1],[0,1,2,1,-2,1,0,1,0,1,0,1,0,1],[0,1,0,1,-1,1,0,1,0,1,0,1,0,1],[0,1,0,1,-1,1,1,1,0,1,0,1,0,1],[0,1,1,1,-2,1,0,1,0,1,0,1,0,1],[0,1,1,1,-1,1,0,1,0,1,0,1,0,1],[1,1,1,1,-1,1,0,1,0,1,0,1,0,1],[1,1,-1,1,-2,1,0,1,0,1,0,1,0,1],[1,1,-1,1,-1,1,0,1,0,1,0,1,0,1],[1,1,0,1,-3,1,0,1,0,1,0,1,0,1],[1,1,0,1,-2,1,0,1,0,1,0,1,0,1],[1,1,0,1,-1,1,-1,1,0,1,0,1,0,1],[1,1,1,1,-3,1,0,1,-1,1,0,1,0,1],[1,1,1,1,-2,1,-1,1,0,1,0,1,0,1],[1,1,1,1,-2,1,0,1,0,1,0,1,0,1],[1,1,1,1,0,1,-2,1,0,1,0,1,0,1],[1,1,2,1,-2,1,0,1,-1,1,0,1,0,1],[0,1,2,1,-2,1,0,1,-1,1,0,1,0,1],[1,1,2,1,-2,1,0,1,-1,1,-1,1,0,1],[1,1,2,1,-2,1,0,1,0,1,-1,1,0,1],[1,1,2,1,-2,1,0,1,0,1,0,1,0,1],[1,1,2,1,-1,1,0,1,0,1,0,1,0,1],[1,1,2,1,-3,1,0,1,0,1,0,1,0,1],[1,1,2,1,-2,1,-1,1,0,1,0,1,0,1],[1,1,2,1,-1,1,-2,1,0,1,0,1,0,1],[1,1,2,1,0,1,-2,1,0,1,0,1,0,1],[1,1,2,1,-1,1,-1,1,0,1,0,1,0,1],[1,1,3,1,-2,1,-2,1,0,1,0,1,0,1]],O=[["F/m or C**2/N·m**2"],["S or A/V"],["F or C/V"],["C**2/N"],["C/kg"],["N·m·m/kg·kg"],["C/m**3"],["C/m**2"],["C/m"],["J/kg"],["Hz"],["A"],["m/s**2"],["m/s"],["kg·m/s"],["Pa or N/m**2 or J/m**3"],["Pa·s"],["W/m**2"],["N/m"],["T or Wb/m**2"],["W/(m·K)"],["V/m or N/C"],["N"],["H/m"],["J/K"],["J/(kg·K)"],["J/(mol·K)"],["J/mol"],["J or N·m"],["J·s"],["W or J/s"],["V or W/A"],["Ω or V/A"],["H or Wb/A"],["Wb"],["N·m**2/C**2"]],S=function(t,e,s,i,r){const o=s.M,n=s.L,h=s.T,a=s.Q,u=s.temperature,c=s.amount,m=s.intensity;for(let e=0,s=R.length;e<s;e++){const s=R[e];if(o.numer===s[0]&&o.denom===s[1]&&n.numer===s[2]&&n.denom===s[3]&&h.numer===s[4]&&h.denom===s[5]&&a.numer===s[6]&&a.denom===s[7]&&u.numer===s[8]&&u.denom===s[9]&&c.numer===s[10]&&c.denom===s[11]&&m.numer===s[12]&&m.denom===s[13])return r?1!==t?t+" * "+O[e][0]:O[e][0]:t+" * "+O[e][0]}return function(t,e,s,i,r){const o=function(t,e){return 0===t.numer?null:1===t.denom?1===t.numer?e:`${e}**${t.numer}`:`${e}**${t}`};return""+(1===t&&r?"":e)+((1===t||s.isOne())&&r?"":" ")+[o(s.M,i[0]),o(s.L,i[1]),o(s.T,i[2]),o(s.Q,i[3]),o(s.temperature,i[4]),o(s.amount,i[5]),o(s.intensity,i[6])].filter((function(t){return"string"==typeof t})).join(" ")}(t,e,s,i,r)};function A(t,e){return V.valueOf(t.multiplier+e.multiplier,t.dimensions.compatible(e.dimensions),t.labels)}function I(t,e){return V.valueOf(t.multiplier-e.multiplier,t.dimensions.compatible(e.dimensions),t.labels)}function k(t,e){return V.valueOf(t.multiplier*e.multiplier,t.dimensions.mul(e.dimensions),t.labels)}function C(t,e){return V.valueOf(t*e.multiplier,e.dimensions,e.labels)}function N(t,e){return V.valueOf(t.multiplier/e.multiplier,t.dimensions.div(e.dimensions),t.labels)}class V{multiplier;dimensions;labels;static isOne(t){if(void 0===t)return!0;if(t instanceof V)return t.isOne();throw new Error("isOne argument must be a Unit or undefined.")}static assertDimensionless(t){if(!V.isOne(t))throw new Error(`uom ${t} must be dimensionless.`)}static compatible(t,e){if(t){if(e)return t.compatible(e);if(t.isOne())return;throw new Error(t+" is incompatible with 1")}if(e){if(e.isOne())return;throw new Error("1 is incompatible with "+e)}}static isCompatible(t,e){return t?e?t.isCompatible(e):!!t.isOne():!e||!!e.isOne()}static mul(t,e){return t?e?t.mul(e):V.isOne(e)?t:void 0:V.isOne(t)?e:void 0}static div(t,e){return t?e?t.div(e):t:e?e.inv():V.ONE}static inv(t){return t instanceof V?t.isOne()?V.ONE:t.inv():V.ONE}static mustBeUnit(t,e){if(e instanceof V)return e;if(void 0===e)return V.ONE;throw new Error(`${t} must be a Unit or undefined (meaning 1).`)}static pow(t,e){return t instanceof V?t.isOne()||e.isZero()?void 0:t.pow(e):void 0}static sqrt(t){return t instanceof V?t.isOne()?void 0:t.sqrt():void 0}static valueOf(t,e,s){if(1===t)switch(e.summary){case i.AMOUNT_OF_SUBSTANCE:return V.MOLE;case i.ANGULAR_MOMENTUM:return V.JOULE_SECOND;case i.AREA:return V.METER_SQUARED;case i.ELECTRIC_CHARGE:return V.COULOMB;case i.ELECTRIC_CURRENT:return V.AMPERE;case i.ELECTRIC_FIELD:return V.ELECTRIC_FIELD;case i.ELECTRIC_PERMITTIVITY_TIMES_AREA:return V.COULOMB_SQUARED_PER_NEWTON;case i.ENERGY_OR_TORQUE:return V.JOULE;case i.FORCE:return V.NEWTON;case i.FRICTION_COEFFICIENT:return V.FRICTION_COEFFICIENT;case i.INV_LENGTH:return V.INV_METER;case i.INV_MASS:return V.INV_KILOGRAM;case i.INV_MOMENT_OF_INERTIA:return V.INV_KILOGRAM_METER_SQUARED;case i.INV_TIME:return V.INV_SECOND;case i.LENGTH:return V.METER;case i.LUMINOUS_INTENSITY:return V.CANDELA;case i.MASS:return V.KILOGRAM;case i.MOMENT_OF_INERTIA:return V.KILOGRAM_METER_SQUARED;case i.MOMENTUM:return V.KILOGRAM_METER_PER_SECOND;case i.MOMENTUM_SQUARED:return V.KILOGRAM_SQUARED_METER_SQUARED_PER_SECOND_SQUARED;case i.ONE:return V.ONE;case i.RATE_OF_CHANGE_OF_AREA:return V.METER_SQUARED_PER_SECOND;case i.STIFFNESS:return V.STIFFNESS;case i.THERMODYNAMIC_TEMPERATURE:return V.KELVIN;case i.TIME:return V.SECOND;case i.TIME_SQUARED:return V.SECOND_SQUARED;case i.VELOCITY:return V.METER_PER_SECOND;case i.VELOCITY_SQUARED:return V.METER_SQUARED_PER_SECOND_SQUARED;case i.VOLUME:return V.METER_CUBED}for(const s of L)if(s.multiplier===t&&s.dimensions.equals(e))return s;const r=new V(t,e,s);return L.push(r),r}static ONE=new V(1,_.ONE,T);static KILOGRAM=new V(1,_.MASS,T);static METER=new V(1,_.LENGTH,T);static SECOND=new V(1,_.TIME,T);static COULOMB=new V(1,_.ELECTRIC_CHARGE,T);static AMPERE=new V(1,_.ELECTRIC_CURRENT,T);static KELVIN=new V(1,_.THERMODYNAMIC_TEMPERATURE,T);static MOLE=new V(1,_.AMOUNT_OF_SUBSTANCE,T);static CANDELA=new V(1,_.LUMINOUS_INTENSITY,T);static COULOMB_SQUARED_PER_NEWTON=new V(1,_.ELECTRIC_PERMITTIVITY_TIMES_AREA,T);static ELECTRIC_FIELD=new V(1,_.ELECTRIC_FIELD,T);static NEWTON=new V(1,_.FORCE,T);static JOULE=new V(1,_.ENERGY_OR_TORQUE,T);static JOULE_SECOND=new V(1,_.ANGULAR_MOMENTUM,T);static METER_SQUARED=new V(1,_.AREA,T);static METER_CUBED=new V(1,_.VOLUME,T);static SECOND_SQUARED=new V(1,_.TIME_SQUARED,T);static INV_KILOGRAM=new V(1,_.INV_MASS,T);static INV_METER=new V(1,_.INV_LENGTH,T);static INV_SECOND=new V(1,_.INV_TIME,T);static KILOGRAM_METER_SQUARED=new V(1,_.MOMENT_OF_INERTIA,T);static KILOGRAM_METER_PER_SECOND=new V(1,_.MOMENTUM,T);static KILOGRAM_SQUARED_METER_SQUARED_PER_SECOND_SQUARED=new V(1,_.MOMENTUM_SQUARED,T);static INV_KILOGRAM_METER_SQUARED=new V(1,_.INV_MOMENT_OF_INERTIA,T);static STIFFNESS=new V(1,_.STIFFNESS,T);static FRICTION_COEFFICIENT=new V(1,_.FRICTION_COEFFICIENT,T);static METER_PER_SECOND=new V(1,_.VELOCITY,T);static METER_SQUARED_PER_SECOND=new V(1,_.RATE_OF_CHANGE_OF_AREA,T);static METER_SQUARED_PER_SECOND_SQUARED=new V(1,_.VELOCITY_SQUARED,T);constructor(t,e,s){if(this.multiplier=t,this.dimensions=e,this.labels=s,7!==s.length)throw new Error("Expecting 7 elements in the labels array.");this.multiplier=t,this.dimensions=e,this.labels=s}compatible(t){if(t instanceof V){try{this.dimensions.compatible(t.dimensions)}catch(e){const s=e instanceof Error?e.message:`${e}`;throw new Error(`${this} is not compatible with ${t}. Cause: ${s}`)}return this}throw new Error("Illegal Argument for Unit.compatible: "+t)}div(t){return N(this,t)}isCompatible(t){if(t instanceof V)return this.dimensions.equals(t.dimensions);throw new Error("Illegal Argument for Unit.compatible: "+t)}isOne(){return this.dimensions.isOne()&&1===this.multiplier}inv(){return V.valueOf(1/this.multiplier,this.dimensions.inv(),this.labels)}mul(t){return k(this,t)}neg(){return V.valueOf(-this.multiplier,this.dimensions,this.labels)}pow(t){return V.valueOf(Math.pow(this.multiplier,t.numer/t.denom),this.dimensions.pow(t),this.labels)}sqrt(){return V.valueOf(Math.sqrt(this.multiplier),this.dimensions.sqrt(),this.labels)}toExponential(t,e){return S(this.multiplier,this.multiplier.toExponential(t),this.dimensions,this.labels,e)}toFixed(t,e){return S(this.multiplier,this.multiplier.toFixed(t),this.dimensions,this.labels,e)}toPrecision(t,e){return S(this.multiplier,this.multiplier.toPrecision(t),this.dimensions,this.labels,e)}toString(t,e){return S(this.multiplier,this.multiplier.toString(t),this.dimensions,this.labels,e)}__add__(t){return t instanceof V?A(this,t):void 0}__radd__(t){return t instanceof V?A(t,this):void 0}__sub__(t){return t instanceof V?I(this,t):void 0}__rsub__(t){return t instanceof V?I(t,this):void 0}__mul__(t){return t instanceof V?k(this,t):"number"==typeof t?C(t,this):void 0}__rmul__(t){return t instanceof V?k(t,this):"number"==typeof t?C(t,this):void 0}__div__(t){return t instanceof V?N(this,t):"number"==typeof t?V.valueOf(this.multiplier/t,this.dimensions,this.labels):void 0}__rdiv__(t){return t instanceof V?N(t,this):"number"==typeof t?V.valueOf(t/this.multiplier,this.dimensions.inv(),this.labels):void 0}__pos__(){return this}__neg__(){return this.neg()}}function z(t,e,s,i){if(0!==t){t>=0?i.length>0&&i.push("+"):i.push("-");const r=Math.abs(t);1===r?i.push(s):(i.push(e(r)),"1"!==s&&(i.push("*"),i.push(s)))}}function F(t,e,s,i){const r=[];for(let i=0,o=t.length;i<o;i++)z(t[i],e,s[i],r);return V.isOne(i)?r.length>0?r.join(""):"0":r.length>0?`${r.join("")} ${i.toString(10,!0)}`:"0"}const B=function(t){const e=[0,0];return e[q]=t,e};function P(t){return new H([t.a,t.x],t.uom)}function D(t){return t.lock(),t}const U=function(t){const e=[0,0];return e[q]=t.a,e[G]=t.x,e},q=0,G=1,X=["1","e1"];X[q]="1",X[G]="e1";const Y=["1","e_{1}"];Y[q]="1",Y[G]="e_{1}";class H extends b{static scalar(t,e){return new H([t,0],e)}static vector(t,e){return new H([0,t],e)}static zero=D(new H([0,0],void 0));static one=D(new H(B(1),void 0));static e1=D(new H(function(t){const e=[0,0];return e[G]=1,e}(),void 0));static meter=D(new H(B(1),V.METER));static kilogram=D(new H(B(1),V.KILOGRAM));static second=D(new H(B(1),V.SECOND));static ampere=D(new H(B(1),V.AMPERE));static kelvin=D(new H(B(1),V.KELVIN));static mole=D(new H(B(1),V.MOLE));static candela=D(new H(B(1),V.CANDELA));static coulomb=D(new H(B(1),V.COULOMB));static newton=D(new H(B(1),V.NEWTON));static joule=D(new H(B(1),V.JOULE));coords;constructor(t=[0,0],e){if(super(e),2!==t.length)throw new Error("coords.length must be 2.");this.coords=t}get grades(){const t=this.coords;let e=0;return 0!==t[q]&&(e+=1),0!==t[G]&&(e+=2),e}add(t,e=1){return this.isLocked()?D(this.clone().add(t,e)):this.isZero()?(this.a=t.a*e,this.x=t.x*e,this.uom=t.uom,this):(t.isZero()||(this.a+=t.a*e,this.x+=t.x*e,this.uom=V.compatible(this.uom,t.uom)),this)}addVector(t,e=1){if(this.isLocked())return D(this.clone().addVector(t,e));if(this.isZero())this.uom=t.uom;else{if(0===t.x)return this;this.uom=V.compatible(this.uom,t.uom)}return this.x+=t.x*e,this}addScalar(t,e,s=1){return this.isLocked()?D(this.clone().addScalar(t,e,s)):this.isZero()?(this.a=t*s,this.uom=e,this):(0===t||0===s||(this.a+=t*s,this.uom=V.compatible(this.uom,e)),this)}clone(){return P(this)}conj(){return this.isLocked()?D(this.clone().conj()):(this.x=-this.x,this)}copy(t){return this.isMutable()?(this.a=t.a,this.x=t.x,this.uom=t.uom,this):D(P(this).copy(t))}copyVector(t){return this.isMutable()?(this.a=0,this.x=t.x,this.uom=t.uom,this):this.clone().copyVector(t).permlock()}dual(){if(this.isLocked())return this.clone().dual().permlock();{const t=this.b,e=this.a;return this.a=t,this.b=e,this}}equals(t){return t===this||t instanceof H&&function(t,e){for(let s=0;s<2;s++)if(t[s]!==e[s])return!1;return!0}(this.coords,t.coords)&&V.isCompatible(this.uom,t.uom)}lco(t){return this.isLocked()?D(this.clone().lco(t)):this.lco2(this,t)}lco2(t,e){const s=t.a,i=t.x,r=e.a,o=e.x;return this.a=s*r+i*o,this.x=s*o,this.uom=V.mul(this.uom,e.uom),this}div(t){return this.isLocked()?D(this.clone().div(t)):0===t.x?this.divByScalar(t.a,t.uom):this.mul(P(t).inv())}divByVector(t){throw new Error("Method not implemented.")}ext(t){if(this.isLocked())return D(this.clone().ext(t));{const e=this.a,s=this.x,i=t.a,r=t.x;return this.a=e*i,this.x=e*r+s*i,this.uom=V.mul(this.uom,t.uom),this}}grade(t){if(this.isLocked())return D(this.clone().grade(t));switch(t){case 0:this.x=0;break;case 1:this.a=0;break;default:this.a=0,this.x=0}return this}isBivector(){return 0===this.coords[q]&&0===this.coords[G]}isOne(){return 1===this.coords[q]&&0===this.coords[G]&&V.isOne(this.uom)}isScalar(){return 0===this.coords[G]}isSpinor(){return!!V.isOne(this.uom)&&0===this.coords[G]}isVector(){return 0===this.coords[q]}magnitude(){return this.isMutable()?(this.a=this.magnitudeNoUnits(),this.x=0,this):D(this.clone().magnitude())}magnitudeNoUnits(){return Math.sqrt(this.quaditudeNoUnits())}mul(t){return this.isLocked()?D(this.clone().mul(t)):this.mul2(this,t)}mul2(t,e){const s=t.a,i=t.x,r=e.a,o=e.x;return this.a=s*r+i*o,this.x=s*o+i*r,this.uom=V.mul(this.uom,e.uom),this}mulByNumber(t){return this.isLocked()?D(this.clone().mulByNumber(t)):(this.a*=t,this.x*=t,this)}mulByVector(t){if(this.isLocked())return D(this.clone().mulByVector(t));{const e=this.a,s=this.x,i=t.x;return this.a=s*i,this.x=e*i,this.uom=V.mul(this.uom,t.uom),this}}rco(t){return this.isLocked()?D(this.clone().rco(t)):this.rco2(this,t)}rco2(t,e){const s=t.a,i=t.x,r=e.a,o=e.x;return this.a=s*r+i*o,this.x=i*r,this.uom=V.mul(this.uom,e.uom),this}rev(){return this.isMutable()?(this.a=+this.a,this.x=+this.x,this):D(this.clone().rev())}quaditude(){return this.isMutable()?(this.a=this.quaditudeNoUnits(),this.x=0,this.uom=V.mul(this.uom,this.uom),this):D(this.clone().quaditude())}quaditudeNoUnits(){const t=this.a,e=this.x;return t*t+e*e}subScalar(t,e,s=1){return this.isLocked()?D(this.clone().subScalar(t,e,s)):this.isZero()?(this.a=-t*s,this.uom=e,this):(0===t||0===s||(this.a-=t*s,this.uom=V.compatible(this.uom,e)),this)}scp(t){return this.isLocked()?D(this.clone().scp(t)):this.scp2(this,t)}scp2(t,e){const s=t.a,i=t.x,r=s*e.a+i*e.x;return this.a=r,this.x=0,this.uom=V.mul(t.uom,e.uom),this}sqrt(){return this.isLocked()?this.clone().sqrt().permlock():(this.a=Math.sqrt(this.a),this.x=0,this.uom=V.sqrt(this.uom),this)}squaredNorm(){return this.isMutable()?(this.a=this.quaditudeNoUnits(),this.x=0,this.uom=V.mul(this.uom,this.uom),this):D(this.clone().quaditude())}subVector(t,e=1){if(this.isLocked())return D(this.clone().subVector(t,e));if(this.isZero())this.uom=t.uom;else{if(0===t.x)return this;this.uom=V.compatible(this.uom,t.uom)}return this.x-=t.x*e,this}divByScalar(t,e){return this.isLocked()?D(this.clone().divByScalar(t,e)):(this.uom=V.div(this.uom,e),this.a/=t,this.x/=t,this)}scale(t){return this.isMutable()?(this.a=this.a*t,this.x=this.x*t,this):D(P(this).scale(t))}reflect(t){if(this.isLocked())return D(this.clone().reflect(t));{const e=t.x,s=t.uom,i=this.a,r=this.x,o=this.uom,n=e*e,h=n,a=n;return this.a=-a*i,this.x=-h*r,this.uom=V.mul(s,V.mul(o,s)),this}}rotate(t){if(this.isLocked())return D(this.clone().rotate(t));{V.assertDimensionless(t.uom);const e=this.a,s=this.x,i=t.a,r=i*i,o=r,n=r;return this.a=n*e,this.x=o*s,this}}sub(t,e=1){if(this.isLocked())return D(this.clone().sub(t,e));if(this.isZero())this.a=-t.a*e,this.x=-t.x*e,this.uom=t.uom;else{if(t.isZero())return this;this.a-=t.a*e,this.x-=t.x*e,this.uom=V.compatible(this.uom,t.uom)}return this}toExponential(t){return F(U(this),(function(e){return e.toExponential(t)}),X,this.uom)}toFixed(t){return F(U(this),(function(e){return e.toFixed(t)}),X,this.uom)}toLaTeX(t){return F(U(this),(function(e){return e.toString(t)}),Y,this.uom)}toPrecision(t){return F(U(this),(function(e){return e.toPrecision(t)}),X,this.uom)}toString(t){return F(U(this),(function(e){return e.toString(t)}),X,this.uom)}zero(){return this.isMutable()?(this.a=0,this.x=0,this.uom=V.ONE,this):D(P(this).zero())}__div__(t){return t instanceof H?D(this.clone().div(t)):"number"==typeof t?D(this.clone().divByNumber(t)):t instanceof V?D(this.clone().divByScalar(1,t)):void 0}divByNumber(t){return this.isLocked()?D(this.clone().divByNumber(t)):(this.a/=t,this.x/=t,this)}__rdiv__(t){return t instanceof H?D(P(t).div(this)):"number"==typeof t?D(H.scalar(t,void 0).div(this)):void 0}__vbar__(t){return t instanceof H?D(P(this).scp(t)):"number"==typeof t?D(P(this).scp(H.scalar(t))):void 0}__rvbar__(t){return t instanceof H?D(P(t).scp(this)):"number"==typeof t?D(H.scalar(t).scp(this)):void 0}__wedge__(t){return t instanceof H?D(P(this).ext(t)):"number"==typeof t?D(P(this).mulByNumber(t)):void 0}__rwedge__(t){return t instanceof H?D(P(t).ext(this)):"number"==typeof t?D(P(this).mulByNumber(t)):void 0}__lshift__(t){return t instanceof H?D(P(this).lco(t)):"number"==typeof t?D(P(this).lco(H.scalar(t))):void 0}__rlshift__(t){return t instanceof H?D(P(t).lco(this)):"number"==typeof t?D(H.scalar(t).lco(this)):void 0}__rshift__(t){return t instanceof H?D(P(this).rco(t)):"number"==typeof t?D(P(this).rco(H.scalar(t))):void 0}__rrshift__(t){return t instanceof H?D(P(t).rco(this)):"number"==typeof t?D(H.scalar(t).rco(this)):void 0}__bang__(){return D(P(this).inv())}inv(){if(this.isLocked())return D(this.clone().inv());{const t=this.a,e=this.x,s=$([[t,e],[e,t]],[1,0]);return this.a=s[0],this.x=s[1],this.uom=V.inv(this.uom),this}}__eq__(t){return t instanceof H?this.equals(t):"number"==typeof t?this.equals(H.scalar(t)):t instanceof V&&this.equals(H.scalar(1,t))}__ne__(t){return t instanceof H?!this.equals(t):"number"==typeof t?!this.equals(H.scalar(t)):!(t instanceof V&&this.equals(H.scalar(1,t)))}__tilde__(){return D(P(this).rev())}__add__(t){return t instanceof H?D(this.clone().add(t)):"number"==typeof t?D(this.clone().addScalar(t,void 0,1)):t instanceof V?D(this.clone().addScalar(1,t,1)):void 0}__radd__(t){return t instanceof H?D(P(t).add(this)):"number"==typeof t?D(H.scalar(t).add(this)):t instanceof V?D(H.scalar(1,t).add(this)):void 0}__sub__(t){return t instanceof H?D(this.clone().sub(t)):"number"==typeof t?D(this.clone().subScalar(t,void 0,1)):t instanceof V?D(this.clone().subScalar(1,t,1)):void 0}__rsub__(t){return t instanceof H?D(P(t).sub(this)):"number"==typeof t?D(H.scalar(t).sub(this)):void 0}__pos__(){return D(P(this))}__neg__(){return D(P(this).neg())}neg(){return this.isLocked()?D(this.clone().neg()):(this.a=-this.a,this.x=-this.x,this)}isZero(){return 0===this.coords[q]&&0===this.coords[G]}__mul__(t){return t instanceof H?D(this.clone().mul(t)):"number"==typeof t?D(this.clone().mulByNumber(t)):t instanceof V?D(this.clone().mulByScalar(1,t)):void 0}__rmul__(t){return t instanceof H?D(P(t).mul(this)):"number"==typeof t?D(P(this).mulByNumber(t)):void 0}mulByScalar(t,e){return this.isLocked()?D(this.clone().mulByScalar(t,e)):(this.a*=t,this.x*=t,this.uom=V.mul(this.uom,e),this)}get a(){return this.coords[q]}set a(t){if(!this.isMutable())throw new Error(E("a").message);this.coords[q]=t}get x(){return this.coords[G]}set x(t){if(!this.isMutable())throw new Error(E("x").message);this.coords[G]=t}get b(){return this.coords[G]}set b(t){if(!this.isMutable())throw new Error(E("b").message);this.coords[G]=t}}function W(t){return"number"==typeof t}function Q(){return"be a `number`"}function Z(t,e,s){return y(t,W(e),Q,s),e}function J(t){return f("name",t),{get message(){return`'${t}' method is not yet implemented.`}}}function K(t,e){let s=0;const i=t.length;for(let e=0;e<i;e++)s=Math.max(s,Math.abs(t[e]));const r=s*Math.pow(10,-e);for(let e=0;e<i;e++)Math.abs(t[e])<r&&(t[e]=0)}function j(t){return 0===t.x&&0===t.y}function tt(t){return j(t)&&function(t){return 0===t.xy}(t)&&0===t.a&&0===t.b}function et(t){const e=t.x,s=t.y;return e*e+s*s}const st=Math.sqrt,it=["1","e1","e2","e12"];it[0]="1",it[1]="e1",it[2]="e2",it[3]="e12";const rt=["1","e_{1}","e_{2}","I"];rt[0]="1",rt[1]="e_{1}",rt[2]="e_{2}",rt[3]="I";const ot=function(t){const e=[0,0,0,0];return e[0]=t,e},nt=function(t,e){const s=[0,0,0,0];return s[1]=t,s[2]=e,s},ht=function(t,e){const s=[0,0,0,0];return s[0]=t,s[3]=e,s},at=function(t){const e=[0,0,0,0];return e[0]=t.a,e[1]=t.x,e[2]=t.y,e[3]=t.b,e};function ut(t){return 0===t.x&&0===t.y&&0===t.b}function ct(t){return t.lock(),t}class mt extends b{static scalar(t,e){return new mt(ot(t),e)}static bivector(t,e){return mt.spinor(0,t,e)}static spinor(t,e,s){return new mt(ht(t,e),s)}static vector(t,e,s){const i=()=>"Geometric2.vector(x: number, y: number, uom?: Unit): Geometric2";return Z("x",t,i),Z("y",e,i),new mt(nt(t,e),s)}static copy(t){return new mt(at(t),t.uom)}static fromBivector(t){return new mt(function(t){const e=[0,0,0,0];return e[3]=t,e}(t.xy),t.uom)}static fromScalar(t){return new mt(ot(t.a),t.uom)}static fromSpinor(t){return new mt(ht(t.a,t.xy),t.uom)}static fromVector(t){return new mt(nt(t.x,t.y),t.uom)}static rotorFromDirections(t,e){return new mt([0,0,0,0]).rotorFromDirections(t,e)}static rotorFromVectorToVector(t,e){return new mt([0,0,0,0]).rotorFromVectorToVector(t,e)}static zero=ct(new mt([0,0,0,0],void 0));static one=ct(new mt(ot(1),void 0));static e1=ct(new mt(nt(1,0),void 0));static e2=ct(new mt(nt(0,1),void 0));static I=ct(new mt(function(t){const e=[0,0,0,0];return e[3]=1,e}(),void 0));static meter=ct(new mt(ot(1),V.METER));static kilogram=ct(new mt(ot(1),V.KILOGRAM));static second=ct(new mt(ot(1),V.SECOND));static ampere=ct(new mt(ot(1),V.AMPERE));static kelvin=ct(new mt(ot(1),V.KELVIN));static mole=ct(new mt(ot(1),V.MOLE));static candela=ct(new mt(ot(1),V.CANDELA));static coulomb=ct(new mt(ot(1),V.COULOMB));static newton=ct(new mt(ot(1),V.NEWTON));static joule=ct(new mt(ot(1),V.JOULE));coords_;constructor(t=[0,0,0,0],e){if(super(e),4!==t.length)throw new Error("coords.length must be 4");this.coords_=t}scale(t){return this.mulByNumber(t)}__div__(t){return t instanceof mt?ct(this.clone().div(t)):"number"==typeof t?ct(this.clone().divByNumber(t)):t instanceof V?ct(this.clone().divByScalar(1,t)):void 0}__rdiv__(t){return t instanceof mt?ct(mt.copy(t).div(this)):"number"==typeof t?ct(mt.scalar(t,void 0).div(this)):void 0}__vbar__(t){return t instanceof mt?ct(mt.copy(this).scp(t)):"number"==typeof t?ct(mt.copy(this).scp(mt.scalar(t))):void 0}__rvbar__(t){return t instanceof mt?ct(mt.copy(t).scp(this)):"number"==typeof t?ct(mt.scalar(t).scp(this)):void 0}__wedge__(t){return t instanceof mt?ct(mt.copy(this).ext(t)):"number"==typeof t?ct(mt.copy(this).mulByNumber(t)):void 0}__rwedge__(t){return t instanceof mt?ct(mt.copy(t).ext(this)):"number"==typeof t?ct(mt.copy(this).mulByNumber(t)):void 0}__lshift__(t){return t instanceof mt?ct(mt.copy(this).lco(t)):"number"==typeof t?ct(mt.copy(this).lco(mt.scalar(t))):void 0}__rlshift__(t){return t instanceof mt?ct(mt.copy(t).lco(this)):"number"==typeof t?ct(mt.scalar(t).lco(this)):void 0}__rshift__(t){return t instanceof mt?ct(mt.copy(this).rco(t)):"number"==typeof t?ct(mt.copy(this).rco(mt.scalar(t))):void 0}__rrshift__(t){return t instanceof mt?ct(mt.copy(t).rco(this)):"number"==typeof t?ct(mt.scalar(t).rco(this)):void 0}__bang__(){return ct(mt.copy(this).inv())}__eq__(t){return t instanceof mt?this.equals(t):"number"==typeof t?this.equals(mt.scalar(t)):t instanceof V&&this.equals(mt.scalar(1,t))}__ne__(t){return t instanceof mt?!this.equals(t):"number"==typeof t?!this.equals(mt.scalar(t)):!(t instanceof V&&this.equals(mt.scalar(1,t)))}__tilde__(){return ct(mt.copy(this).rev())}__add__(t){return t instanceof mt?ct(this.clone().add(t)):"number"==typeof t?ct(this.clone().addScalar(t,void 0,1)):t instanceof V?ct(this.clone().addScalar(1,t,1)):void 0}__radd__(t){return t instanceof mt?ct(mt.copy(t).add(this)):"number"==typeof t?ct(mt.scalar(t).add(this)):t instanceof V?ct(mt.scalar(1,t).add(this)):void 0}__sub__(t){return t instanceof mt?ct(this.clone().sub(t)):"number"==typeof t?ct(this.clone().subScalar(t,void 0,1)):t instanceof V?ct(this.clone().subScalar(1,t,1)):void 0}__rsub__(t){return t instanceof mt?ct(mt.copy(t).sub(this)):"number"==typeof t?ct(mt.scalar(t).sub(this)):void 0}__pos__(){return ct(mt.copy(this))}__neg__(){return ct(mt.copy(this).neg())}__mul__(t){return t instanceof mt?ct(this.clone().mul(t)):"number"==typeof t?ct(this.clone().mulByNumber(t)):t instanceof V?ct(this.clone().mulByScalar(1,t)):void 0}__rmul__(t){return t instanceof mt?ct(mt.copy(t).mul(this)):"number"==typeof t?ct(mt.copy(this).mulByNumber(t)):void 0}add2(t,e){return tt(t)?this.uom=e.uom:tt(e)?this.uom=t.uom:this.uom=V.compatible(t.uom,e.uom),this.a=t.a+e.a,this.x=t.x+e.x,this.y=t.y+e.y,this.b=t.b+e.b,this}addPseudo(t,e){if(this.isLocked())return ct(this.clone().addPseudo(t,e));if(this.isZero())this.uom=e;else{if(0===t)return this;this.uom=V.compatible(this.uom,e)}return this.b+=t,this}addScalar(t,e,s=1){return this.isLocked()?ct(this.clone().addScalar(t,e,s)):this.isZero()?(this.a=t*s,this.uom=e,this):(0===t||0===s||(this.a+=t*s,this.uom=V.compatible(this.uom,e)),this)}approx(t){return this.isLocked()?ct(this.clone().approx(t)):(K(this.coords_,t),this)}conj(){return this.isLocked()?ct(this.clone().conj()):(this.x=-this.x,this.y=-this.y,this.b=-this.b,this)}copySpinor(t){const e=t.a,s=t.xy;return this.setCoordinate(0,e,"a"),this.setCoordinate(1,0,"x"),this.setCoordinate(2,0,"y"),this.setCoordinate(3,s,"b"),this.uom=t.uom,this}div(t){return this.isLocked()?ct(this.clone().div(t)):ut(t)?this.divByScalar(t.a,t.uom):this.mul(mt.copy(t).inv())}div2(t,e){throw new Error(J("div2").message)}divByNumber(t){return this.isLocked()?ct(this.clone().divByNumber(t)):(this.a/=t,this.x/=t,this.y/=t,this.b/=t,this)}divByVector(t){if(this.isLocked())return ct(this.clone().divByVector(t));{const e=t.x,i=t.y;return this.mulByVector(t).divByScalar(e*e+i*i,V.pow(t.uom,s.valueOf(2,1)))}}dual(){if(this.isLocked())return this.clone().dual().permlock();{const t=this.b,e=-this.x,s=this.y,i=-this.a;return this.a=t,this.x=s,this.y=e,this.b=i,this}}equals(t){return t===this||t instanceof mt&&function(t,e){for(let s=0;s<4;s++)if(t[s]!==e[s])return!1;return!0}(this.coords_,t.coords_)&&V.isCompatible(this.uom,t.uom)}ext2(t,e){const s=t.a,i=t.x,r=t.y,o=t.b,n=e.a,h=e.x,a=e.y,u=e.b;return this.a=s*n,this.x=s*h+i*n,this.y=s*a+r*n,this.b=s*u+i*a-r*h+o*n,this.uom=V.mul(this.uom,e.uom),this}grade(t){if(this.isLocked())return ct(this.clone().grade(t));switch(t){case 0:this.x=0,this.y=0,this.b=0;break;case 1:this.a=0,this.b=0;break;case 2:this.a=0,this.x=0,this.y=0;break;default:this.a=0,this.x=0,this.y=0,this.b=0}return this}I(){return this.a=0,this.x=0,this.y=0,this.b=1,this.uom=void 0,this}lco(t){return this.isLocked()?ct(this.clone().lco(t)):this.lco2(this,t)}lco2(t,e){const s=t.a,i=t.x,r=t.y,o=t.b,n=e.a,h=e.x,a=e.y,u=e.b;return this.a=s*n+i*h+r*a-o*u,this.x=s*h-r*u,this.y=s*a+i*u,this.b=s*u,this.uom=V.mul(this.uom,e.uom),this}one(){return this.a=1,this.x=0,this.y=0,this.b=0,this.uom=void 0,this}rco(t){return this.isLocked()?ct(this.clone().rco(t)):this.rco2(this,t)}rco2(t,e){const s=t.a,i=t.x,r=t.y,o=t.b,n=e.a,h=e.x,a=e.y,u=e.b;return this.a=s*n+i*h+r*a-o*u,this.x=i*n+o*a,this.y=r*n-o*h,this.b=o*n,this.uom=V.mul(this.uom,e.uom),this}reflect(t){if(this.isLocked())return ct(this.clone().reflect(t));{const e=t.x,s=t.y,i=t.uom,r=this.a,o=this.x,n=this.y,h=this.b,a=this.uom,u=e*e,c=s*s,m=u-c,l=-2*e*s,d=u+c;return this.a=-d*r,this.x=l*n-m*o,this.y=l*o+m*n,this.b=d*h,this.uom=V.mul(i,V.mul(a,i)),this}}rotorFromDirections(t,e){return this.isLocked()?ct(this.clone().rotorFromDirections(t,e)):(function(t,e,s){const i=et(t),r=st(i),o=et(e),n=st(o)*r,h=function(t,e){return t.x*e.x+t.y*e.y}(e,t),a=st(2*(o*i+n*h));0!==a&&(s.versor(e,t),s.addScalar(n,void 0,1),s.divByScalar(a))}(t,e,this),this)}rotorFromFrameToFrame(t,e){throw new Error(J("rotorFromFrameToFrame").message)}rotorFromGeneratorAngle(t,e){throw new Error(J("rotorFromGeneratorAngle").message)}rotorFromVectorToVector(t,e){if(this.isLocked())return ct(this.clone().rotorFromVectorToVector(t,e));{const s=t.x,i=t.y,r=e.x,o=e.y,n=Math.sqrt(r*r+o*o),h=Math.sqrt(s*s+i*i),a=n*h,u=r*s+o*i,c=r*i-o*s,m=Math.sqrt(2*a*(a+u)),l=Math.sqrt(n)/(Math.sqrt(h)*m);return this.a=l*(a+u),this.x=0,this.y=0,this.b=l*c,this.uom=V.sqrt(V.div(e.uom,t.uom)),this}}sqrt(){return this.isLocked()?this.clone().sqrt().permlock():(this.a=Math.sqrt(this.a),this.x=0,this.y=0,this.b=0,this.uom=V.sqrt(this.uom),this)}squaredNorm(){return this.quaditude()}sub2(t,e){return tt(t)?(this.a=-e.a,this.x=-e.x,this.y=-e.y,this.b=-e.b,this.uom=e.uom):tt(e)?(this.a=t.a,this.x=t.x,this.y=t.y,this.b=t.b,this.uom=t.uom):(this.a=t.a-e.a,this.x=t.x-e.x,this.y=t.y-e.y,this.b=t.b-e.b,this.uom=V.compatible(t.uom,e.uom)),this}versor(t,e){return this.a=t.x*e.x+t.y*e.y,this.x=0,this.y=0,this.b=t.x*e.y-t.y*e.x,this.uom=V.mul(t.uom,e.uom),this}setCoordinate(t,e,s){if(!this.isMutable())throw new Error(E(s).message);{const s=this.coords_;e!==s[t]&&(s[t]=e)}}get a(){return this.coords_[0]}set a(t){this.setCoordinate(0,t,"a")}get b(){return this.coords_[3]}set b(t){this.setCoordinate(3,t,"b")}get xy(){return this.coords_[3]}set xy(t){this.setCoordinate(3,t,"xy")}get grades(){const t=this.coords_,e=t[0],s=t[1],i=t[2];let r=0;return 0!==e&&(r+=1),0===s&&0===i||(r+=2),0!==t[3]&&(r+=4),r}get x(){return this.coords_[1]}set x(t){this.setCoordinate(1,t,"x")}get y(){return this.coords_[2]}set y(t){this.setCoordinate(2,t,"y")}add(t,e=1){return this.isLocked()?ct(this.clone().add(t,e)):this.isZero()?(this.a=t.a*e,this.x=t.x*e,this.y=t.y*e,this.b=t.b*e,this.uom=t.uom,this):(tt(t)||(this.a+=t.a*e,this.x+=t.x*e,this.y+=t.y*e,this.b+=t.b*e,this.uom=V.compatible(this.uom,t.uom)),this)}addVector(t,e=1){if(this.isLocked())return ct(this.clone().addVector(t,e));if(this.isZero())this.uom=t.uom;else{if(j(t))return this;this.uom=V.compatible(this.uom,t.uom)}return this.x+=t.x*e,this.y+=t.y*e,this}clone(){return mt.copy(this)}copy(t){return this.a=t.a,this.x=t.x,this.y=t.y,this.b=t.b,this.uom=t.uom,this}copyBivector(t){const e=t.xy;return this.setCoordinate(0,0,"a"),this.setCoordinate(1,0,"x"),this.setCoordinate(2,0,"y"),this.setCoordinate(3,e,"b"),this.uom=t.uom,this}copyScalar(t,e){return this.setCoordinate(0,t,"a"),this.setCoordinate(1,0,"x"),this.setCoordinate(2,0,"y"),this.setCoordinate(3,0,"b"),this.uom=e,this}copyVector(t){const e=t.x,s=t.y;return this.setCoordinate(0,0,"a"),this.setCoordinate(1,e,"x"),this.setCoordinate(2,s,"y"),this.setCoordinate(3,0,"b"),this.uom=t.uom,this}direction(){if(this.isMutable()){const t=this.magnitudeNoUnits();return 0!==t&&(this.a=this.a/t,this.x=this.x/t,this.y=this.y/t,this.b=this.b/t),this.uom=void 0,this}return ct(this.clone().direction())}divByPseudo(t,e){if(this.isMutable()){const s=this.a,i=this.x,r=this.y,o=this.b;return this.a=o/t,this.x=r/t,this.y=-i/t,this.b=-s/t,this.uom=V.div(this.uom,e),this}return ct(this.clone().divByPseudo(t,e))}divByScalar(t,e){return this.isLocked()?ct(this.clone().divByScalar(t,e)):(this.uom=V.div(this.uom,e),this.a/=t,this.x/=t,this.y/=t,this.b/=t,this)}ext(t){if(this.isLocked())return ct(this.clone().ext(t));{const e=this.a,s=this.x,i=this.y,r=this.b,o=t.a,n=t.x,h=t.y,a=t.b;return this.a=e*o,this.x=e*n+s*o,this.y=e*h+i*o,this.b=e*a+s*h-i*n+r*o,this.uom=V.mul(this.uom,t.uom),this}}inv(){if(this.isLocked())return ct(this.clone().inv());{const t=this.a,e=this.x,s=this.y,i=this.b,r=$([[+t,+e,+s,-i],[+e,+t,-i,+s],[+s,+i,+t,-e],[+i,+s,-e,+t]],[1,0,0,0]);return this.a=r[0],this.x=r[1],this.y=r[2],this.b=r[3],this.uom=V.inv(this.uom),this}}isBivector(){return 0===this.a&&0===this.x&&0===this.y}isOne(){return!!V.isOne(this.uom)&&1===this.a&&0===this.x&&0===this.y&&0===this.b}isScalar(){return ut(this)}isSpinor(){return!!V.isOne(this.uom)&&0===this.x&&0===this.y}isVector(){return 0===this.a&&0===this.b}isZero(){return 0===this.a&&0===this.x&&0===this.y&&0===this.b}magnitude(){return this.isMutable()?(this.a=this.magnitudeNoUnits(),this.x=0,this.y=0,this.b=0,this):ct(this.clone().magnitude())}magnitudeNoUnits(){return Math.sqrt(this.quaditudeNoUnits())}mul(t){return this.isLocked()?ct(this.clone().mul(t)):this.mul2(this,t)}mul2(t,e){const s=t.a,i=t.x,r=t.y,o=t.b,n=e.a,h=e.x,a=e.y,u=e.b;return this.a=s*n+i*h+r*a-o*u,this.x=s*h+i*n-r*u+o*a,this.y=s*a+i*u+r*n-o*h,this.b=s*u+i*a-r*h+o*n,this.uom=V.mul(this.uom,e.uom),this}mulByBivector(t){if(this.isLocked())return ct(this.clone().mulByBivector(t));{this.uom=V.mul(this.uom,t.uom);const e=this.a,s=this.x,i=this.y,r=this.b,o=t.xy;return this.a=-r*o,this.x=-i*o,this.y=+s*o,this.b=e*o,this}}mulByNumber(t){return this.isLocked()?ct(this.clone().mulByNumber(t)):(this.a*=t,this.x*=t,this.y*=t,this.b*=t,this)}mulByScalar(t,e){return this.isLocked()?ct(this.clone().mulByScalar(t,e)):(this.a*=t,this.x*=t,this.y*=t,this.b*=t,this.uom=V.mul(this.uom,e),this)}mulByVector(t){if(this.isLocked())return ct(this.clone().mulByVector(t));{this.uom=V.mul(this.uom,t.uom);const e=this.a,s=this.x,i=this.y,r=this.xy,o=t.x,n=t.y;return this.a=s*o+i*n,this.x=e*o+r*n,this.y=e*n-r*o,this.b=s*n-i*o,this}}neg(){return this.isLocked()?ct(this.clone().neg()):(this.a=-this.a,this.x=-this.x,this.y=-this.y,this.b=-this.b,this)}quaditude(){return this.isMutable()?(this.a=this.quaditudeNoUnits(),this.x=0,this.y=0,this.b=0,this.uom=V.mul(this.uom,this.uom),this):ct(this.clone().quaditude())}rev(){return this.isMutable()?(this.a=+this.a,this.x=+this.x,this.y=+this.y,this.b=-this.b,this):ct(this.clone().rev())}rotate(t){if(this.isLocked())return ct(this.clone().rotate(t));{V.assertDimensionless(t.uom);const e=this.a,s=this.x,i=this.y,r=this.b,o=t.a,n=t.xy,h=o*o,a=n*n,u=h-a,c=2*o*n,m=h+a;return this.a=m*e,this.x=u*s+c*i,this.y=u*i-c*s,this.b=m*r,this}}scp(t){return this.isLocked()?ct(this.clone().scp(t)):this.scp2(this,t)}scp2(t,e){const s=t.a,i=t.x,r=t.y,o=t.b,n=s*e.a+i*e.x+r*e.y-o*e.b;return this.a=n,this.x=0,this.y=0,this.b=0,this.uom=V.mul(t.uom,e.uom),this}quaditudeNoUnits(){const t=this.a,e=this.x,s=this.y,i=this.b;return t*t+e*e+s*s+i*i}sub(t,e=1){if(this.isLocked())return ct(this.clone().sub(t,e));if(this.isZero())this.uom=t.uom;else{if(tt(t))return this;this.uom=V.compatible(this.uom,t.uom)}return this.a-=t.a*e,this.x-=t.x*e,this.y-=t.y*e,this.b-=t.b*e,this}subScalar(t,e,s=1){return this.isLocked()?ct(this.clone().subScalar(t,e,s)):this.isZero()?(this.a=-t*s,this.uom=e,this):(0===t||0===s||(this.a-=t*s,this.uom=V.compatible(this.uom,e)),this)}subVector(t,e=1){if(this.isLocked())return ct(this.clone().subVector(t,e));if(this.isZero())this.uom=t.uom;else{if(j(t