dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
mechanics.hpp
Go to the documentation of this file.
1#pragma once
2
8
9#include <dimval/define.hpp>
10
11// -----------------------------------------------------------------------------
12// Acceleration
13// -----------------------------------------------------------------------------
14
15DIMVAL_DEFINE_UNIT(MeterPerSecondSquared,
16 "m_per_s2",
17 "m/s²",
18 "m/s²",
19 "meter per second squared",
20 "acceleration",
21 1.0,
22 ::comms::Icons::mdi::axis_arrow,
23 ::comms::Colors::mui::red[400],
24 static constexpr int default_precision = 3;)
25
26// 1 g₀ = 9.80665 m/s² exactly (CGPM 1901). The id is "g0" so the bare symbol
27// "g" stays free for a future Gram unit if mass-prefix aliases ever land.
28DIMVAL_DEFINE_UNIT(StandardGravity,
29 "g0",
30 "g₀",
31 "g₀",
32 "standard gravity",
33 "acceleration",
34 9.80665,
35 ::comms::Icons::mdi::arrow_down_bold,
36 ::comms::Colors::mui::red[500],
37 static constexpr int default_precision = 3;)
38
39// -----------------------------------------------------------------------------
40// Area
41// -----------------------------------------------------------------------------
42
43DIMVAL_DEFINE_UNIT(SquareMeter,
44 "m2",
45 "m²",
46 "m²",
47 "square meter",
48 "area",
49 1.0,
50 ::comms::Icons::mdi::vector_square,
51 ::comms::Colors::mui::green[400],
52 static constexpr int default_precision = 2;)
53
54DIMVAL_DEFINE_UNIT(Hectare,
55 "ha",
56 "ha",
57 "ha",
58 "hectare",
59 "area",
60 1e4,
61 ::comms::Icons::mdi::vector_square,
62 ::comms::Colors::mui::green[500],
63 static constexpr int default_precision = 2;)
64
65// -----------------------------------------------------------------------------
66// Density (mass per volume)
67// -----------------------------------------------------------------------------
68
69DIMVAL_DEFINE_UNIT(KilogramPerCubicMeter,
70 "kg_per_m3",
71 "kg/m³",
72 "kg/m³",
73 "kilogram per cubic meter",
74 "density",
75 1.0,
76 ::comms::Icons::mdi::weight_kilogram,
77 ::comms::Colors::mui::brown[400],
78 static constexpr int default_precision = 2;)
79
80DIMVAL_DEFINE_UNIT(GramPerCubicCentimeter,
81 "g_per_cm3",
82 "g/cm³",
83 "g/cm³",
84 "gram per cubic centimeter",
85 "density",
86 1000.0,
87 ::comms::Icons::mdi::weight_gram,
88 ::comms::Colors::mui::brown[500],
89 static constexpr int default_precision = 3;)
Macros that expand into a CRTP unit/measure struct and a runtime auto-registration for it.
#define DIMVAL_DEFINE_UNIT(Tag, Id, Symbol, ShortName, LongName, Kind, Factor, Icon, Color,...)
Define a unit struct in ::dimval and auto-register its descriptor at static-init time.
Definition define.hpp:72