dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
si.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <dimval/define.hpp>
7
8// -----------------------------------------------------------------------------
9// SI base units
10// -----------------------------------------------------------------------------
11
13 "m",
14 "m",
15 "m",
16 "meter",
17 "length",
18 1.0,
19 ::comms::Icon::from("tabler:ruler"),
20 ::comms::Colors::mui::teal[400])
21
22DIMVAL_DEFINE_UNIT(Kilogram,
23 "kg",
24 "kg",
25 "kg",
26 "kilogram",
27 "mass",
28 1.0,
29 ::comms::Icons::mdi::weight,
30 ::comms::Colors::mui::blue_grey[400])
31
33 "s",
34 "s",
35 "s",
36 "second",
37 "time",
38 1.0,
39 ::comms::Icon::from("ph:clock"),
40 ::comms::Colors::mui::blue[400])
41
43 "A",
44 "A",
45 "A",
46 "ampere",
47 "current",
48 1.0,
49 ::comms::Icon::from("material-symbols:electric-bolt-rounded"),
50 ::comms::Colors::mui::amber[600])
51
53 "K",
54 "K",
55 "K",
56 "kelvin",
57 "temperature",
58 1.0,
59 ::comms::Icon::from("ph:thermometer-light"),
60 ::comms::Colors::mui::orange[300])
61
63 "mol",
64 "mol",
65 "mol",
66 "mole",
67 "amount_of_substance",
68 1.0,
69 ::comms::Icons::mdi::beaker_outline,
70 ::comms::Colors::mui::blue_grey[400])
71
72DIMVAL_DEFINE_UNIT(Candela,
73 "cd",
74 "cd",
75 "cd",
76 "candela",
77 "luminous_intensity",
78 1.0,
79 ::comms::Icons::mdi::lightbulb_outline,
80 ::comms::Colors::mui::yellow[400])
81
82// -----------------------------------------------------------------------------
83// Time alternates (canonical = Second; linearly converting alt non-prefix units)
84// -----------------------------------------------------------------------------
85
87 "min",
88 "min",
89 "min",
90 "minute",
91 "time",
92 60.0,
93 ::comms::Icons::mdi::timer,
94 ::comms::Colors::mui::blue[300])
96 "h",
97 "h",
98 "h",
99 "hour",
100 "time",
101 3600.0,
102 ::comms::Icons::mdi::clock_time_three_outline,
103 ::comms::Colors::mui::blue[500])
105 "d",
106 "d",
107 "d",
108 "day",
109 "time",
110 86400.0,
111 ::comms::Icons::mdi::calendar,
112 ::comms::Colors::mui::blue[600])
113
114// -----------------------------------------------------------------------------
115// Temperature alternates (canonical = Kelvin)
116// -----------------------------------------------------------------------------
117
118DIMVAL_DEFINE_UNIT(Celsius,
119 "degC",
120 "°C",
121 "°C",
122 "degree Celsius",
123 "temperature",
124 1.0,
125 ::comms::Icons::mdi::thermometer_lines,
126 ::comms::Colors::mui::orange[400],
127 static constexpr double offset = 273.15;
128 static constexpr int default_precision = 1;)
129DIMVAL_DEFINE_UNIT(Fahrenheit,
130 "degF",
131 "°F",
132 "°F",
133 "degree Fahrenheit",
134 "temperature",
135 5.0 / 9.0,
136 ::comms::Icons::mdi::thermometer,
137 ::comms::Colors::mui::orange[500],
138 static constexpr double offset = 273.15 - 32.0 * 5.0 / 9.0;
139 static constexpr int default_precision = 1;)
140
141// -----------------------------------------------------------------------------
142// SI derived units
143// -----------------------------------------------------------------------------
144
145DIMVAL_DEFINE_UNIT(Radian,
146 "rad",
147 "rad",
148 "rad",
149 "radian",
150 "angle",
151 1.0,
152 ::comms::Icons::mdi::angle_obtuse,
153 ::comms::Colors::mui::deep_purple[400])
154
155DIMVAL_DEFINE_UNIT(Steradian,
156 "sr",
157 "sr",
158 "sr",
159 "steradian",
160 "solid_angle",
161 1.0,
162 ::comms::Icons::mdi::circle_outline,
163 ::comms::Colors::mui::deep_purple[300])
164
166 "Hz",
167 "Hz",
168 "Hz",
169 "hertz",
170 "frequency",
171 1.0,
172 ::comms::Icon::from("ph:wave-sine"),
173 ::comms::Colors::mui::light_blue[400])
174
175DIMVAL_DEFINE_UNIT(Newton,
176 "N",
177 "N",
178 "N",
179 "newton",
180 "force",
181 1.0,
182 ::comms::Icons::mdi::arrow_right_bold,
183 ::comms::Colors::mui::blue_grey[500])
184
185DIMVAL_DEFINE_UNIT(Pascal,
186 "Pa",
187 "Pa",
188 "Pa",
189 "pascal",
190 "pressure",
191 1.0,
192 ::comms::Icon::from("ph:gauge"),
193 ::comms::Colors::mui::blue_grey[400])
194
196 "J",
197 "J",
198 "J",
199 "joule",
200 "energy",
201 1.0,
202 ::comms::Icons::mdi::flash,
203 ::comms::Colors::mui::deep_orange[500])
204
206 "W",
207 "W",
208 "W",
209 "watt",
210 "power",
211 1.0,
212 ::comms::Icons::mdi::lightning_bolt,
213 ::comms::Colors::mui::deep_orange[400])
214
215DIMVAL_DEFINE_UNIT(Coulomb,
216 "C",
217 "C",
218 "C",
219 "coulomb",
220 "charge",
221 1.0,
222 ::comms::Icons::mdi::transmission_tower,
223 ::comms::Colors::mui::amber[700])
224
226 "V",
227 "V",
228 "V",
229 "volt",
230 "voltage",
231 1.0,
232 ::comms::Icon::from("material-symbols:electric-bolt-rounded"),
233 ::comms::Colors::mui::amber[500])
234
236 "F",
237 "F",
238 "F",
239 "farad",
240 "capacitance",
241 1.0,
242 ::comms::Icon::from("mdi:capacitor"),
243 ::comms::Colors::mui::brown[300])
244
246 "ohm",
247 "Ω",
248 "Ω",
249 "ohm",
250 "resistance",
251 1.0,
252 ::comms::Icons::mdi::resistor,
253 ::comms::Colors::mui::brown[400])
254
255DIMVAL_DEFINE_UNIT(Siemens,
256 "siemens",
257 "S",
258 "S",
259 "siemens",
260 "conductance",
261 1.0,
262 ::comms::Icons::mdi::resistor_nodes,
263 ::comms::Colors::mui::brown[500])
264
266 "Wb",
267 "Wb",
268 "Wb",
269 "weber",
270 "magnetic_flux",
271 1.0,
272 ::comms::Icon::from("ph:magnet"),
273 ::comms::Colors::mui::indigo[400])
274
276 "T",
277 "T",
278 "T",
279 "tesla",
280 "magnetic_flux_density",
281 1.0,
282 ::comms::Icon::from("ph:magnet"),
283 ::comms::Colors::mui::indigo[500])
284
286 "H",
287 "H",
288 "H",
289 "henry",
290 "inductance",
291 1.0,
292 ::comms::Icon::from("mdi:coil"),
293 ::comms::Colors::mui::brown[600])
294
296 "lm",
297 "lm",
298 "lm",
299 "lumen",
300 "luminous_flux",
301 1.0,
302 ::comms::Icons::mdi::lightbulb_outline,
303 ::comms::Colors::mui::yellow[500])
304
306 "lx",
307 "lx",
308 "lx",
309 "lux",
310 "illuminance",
311 1.0,
312 ::comms::Icons::mdi::brightness_6,
313 ::comms::Colors::mui::yellow[600])
314
315DIMVAL_DEFINE_UNIT(Becquerel,
316 "Bq",
317 "Bq",
318 "Bq",
319 "becquerel",
320 "radioactivity",
321 1.0,
322 ::comms::Icons::mdi::radioactive_circle_outline,
323 ::comms::Colors::mui::pink[400])
324
326 "Gy",
327 "Gy",
328 "Gy",
329 "gray",
330 "absorbed_dose",
331 1.0,
332 ::comms::Icons::mdi::radioactive_circle_outline,
333 ::comms::Colors::mui::pink[500])
334
335DIMVAL_DEFINE_UNIT(Sievert,
336 "Sv",
337 "Sv",
338 "Sv",
339 "sievert",
340 "dose_equivalent",
341 1.0,
342 ::comms::Icons::mdi::radioactive_circle_outline,
343 ::comms::Colors::mui::pink[600])
344
346 "kat",
347 "kat",
348 "kat",
349 "katal",
350 "catalytic_activity",
351 1.0,
352 ::comms::Icons::mdi::beaker_outline,
353 ::comms::Colors::mui::pink[300])
354
355// -----------------------------------------------------------------------------
356// Volume / mass alternates
357// -----------------------------------------------------------------------------
358
360 "L",
361 "L",
362 "L",
363 "litre",
364 "volume",
365 1.0,
366 ::comms::Icons::mdi::water_outline,
367 ::comms::Colors::mui::blue_grey[300])
368
369DIMVAL_DEFINE_UNIT(CubicMeter,
370 "m3",
371 "m³",
372 "m³",
373 "cubic meter",
374 "volume",
375 1000.0,
376 ::comms::Icons::mdi::cube_outline,
377 ::comms::Colors::mui::blue_grey[400])
378
380 "t",
381 "t",
382 "t",
383 "tonne",
384 "mass",
385 1000.0,
386 ::comms::Icons::mdi::weight,
387 ::comms::Colors::mui::blue_grey[500])
388
389// -----------------------------------------------------------------------------
390// Pressure / energy alternates
391// -----------------------------------------------------------------------------
392
394 "bar",
395 "bar",
396 "bar",
397 "bar",
398 "pressure",
399 1e5,
400 ::comms::Icon::from("ph:gauge"),
401 ::comms::Colors::mui::blue_grey[500],
402 static constexpr int default_precision = 2;)
403
404DIMVAL_DEFINE_UNIT(Atmosphere,
405 "atm",
406 "atm",
407 "atm",
408 "standard atmosphere",
409 "pressure",
410 101325.0,
411 ::comms::Icon::from("ph:gauge"),
412 ::comms::Colors::mui::blue_grey[600],
413 static constexpr int default_precision = 3;)
414
415DIMVAL_DEFINE_UNIT(KilowattHour,
416 "kWh",
417 "kWh",
418 "kWh",
419 "kilowatt-hour",
420 "energy",
421 3.6e6,
422 ::comms::Icons::mdi::battery_high,
423 ::comms::Colors::mui::deep_orange[700],
424 static constexpr int default_precision = 2;)
425
426// -----------------------------------------------------------------------------
427// Magnetic flux density alternate
428// -----------------------------------------------------------------------------
429
431 "G",
432 "G",
433 "G",
434 "gauss",
435 "magnetic_flux_density",
436 1e-4,
437 ::comms::Icon::from("ph:magnet"),
438 ::comms::Colors::mui::indigo[400])
439
440// -----------------------------------------------------------------------------
441// Angle (canonical Radian; Degree alt non-prefix unit)
442// -----------------------------------------------------------------------------
443
444DIMVAL_DEFINE_UNIT(Degree,
445 "deg",
446 "°",
447 "°",
448 "degree",
449 "angle",
450 0.017453292519943295,
451 ::comms::Icons::mdi::angle_obtuse,
452 ::comms::Colors::mui::deep_purple[400],
453 static constexpr ::std::string_view formatter = "degree";
454 static constexpr int default_precision = 2;
455 static constexpr bool no_space_before_symbol = true;)
456
457// 1 arcminute = π/10800 rad. Used in astronomy / GNSS heading reports.
458DIMVAL_DEFINE_UNIT(Arcminute,
459 "arcmin",
460 "′",
461 "′",
462 "arcminute",
463 "angle",
464 2.908882086657216e-4,
465 ::comms::Icons::mdi::angle_acute,
466 ::comms::Colors::mui::deep_purple[300],
467 static constexpr int default_precision = 2;
468 static constexpr bool no_space_before_symbol = true;)
469
470// 1 arcsecond = π/648000 rad.
471DIMVAL_DEFINE_UNIT(Arcsecond,
472 "arcsec",
473 "″",
474 "″",
475 "arcsecond",
476 "angle",
477 4.84813681109536e-6,
478 ::comms::Icons::mdi::angle_acute,
479 ::comms::Colors::mui::deep_purple[200],
480 static constexpr int default_precision = 3;
481 static constexpr bool no_space_before_symbol = true;)
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