Skip to content

Commit

Permalink
Merge pull request #246 from Markos-Th09/cgs
Browse files Browse the repository at this point in the history
add the CGS units
  • Loading branch information
printfn authored Nov 10, 2023
2 parents f8ebee3 + 6f9e38a commit e6b8d2d
Showing 1 changed file with 46 additions and 11 deletions.
57 changes: 46 additions & 11 deletions core/src/units/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,36 @@ const COMMON_PHYSICAL_UNITS: &[UnitTuple] = &[
("light", "", "c", ""),
];

const CGS_UNITS: &[UnitTuple] = &[
("gal", "gals", "cm/s^2", "accerelation"),
("dyne", "dynes", "g*gal", "force"),
("erg", "ergs", "g*cm^2/s^2", "work, energy"),
("barye", "baryes", "g/(cm*s^2)", "pressure"),
("poise", "poises", "g/(cm*s)", ""),
("stokes", "", "cm^2/s", ""),
("kayser", "kaysers", "cm^-1", ""),
("biot", "biots", "10 amperes", ""),
("emu", "emus", "0.001 A m^2", ""),
("franklin", "franklins", "dyn^1/2*cm", ""),
("gauss", "", "10^-4 tesla", ""),
("maxwell", "maxwells", "10^-8 weber", ""),
("phot", "phots", "10000 lux", ""),
("stilb", "stilbs", "10000 candela/m^2", ""),
// abbrevations
("gallileo", "gallileos", "gal", ""),
("dyn", "dyns", "dyne", ""),
("Ba", "", "barye", ""),
("P", "", "poise", ""),
("St", "", "stokes", ""),
("K", "", "kayser", ""),
("Bi", "", "biot", ""),
("Fr", "", "franklin", ""),
("G", "", "gauss", ""),
("Mx", "", "maxwell", ""),
("ph", "", "phot", ""),
("P", "", "poise", ""),
];

const IMPERIAL_UNITS: &[UnitTuple] = &[
("inch", "inches", "2.54 cm", ""),
("mil", "mils", "1/1000 inch", ""),
Expand All @@ -516,12 +546,13 @@ const IMPERIAL_UNITS: &[UnitTuple] = &[
("yard", "yards", "l@3 ft", ""),
("mile", "miles", "l@5280 ft", ""),
("line", "lines", "1/12 inch", ""),
("rod", "", "5.5 yard", ""),
("pole", "", "rod", ""),
("perch", "", "rod", ""),
("furlong", "", "40 rod", ""),
("rod", "rods", "5.5 yard", ""),
("pole", "poles", "rod", ""),
("perch", "perches", "rod", ""),
("firkin", "firkins", "90 lb", ""),
("furlong", "furlongs", "40 rod", ""),
("statute_mile", "statute_miles", "mile", ""),
("league", "", "3 mile", ""),
("league", "leagues", "3 mile", ""),
("chain", "chains", "66 feet", ""),
("link", "links", "1/100 chain", ""),
("thou", "", "1/1000 inch", "thousandth of an inch"),
Expand All @@ -532,7 +563,7 @@ const IMPERIAL_UNITS: &[UnitTuple] = &[
("point", "points", "l@1/72 inch", ""),
("twip", "twips", "l@1/20 point", ""),
("poppyseed", "poppyseeds", "l@line", ""),
("pica", "", "l@12 points", ""),
("pica", "picas", "l@12 points", ""),
("barleycorn", "barleycorns", "l@4 poppyseed", ""),
("finger", "fingers", "l@63 points", ""),
("stick", "sticks", "l@2 inches", ""),
Expand All @@ -543,16 +574,16 @@ const IMPERIAL_UNITS: &[UnitTuple] = &[
("hand", "hands", "l@2 sticks", ""),
("shaftment", "shaftments", "l@2 palm", ""),
("cubit", "cubits", "l@2 span", ""),
("ell", "", "l@5 span", ""),
("skein", "", "l@96 ell", ""),
("spindle", "", "l@120 skein", ""),
("ell", "ells", "l@5 span", ""),
("skein", "skeins", "l@96 ell", ""),
("spindle", "spindles", "l@120 skein", ""),
("link", "links", "l@1/25 rod", ""),
("fathom", "fathoms", "l@2 yard", ""),
("shackle", "shackles", "l@15 yard", ""),
("pace", "paces", "l@5 shaftments", ""),
("step", "steps", "l@2 paces", ""),
("grade", "", "l@pace", ""),
("rope", "", "l@4 steps", ""),
("grade", "grades", "l@pace", ""),
("rope", "ropes", "l@4 steps", ""),
("ramsdens_chain", "", "l@5 rope", ""),
("roman_mile", "roman_miles", "l@50 ramsdens_chain", ""),
("gunters_chain", "gunters_chains", "l@4 rod", ""),
Expand Down Expand Up @@ -632,6 +663,9 @@ const IMPERIAL_ABBREVIATIONS: &[UnitTuple] = &[
("plf", "", "lb / foot", "pounds per linear foot"),
("lbf", "", "lb force", ""),
("psi", "", "pound force / inch^2", ""),
("fur", "furs", "furlong", ""),
("fir", "firs", "firkin", ""),
("ftn", "ftns", "fortnight", ""),
];

const NAUTICAL_UNITS: &[UnitTuple] = &[
Expand Down Expand Up @@ -703,6 +737,7 @@ pub(crate) const ALL_UNIT_DEFS: &[&[UnitTuple]] = &[
IMPERIAL_ABBREVIATIONS,
NAUTICAL_UNITS,
CURRENCIES,
CGS_UNITS,
];

const SHORT_PREFIXES: &[(&str, &str)] = &[
Expand Down

0 comments on commit e6b8d2d

Please sign in to comment.