Files
mp-units/docs/framework/basic_concepts.rst
T

118 lines
3.8 KiB
ReStructuredText
Raw Normal View History

2020-03-09 18:55:41 +01:00
.. namespace:: units
Basic Concepts
==============
The most important concepts in the library are `Unit`, `Dimension`,
2021-01-04 18:36:26 -04:00
`Quantity`, `QuantityPoint`, `QuantityKind`, and `QuantityPointKind`:
2020-03-09 18:55:41 +01:00
.. raw:: html
<object data="../_images/concepts.svg" type="image/svg+xml" class="align-center" style="max-width: 100%;"></object>
2020-03-09 18:55:41 +01:00
..
https://www.planttext.com
@startuml
2020-03-11 12:33:05 +01:00
skinparam monochrome true
skinparam shadowing false
skinparam backgroundColor #fcfcfc
2020-03-11 12:33:05 +01:00
hide circle
hide members
show class methods
2021-01-04 18:36:26 -04:00
package Unit <<Frame>> [[../../framework/units.html]] {
}
2020-03-11 12:33:05 +01:00
package Dimension <<Frame>> [[../../framework/dimensions.html]] {
}
2021-01-04 18:36:26 -04:00
2021-10-20 11:21:58 +02:00
package Kind <<Frame>> [[../../framework/quantity_kinds.html#kind-creation]] {
abstract kind<Dimension> [[../../framework/quantity_kinds.html#kind-creation]]
2021-10-20 11:21:58 +02:00
}
2021-01-04 18:36:26 -04:00
2021-10-20 11:21:58 +02:00
package PointKind <<Frame>> [[../../framework/quantity_kinds.html#quantity-point-kinds]] {
abstract point_kind<Kind, PointOrigin> [[../../framework/quantity_kinds.html#quantity-point-kinds]]
}
package PointOrigin <<Frame>> [[../../framework/quantity_points.html#point-origins]] {
abstract point_origin<Dimension> [[../../framework/quantity_points.html#point-origins]]
}
package Quantity <<Frame>> [[../../framework/quantities.html]] {
class quantity<Dimension, Unit, Rep> [[../../framework/quantities.html#construction]] {
rep number()
}
2021-10-20 11:21:58 +02:00
}
package QuantityPoint <<Frame>> [[../../framework/quantity_points.html]] {
class quantity_point<PointOrigin, Unit, Rep> [[../../framework/quantity_points.html#construction]] {
quantity relative()
}
2021-10-20 11:21:58 +02:00
}
package QuantityKind <<Frame>> [[../../framework/quantity_kinds.html]] {
class quantity_kind<Kind, Unit, Rep> [[../../framework/quantity_kinds.html#construction]] {
quantity common()
}
2021-10-20 11:21:58 +02:00
}
package QuantityPointKind <<Frame>> [[../../framework/quantity_kinds.html#quantity-point-kinds]] {
class quantity_point_kind<PointKind, Unit, Rep> [[../../framework/quantity_kinds.html#quantity-point-kinds]] {
quantity_kind relative()
}
2021-10-20 11:21:58 +02:00
}
2020-03-11 12:33:05 +01:00
Unit <.. Dimension
2021-01-04 18:36:26 -04:00
2021-10-20 11:21:58 +02:00
Dimension <... Quantity
Unit <... Quantity
2021-10-20 11:21:58 +02:00
Dimension <... Kind
Dimension <... PointOrigin
PointOrigin <... PointKind
Kind <... PointKind
2021-10-20 11:21:58 +02:00
Unit <... QuantityPoint
PointOrigin <... QuantityPoint
quantity --* quantity_point
2021-10-20 11:21:58 +02:00
Unit <... QuantityKind
Kind <... QuantityKind
quantity --* quantity_kind
2021-10-20 11:21:58 +02:00
Unit <... QuantityPointKind
PointKind <... QuantityPointKind
quantity_kind --* quantity_point_kind
@enduml
2021-01-04 18:36:26 -04:00
2020-03-09 18:55:41 +01:00
`Unit` is a basic building block of the library. Every dimension works with
a concrete hierarchy of units. Such hierarchy defines a reference unit and
2021-03-05 11:31:46 +01:00
often a few scaled versions of it. Examples: ``second``, ``metre``, ``kilometre_per_hour``.
2020-03-09 18:55:41 +01:00
`Dimension` concept matches a dimension of either a base or derived quantity.
`base_dimension` is instantiated with a unique symbol identifier and a base
unit. `derived_dimension` is a list of exponents of either base or other
2021-03-05 11:31:46 +01:00
derived dimensions. Examples: ``si::dim_time``, ``si::dim_length``, ``si::dim_speed``.
2020-03-09 18:55:41 +01:00
`Quantity` is a concrete amount of a unit for a specified dimension with a
2021-03-05 11:31:46 +01:00
specific representation. Examples: ``quantity<si::dim_time, si::second, int>``,
``si::length<si::metre, int>``, ``si::speed<si::kilometre_per_hour>``.
`QuantityPoint` is an absolute `Quantity` with respect to an origin.
2021-03-05 11:31:46 +01:00
Examples: timestamp (as opposed to duration), absolute temperature
(as opposed to temperature difference).
2021-01-04 18:36:26 -04:00
2021-03-05 11:31:46 +01:00
`QuantityKind` is a `Quantity` with more specific usage. Examples:
distance (``horizonal_kind``) and height (``vertical_kind``) are different kinds
of a length quantity.
2021-01-04 18:36:26 -04:00
`QuantityPointKind` is an absolute `QuantityKind` with respect to an origin.
2021-03-05 11:31:46 +01:00
Examples: altitude is a quantity point of ``vertical_kind`` (as opposed to
height).