Skip to content

Commit

Permalink
docs(units): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 16, 2023
1 parent 27cd71e commit 75e903b
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 15 deletions.
50 changes: 42 additions & 8 deletions packages/units/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ Another example using dimensionless units (here angles, arc second ⇒ radian) t
compute the distance of 10 arcsec on the earth surface (in meters):

```ts
const R = 6371000; // earth radius in meters
// earth radius in meters
// (also available as quantity EARTH_RADIUS, see section below)
const R = 6371000;

convert(10, "arcsec", "rad") * R;
// 308.87479623488537
Expand Down Expand Up @@ -502,6 +504,8 @@ convert(div(speedOfLight, quantity(2.4,"GHz")), "mm");
// 124.9135
```

Some examples using vector quantities:

```ts
// DIN A4 paper size (also available as preset)
const A4 = quantity([210, 297], "mm");
Expand Down Expand Up @@ -533,12 +537,42 @@ convert(mul(quantity(10, "mm"), quantity(2, "in")), "cm2")

The following constants are provided (more to come):

| Var name | Unit |
|---------------------------|----------------|
| `DIN_A0` ... `DIN_A8` | `["mm", "mm"]` |
| `SPEED_OF_LIGHT` | `"m/s"` |
| `SPEED_OF_SOUND_IN_AIR` | `"m/s"` |
| `SPEED_OF_SOUND_IN_WATER` | `"m/s"` |
| Var name | Unit | Comment |
|---------------------------|-------------------|------------------------|
| `DIN_A0` ... `DIN_A8` | 2d vector of `mm` | Paper sizes |
| `EARTH_GRAVITY` | `m/s` | |
| `EARTH_CIRCUMFERENCE` | `m` | |
| `EARTH_MASS` | `kg` | |
| `EARTH_RADIUS` | `m` | |
| `GRAVITATION` | `kg-1·m3·s-2` | Gravitational constant |
| `SPEED_OF_LIGHT` | `m/s` | |
| `SPEED_OF_SOUND_IN_AIR` | `m/s` | at 20 ℃ |
| `SPEED_OF_SOUND_IN_WATER` | `m/s` | at 20 ℃ |

Densities of selected materials:

| Var name | Unit |
|--------------|---------|
| `AIR` | `kg/m3` |
| `ALUMINIUM` | `kg/m3` |
| `CONCRETE` | `kg/m3` |
| `COPPER` | `kg/m3` |
| `DIAMOND` | `kg/m3` |
| `GLASS` | `kg/m3` |
| `GOLD` | `kg/m3` |
| `ICE` | `kg/m3` |
| `IRON` | `kg/m3` |
| `NYLON` | `kg/m3` |
| `PLASTIC` | `kg/m3` |
| `PLATINUM` | `kg/m3` |
| `SAND` | `kg/m3` |
| `SALT_WATER` | `kg/m3` |
| `SILICON` | `kg/m3` |
| `SILVER` | `kg/m3` |
| `STEEL` | `kg/m3` |
| `TITANIUM` | `kg/m3` |
| `WATER` | `kg/m3` |
| `WOOD` | `kg/m3` |

## Status

Expand Down Expand Up @@ -566,7 +600,7 @@ For Node.js REPL:
const units = await import("@thi.ng/units");
```

Package sizes (brotli'd, pre-treeshake): ESM: 4.05 KB
Package sizes (brotli'd, pre-treeshake): ESM: 4.37 KB

## Dependencies

Expand Down
48 changes: 41 additions & 7 deletions packages/units/tpl.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ Another example using dimensionless units (here angles, arc second ⇒ radian) t
compute the distance of 10 arcsec on the earth surface (in meters):

```ts
const R = 6371000; // earth radius in meters
// earth radius in meters
// (also available as quantity EARTH_RADIUS, see section below)
const R = 6371000;

convert(10, "arcsec", "rad") * R;
// 308.87479623488537
Expand Down Expand Up @@ -460,6 +462,8 @@ convert(div(speedOfLight, quantity(2.4,"GHz")), "mm");
// 124.9135
```

Some examples using vector quantities:

```ts
// DIN A4 paper size (also available as preset)
const A4 = quantity([210, 297], "mm");
Expand Down Expand Up @@ -491,12 +495,42 @@ convert(mul(quantity(10, "mm"), quantity(2, "in")), "cm2")

The following constants are provided (more to come):

| Var name | Unit |
|---------------------------|----------------|
| `DIN_A0` ... `DIN_A8` | `["mm", "mm"]` |
| `SPEED_OF_LIGHT` | `"m/s"` |
| `SPEED_OF_SOUND_IN_AIR` | `"m/s"` |
| `SPEED_OF_SOUND_IN_WATER` | `"m/s"` |
| Var name | Unit | Comment |
|---------------------------|-------------------|------------------------|
| `DIN_A0` ... `DIN_A8` | 2d vector of `mm` | Paper sizes |
| `EARTH_GRAVITY` | `m/s` | |
| `EARTH_CIRCUMFERENCE` | `m` | |
| `EARTH_MASS` | `kg` | |
| `EARTH_RADIUS` | `m` | |
| `GRAVITATION` | `kg-1·m3·s-2` | Gravitational constant |
| `SPEED_OF_LIGHT` | `m/s` | |
| `SPEED_OF_SOUND_IN_AIR` | `m/s` | at 20 ℃ |
| `SPEED_OF_SOUND_IN_WATER` | `m/s` | at 20 ℃ |

Densities of selected materials:

| Var name | Unit |
|--------------|---------|
| `AIR` | `kg/m3` |
| `ALUMINIUM` | `kg/m3` |
| `CONCRETE` | `kg/m3` |
| `COPPER` | `kg/m3` |
| `DIAMOND` | `kg/m3` |
| `GLASS` | `kg/m3` |
| `GOLD` | `kg/m3` |
| `ICE` | `kg/m3` |
| `IRON` | `kg/m3` |
| `NYLON` | `kg/m3` |
| `PLASTIC` | `kg/m3` |
| `PLATINUM` | `kg/m3` |
| `SAND` | `kg/m3` |
| `SALT_WATER` | `kg/m3` |
| `SILICON` | `kg/m3` |
| `SILVER` | `kg/m3` |
| `STEEL` | `kg/m3` |
| `TITANIUM` | `kg/m3` |
| `WATER` | `kg/m3` |
| `WOOD` | `kg/m3` |

{{meta.status}}

Expand Down

0 comments on commit 75e903b

Please sign in to comment.