wordplaydev / wordplay

An accessible, language-inclusive programming language and IDE for creating interactive typography on the web.
Other
62 stars 30 forks source link

Add missing unit conversions #363

Open amyjko opened 8 months ago

amyjko commented 8 months ago

What's the problem?

Number values have numerous pre-defined unit conversions for time, distance, and mass (see definitions in NumberBasis.ts. However, there are number of other scientific units (e.g., current, temperature, light intensity), as well as many other commonly used units, like cooking units such as fluid volume and quantities (e.g., dozen). It is possible to define custom conversions, but in most cases, any common unit someone tries should just work and be correct.

What's the design idea?

Create a fairly complete list of units and define them for numbers.

Who benefits?

Anyone doing unit arithmetic on common units.

Design specification

(This section should be included after a design proposal is ready and approved, and the buildable tag is added. This text can remain until then. Designers should add their proposal here, not in a comment).

Draft 1: list of missing conversions

Time

M2h: divide by 3600 (1 hour = 3600 seconds) H2day: divide by 24 (1 day = 24 hours) Day2wk: divide by 7 (1 week = 7 days) Wk2year: divide by 52 (1 year = 52 weeks)

Temp (Celsius and Fahrenheit)

c2f: multiply by 9/5 and add 32 f2c: subtract 32 and then multiply by 5/9

Volume (Milliliters, Liters, Gallons, Fluid ounces)

mL2L: divide by 1000 (1 liter = 1000 milliliters) L2gal: multiply by 0.219969 (1 gallon ≈ 4.54609 liters) mL2floz: divide by 28.4131 (1 fluid ounce ≈ 28.4131 milliliters)

Quantities (Dozen, Units, Score, Million, Billion

u2doz: divide by 12 (1 dozen = 12 units) u2scr: divide by 20 (1 score = 20 units) u2M: divide by 1,000,000 (1 million = 1,000,000 units) u2B: divide by 1,000,000,000 (1 billion = 1,000,000,000 units)

Second Draft

Temp (Celsius and Fahrenheit)

c2f: multiply by 9/5 and add 32 f2c: subtract 32 and then multiply by 5/9

Volume (Milliliters, Liters, Gallons, Fluid ounces)

mL2L: divide by 1000 (1 liter = 1000 milliliters) L2gal: multiply by 0.219969 (1 gallon = 4.54609 liters) mL2floz: divide by 28.4131 (1 fluid ounce = 28.4131 milliliters)

Quantities (Dozen, Units, Score, Million, Billion

doz: divide by 12 (1 dozen = 12) scr: divide by 20 (1 score = 20) M: divide by 1,000,000 (1 million = 1,000,000) B: divide by 1,000,000,000 (1 billion = 1,000,000,000)

Light intensity

fc2lux: multiply by 10.764 (1 foot-candle = 10.7639 lux)

Currents

A2mA: multiply by 1000 (1 ampere = 1000 Miliampere)

Pressure

kPa2Pa: multiply by 1000 (1 Kilopascal = Pascal) Pa2atm: multiply by 9.86923e-6 (1 Pascal = 9 9.86923e-6 Standard atmosphere) psi2Pa: multiply by 6895 (1 Pound-force per square inch = 6894.76 Pascal)

Energy

kJ2J: multiply by 1000 (1 kilojoule = 1000 Joule) cal2J: multiply by 4.184 (1 calorie = 1 Joule)

Power

kW2W: multiply by 1000 (1 kilowatt = 1000 Watts) hp2W: multiply by 445.7 (1 horsepower = 745.7 Watts)

Superme-Abdiwahid commented 7 months ago

@amyjko Below is a sample of our design for possible unit conversation we would like your feedback on our proposed design sketch. Its a bunch units and what they would stand for. IMG_3504 (1)

IMG_3505 (1)

amyjko commented 7 months ago

Thanks @Superme-Abdiwahid! A few comments:

I hope that gives you a good start on your next iteration!

amyjko commented 6 months ago

It's the end of Winter! Please provide an update on this issue, including:

If you do plan to continue work on it, carry on. Otherwise, thank you for your contributions!

amyjko commented 6 months ago

No reply :( Unassigning @Superme-Abdiwahid and @sammyseb.

jessica5m commented 4 months ago

@amyjko Ready for review on my first draft of conversions, I'll be working on light-intensity conversions in the meantime:)

amyjko commented 4 months ago

@jessica5m These are good progress! A few comments:

jessica5m commented 4 months ago

@amyjko ready to review the second draft of conversions

amyjko commented 4 months ago

These look like great extensions; design approved.

@jessica5m, will you be continuing work on this, or are you done? Please unassign yourself if you are done.

jessica5m commented 4 months ago

I am done working and will be unassigning myself:)