\ cora.fs -- Cora Phyco package of conversion ratios and physical constants
\ Version 0
\ 2005/9/9 David Meyer

\ Cora Phyco provides a Forth environment to facilitate conversion of
\ quantities among a large variety of measurement units and systems.
\ Inspired by Frink by Allan Eliasen.
\ This version is a simple implementation providing Forth constants
\ for conversion and physical quantities and a few words to simplify
\ display and conversion.

( Loading Cora Phyco version 0 ... )

\ Display quantity r1 of units r2 in standard unit amount
: mks  ( r1 r2 -- )  F* F. ;

\ Convert quantity r1 from r2 units to r3 units and display
: ->  ( r1 r2 r3 -- )  F/ F* F. ;

\ Convert quantity r1 from r2 units to r3 units and display
\ in engineering notation
: ->e  ( r1 r2 r3 -- )  F/ F* FE. ;

\ Speed (standard unit: m/s (meters per second)

1e0             FCONSTANT  m/s  \ meters per second (standard)

331.46e0        FCONSTANT  mach \ speed of sound in dry air at STP

299792458e0     FCONSTANT  c    \ light in vacuum

\ Acceleration (standard unit: m/s^2 (meters per second per second)

1e0             FCONSTANT  m/s^2        \ meters per second per second (standard)

980665e-5       FCONSTANT  gee  \ standard gravitational acceleration

\ Time (standard unit: s (second))

1e0             FCONSTANT  s    \ second (standard)
60e0 60e0 F*    FCONSTANT  hr   \ hour
24e0 hr F*      FCONSTANT  day  \ day

\ Angular measure (standard unit: radian (dimensionless))

2e0 pi F*       FCONSTANT  circle
circle 360e0 F/ FCONSTANT  deg  \ degree
deg 60e0 F/     FCONSTANT  amin \ arc minute
amin 60e0 F/    FCONSTANT  asec \ arc second

\ Linear measure (standard unit: m (meter))

1e0             FCONSTANT  m    \ meter (standard)
1e3             FCONSTANT  km   \ kilometer
1e-2            FCONSTANT  cm   \ centimeter
1e-3            FCONSTANT  mm   \ millimeter

3048e-4         FCONSTANT  ft   \ foot
ft 12e0 F/      FCONSTANT  in   \ inch
3e0 ft F*       FCONSTANT  yd   \ yard
5280e0 ft F*    FCONSTANT  mi   \ mile
1852e0          FCONSTANT  nmi  \ nautical mile

149597870691e0  FCONSTANT  au   \ astronomical unit
365.25e0 day F* c F*    FCONSTANT  ly   \ light year
au asec F/      FCONSTANT  pc   \ parsec

\ Area (standard unit: m^2 (square meter))

1e0             FCONSTANT  m^2  \ square meter (standard)
ft ft F*        FCONSTANT  ft^2 \ square feet
43560e0 ft^2 F* FCONSTANT  acre \ acre
1e2             FCONSTANT  are  \ are
1e4             FCONSTANT  hectare      \ hectare

\ Volume (standard unit: m^3 (cubic meter))

1e0             FCONSTANT  m^3  \ cubic meter (standard)
1e-6            FCONSTANT  cc   \ cubic centimeter
in in in F* F*  FCONSTANT  in^3 \ cubic inch
231e0 in^3 F*   FCONSTANT  gal  \ gallon
gal 4e0 F/      FCONSTANT  qt   \ quart
qt 2e0 F/       FCONSTANT  pt   \ pint
pt 16e0 F/      FCONSTANT  floz \ fluid ounce
42e0 gal F*     FCONSTANT  bbl  \ petroleum barrel
8e0 floz F*     FCONSTANT  cup  \ cup
cup 16e0 F/     FCONSTANT  tbsp \ tablespoon
tbsp 3e0 F/     FCONSTANT  tsp  \ teaspoon
1e3 cc F*       FCONSTANT  l    \ liter
cc              FCONSTANT  ml   \ milliliter

\ Mass (standard unit: kg (kilogram))

1e0             FCONSTANT  kg   \ kilogram (standard)
1e-3            FCONSTANT  g    \ gram
1e3             FCONSTANT  mt   \ tonne, metric ton

45359237e-8     FCONSTANT  lb   \ pound
2e3 lb F*       FCONSTANT  t    \ ton
lb 16e0 F/      FCONSTANT  oz   \ ounce

( done) cr