Previous: Dimensions, Up: Physical dimension

#### 5.3.4 Systems of units

A system of units is a set of units, one for each of the physical dimensions that Antik can handle. A system of units is needed by Antik for printing output and in special cases for converting physical quantities that have a physical dimension defined (e.g. length), but no units. The system of units defined by `*system-of-units*` is used to determine the units in which the output is printed. There are pre-defined several systems of units, `*siu*`, `*englishu*`, `*cgsu*`:

```     ANTIK-USER> (defparameter *length1* #_10_m)
*LENGTH1*
ANTIK-USER> *length1*
#_10.000000000000000_m
ANTIK-USER> (setf *system-of-units* *englishu*)
(((1 0 0 0 0 0 0 0 0) . FOOT) ((0 0 0 0 0 0 0 0 1) . RADIAN)
((0 0 1 0 0 0 0 0 0) . SLUG) ((0 1 0 0 0 0 0 0 0) . SECOND)
((1 -2 1 0 0 0 0 0 0) . POUND-FORCE) ((2 -3 1 0 0 0 0 0 0) . HORSEPOWER)
((2 -2 1 0 0 0 0 0 0) . FOOT-POUND)
((-1 -2 1 0 0 0 0 0 0) . POUNDS-PER-SQUARE-INCH))
ANTIK-USER> *length1*
#_32.808398950131235_ft
```

So by setting the system of units, you can convert values as needed,

```     ANTIK-USER> (setf *system-of-units* *siu*)
ANTIK-USER> #_12_feet
#_3.657600000000000d0_m
ANTIK-USER> (setf *system-of-units* *englishu*)
ANTIK-USER> #_3_m
#_9.842519685039370d0_ft
```

A new system of units may be defined with `define-sysunits`. One need not define all physical dimensions, but if a unit is needed for a particular dimension and it's not defined, an error will be signalled. For convenience, a system of units may be defined by alteration of an existing system of units. For example, suppose that you wish to have a system of units that is like SI except that lengths are measured in km instead of meters. This will define such a system:

```     (define-sysunits *kmu* (km) *siu* "Kilometer system.")
```

To set the default system of units, use `set-default-sysunits`. To define a symbol macro to set a default system of units, use `setsys`. The SI system is the initial default system of units. It may be reset as the system of units with the symbol macro `si`.

For formatted output of angles, the units (degrees or radians) may be set with the nf option `:degrees`, so the system of units may be maintained whether degrees or radians are desired on output.

— Macro: antik:define-sysunits system-name units &optional base-sysunits docstring

Make a system of units with the given name and units, optionally agumenting the existing system of units base-sysunits.

— Function: antik:set-default-sysunits sysunits &rest additional-units

Set the default system of units to the specified system, possibly augmenting it with other units. additional-units may be `nil` to augment the current default system.

— Macro: antik:setsys symbol sysunits &rest additional-units

Set the symbol macro symbol to make the system of units sysunits default. additional-units may be useform{NIL} to augment the current default system.

— Variable: antik:*system-of-units*

Default system of units used by pqval.

— Variable: antik:*siu*

Systeme internationale system of units.

— Variable: antik:*englishu*

The English system of units.

— Variable: antik:*cgsu*

The `cgs` system of units.