|
|
|
@@ -75,6 +75,42 @@ let ratioInfo; |
|
|
|
|
|
|
|
//#region units |
|
|
|
|
|
|
|
function dimsEqual(unit1, unit2) { |
|
|
|
a = unit1.dimensions; |
|
|
|
b = unit2.dimensions; |
|
|
|
|
|
|
|
if (a.length != b.length) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
for (let i = 0; i < a.length && i < b.length; i++) { |
|
|
|
if (a[i] != b[i]) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// Determines if a unit is one of a length, area, volume, mass, or energy |
|
|
|
function typeOfUnit(unit) { |
|
|
|
if (dimsEqual(unit, math.unit(1, "meters"))) { |
|
|
|
return "length" |
|
|
|
} |
|
|
|
if (dimsEqual(unit, math.unit(1, "meters^2"))) { |
|
|
|
return "area" |
|
|
|
} |
|
|
|
if (dimsEqual(unit, math.unit(1, "meters^3"))) { |
|
|
|
return "volume" |
|
|
|
} |
|
|
|
if (dimsEqual(unit, math.unit(1, "kilograms"))) { |
|
|
|
return "mass" |
|
|
|
} |
|
|
|
if (dimsEqual(unit, math.unit(1, "joules"))) { |
|
|
|
return "energy" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
math.createUnit({ |
|
|
|
ShoeSizeMensUS: { |
|
|
|
prefixes: "long", |
|
|
|
|