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 (nf-option :system-of-units) is used to determine the units in which the output is printed. There are pre-defined several systems of units, si, english, cgs:

     ANTIK-USER> (defparameter *length1* #_10_m)
     ANTIK-USER> *length1*
     ANTIK-USER> (set-system-of-units :english)
     ; No value
     ANTIK-USER> *length1*

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

     ANTIK-USER> (set-system-of-units :si)
     ; No value
     ANTIK-USER> #_12_feet
     ANTIK-USER> (set-system-of-units :english)
     ANTIK-USER> #_3_m

A new system of units may be defined with define-system-of-units. 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 augmentation 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-system-of-units kmdeg (km degree) si)

The SI system is the initial system of units.

— Macro: antik:define-system-of-units system-name units &optional augemented-system

Define a system of units with the given name and units, possibly by augmenting the named system of units.

— Function: antik:set-system-of-units system-of-units &rest units

Set the default system of units to the specified system.

— Macro: antik:with-system-of-units (system-of-units &rest units) &body body

When executing the body, change the system of units by naming the units. If system-of-units is non-nil, augment that system with the specified units; if it is t, augment the current system of units.

— Macro: antik:with-si-units &body body

Use the si system of units in the body.