Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Speed.hpp
Go to the documentation of this file.
1 // Copyright © 2020-2024 Alexandre Coderre-Chabot
2 //
3 // This file is part of Physical Quantities (PhQ), a C++ library of physical quantities, physical
4 // models, and units of measure for scientific computing.
5 //
6 // Physical Quantities is hosted at:
7 // https://github.com/acodcha/phq
8 //
9 // Physical Quantities is licensed under the MIT License:
10 // https://mit-license.org
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
13 // associated documentation files (the "Software"), to deal in the Software without restriction,
14 // including without limitation the rights to use, copy, modify, merge, publish, distribute,
15 // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 // - The above copyright notice and this permission notice shall be included in all copies or
18 // substantial portions of the Software.
19 // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
20 // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 
25 #ifndef PHQ_UNIT_SPEED_HPP
26 #define PHQ_UNIT_SPEED_HPP
27 
28 #include <cstddef>
29 #include <cstdint>
30 #include <functional>
31 #include <map>
32 #include <ostream>
33 #include <string_view>
34 #include <unordered_map>
35 
36 #include "../Base.hpp"
37 #include "../Dimension/ElectricCurrent.hpp"
38 #include "../Dimension/Length.hpp"
39 #include "../Dimension/LuminousIntensity.hpp"
40 #include "../Dimension/Mass.hpp"
41 #include "../Dimension/SubstanceAmount.hpp"
42 #include "../Dimension/Temperature.hpp"
43 #include "../Dimension/Time.hpp"
44 #include "../Dimensions.hpp"
45 #include "../Unit.hpp"
46 #include "../UnitSystem.hpp"
47 
48 namespace PhQ {
49 
50 namespace Unit {
51 
52 /// \brief Speed units.
53 enum class Speed : int8_t {
54  /// \brief Metre per second (m/s) speed unit.
56 
57  /// \brief Metre per minute (m/min) speed unit.
59 
60  /// \brief Metre per hour (m/hr) speed unit.
62 
63  /// \brief Nautical mile per second (nmi/s) speed unit.
65 
66  /// \brief Nautical mile per minute (nmi/min) speed unit.
68 
69  /// \brief Knot (kn) speed unit, also known as nautical mile per hour.
70  Knot,
71 
72  /// \brief Mile per second (mi/s) speed unit.
74 
75  /// \brief Mile per minute (mi/min) speed unit.
77 
78  /// \brief Mile per hour (mi/hr) speed unit.
80 
81  /// \brief Kilometre per second (km/s) speed unit.
83 
84  /// \brief Kilometre per minute (km/min) speed unit.
86 
87  /// \brief Kilometre per hour (km/hr) speed unit.
89 
90  /// \brief Yard per second (yd/s) speed unit.
92 
93  /// \brief Yard per minute (yd/min) speed unit.
95 
96  /// \brief Yard per hour (yd/hr) speed unit.
98 
99  /// \brief Foot per second (ft/s) speed unit.
101 
102  /// \brief Foot per minute (ft/min) speed unit.
104 
105  /// \brief Foot per hour (ft/hr) speed unit.
106  FootPerHour,
107 
108  /// \brief Decimetre per second (dm/s) speed unit.
110 
111  /// \brief Decimetre per minute (dm/min) speed unit.
113 
114  /// \brief Decimetre per hour (dm/hr) speed unit.
116 
117  /// \brief Inch per second (in/s) speed unit.
119 
120  /// \brief Inch per minute (in/min) speed unit.
122 
123  /// \brief Inch per hour (in/hr) speed unit.
124  InchPerHour,
125 
126  /// \brief Centimetre per second (cm/s) speed unit.
128 
129  /// \brief Centimetre per minute (cm/min) speed unit.
131 
132  /// \brief Centimetre per hour (cm/hr) speed unit.
134 
135  /// \brief Millimetre per second (mm/s) speed unit.
137 
138  /// \brief Millimetre per minute (mm/min) speed unit.
140 
141  /// \brief Millimetre per hour (mm/hr) speed unit.
143 
144  /// \brief Milliinch per second (mil/s) speed unit.
146 
147  /// \brief Milliinch per minute (mil/min) speed unit.
149 
150  /// \brief Milliinch per hour (mil/hr) speed unit.
152 
153  /// \brief Micrometre per second (μm/s) speed unit.
155 
156  /// \brief Micrometre per minute (μm/min) speed unit.
158 
159  /// \brief Micrometre per hour (μm/hr) speed unit.
161 
162  /// \brief Microinch per second (μin/s) speed unit.
164 
165  /// \brief Microinch per minute (μin/min) speed unit.
167 
168  /// \brief Microinch per hour (μin/hr) speed unit.
170 };
171 
172 } // namespace Unit
173 
174 /// \brief Standard speed unit: metre per second (m/s).
175 template <>
176 inline constexpr const Unit::Speed Standard<Unit::Speed>{Unit::Speed::MetrePerSecond};
177 
178 /// \brief Physical dimension set of speed units.
179 template <>
180 inline constexpr const Dimensions RelatedDimensions<Unit::Speed>{
181  Dimensions{Dimension::Time{-1}, Dimension::Length{1}, Dimension::Mass{0},
183  Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
184 };
185 
186 inline std::ostream& operator<<(std::ostream& stream, const Unit::Speed unit) {
187  stream << Abbreviation(unit);
188  return stream;
189 }
190 
191 namespace Internal {
192 
193 template <>
194 inline const std::map<UnitSystem, Unit::Speed> ConsistentUnits<Unit::Speed>{
199 };
200 
201 template <>
202 inline const std::map<Unit::Speed, UnitSystem> RelatedUnitSystems<Unit::Speed>{
207 };
208 
209 // clang-format off
210 
211 template <>
212 inline const std::map<Unit::Speed, std::string_view> Abbreviations<Unit::Speed>{
213  {Unit::Speed::MetrePerSecond, "m/s" },
214  {Unit::Speed::MetrePerMinute, "m/min" },
215  {Unit::Speed::MetrePerHour, "m/hr" },
218  {Unit::Speed::Knot, "kn" },
219  {Unit::Speed::MilePerSecond, "mi/s" },
220  {Unit::Speed::MilePerMinute, "mi/min" },
221  {Unit::Speed::MilePerHour, "mi/hr" },
223  {Unit::Speed::KilometrePerMinute, "km/min" },
224  {Unit::Speed::KilometrePerHour, "km/hr" },
225  {Unit::Speed::YardPerSecond, "yd/s" },
226  {Unit::Speed::YardPerMinute, "yd/min" },
227  {Unit::Speed::YardPerHour, "yd/hr" },
228  {Unit::Speed::FootPerSecond, "ft/s" },
229  {Unit::Speed::FootPerMinute, "ft/min" },
230  {Unit::Speed::FootPerHour, "ft/hr" },
232  {Unit::Speed::DecimetrePerMinute, "dm/min" },
233  {Unit::Speed::DecimetrePerHour, "dm/hr" },
234  {Unit::Speed::InchPerSecond, "in/s" },
235  {Unit::Speed::InchPerMinute, "in/min" },
236  {Unit::Speed::InchPerHour, "in/hr" },
239  {Unit::Speed::CentimetrePerHour, "cm/hr" },
242  {Unit::Speed::MillimetrePerHour, "mm/hr" },
244  {Unit::Speed::MilliinchPerMinute, "mil/min"},
245  {Unit::Speed::MilliinchPerHour, "mil/hr" },
247  {Unit::Speed::MicrometrePerMinute, "μm/min" },
248  {Unit::Speed::MicrometrePerHour, "μm/hr" },
249  {Unit::Speed::MicroinchPerSecond, "μin/s" },
250  {Unit::Speed::MicroinchPerMinute, "μin/min"},
251  {Unit::Speed::MicroinchPerHour, "μin/hr" },
252 };
253 
254 template <>
255 inline const std::unordered_map<std::string_view, Unit::Speed> Spellings<Unit::Speed>{
256  {"m/s", Unit::Speed::MetrePerSecond },
257  {"m/min", Unit::Speed::MetrePerMinute },
258  {"m/hr", Unit::Speed::MetrePerHour },
261  {"kn", Unit::Speed::Knot },
262  {"knot", Unit::Speed::Knot },
263  {"knots", Unit::Speed::Knot },
264  {"nmi/hr", Unit::Speed::Knot },
265  {"mi/s", Unit::Speed::MilePerSecond },
266  {"mi/min", Unit::Speed::MilePerMinute },
267  {"mi/hr", Unit::Speed::MilePerHour },
269  {"km/min", Unit::Speed::KilometrePerMinute },
270  {"km/hr", Unit::Speed::KilometrePerHour },
271  {"yd/s", Unit::Speed::YardPerSecond },
272  {"yd/min", Unit::Speed::YardPerMinute },
273  {"yd/hr", Unit::Speed::YardPerHour },
274  {"ft/s", Unit::Speed::FootPerSecond },
275  {"ft/min", Unit::Speed::FootPerMinute },
276  {"ft/hr", Unit::Speed::FootPerHour },
278  {"dm/min", Unit::Speed::DecimetrePerMinute },
279  {"dm/hr", Unit::Speed::DecimetrePerHour },
280  {"in/s", Unit::Speed::InchPerSecond },
281  {"in/min", Unit::Speed::InchPerMinute },
282  {"in/hr", Unit::Speed::InchPerHour },
285  {"cm/hr", Unit::Speed::CentimetrePerHour },
288  {"mm/hr", Unit::Speed::MillimetrePerHour },
289  {"milin/s", Unit::Speed::MilliinchPerSecond },
290  {"milin/min", Unit::Speed::MilliinchPerMinute },
291  {"milin/hr", Unit::Speed::MilliinchPerHour },
292  {"milliinch/s", Unit::Speed::MilliinchPerSecond },
293  {"milliinch/min", Unit::Speed::MilliinchPerMinute },
294  {"milliinch/hr", Unit::Speed::MilliinchPerHour },
296  {"mil/min", Unit::Speed::MilliinchPerMinute },
297  {"mil/hr", Unit::Speed::MilliinchPerHour },
298  {"thou/s", Unit::Speed::MilliinchPerSecond },
299  {"thou/min", Unit::Speed::MilliinchPerMinute },
300  {"thou/hr", Unit::Speed::MilliinchPerHour },
302  {"μm/min", Unit::Speed::MicrometrePerMinute },
303  {"μm/hr", Unit::Speed::MicrometrePerHour },
306  {"um/hr", Unit::Speed::MicrometrePerHour },
307  {"μin/s", Unit::Speed::MicroinchPerSecond },
308  {"μin/min", Unit::Speed::MicroinchPerMinute },
309  {"μin/hr", Unit::Speed::MicroinchPerHour },
311  {"uin/min", Unit::Speed::MicroinchPerMinute },
312  {"uin/hr", Unit::Speed::MicroinchPerHour },
313 };
314 
315 // clang-format on
316 
317 template <>
318 template <typename NumericType>
319 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MetrePerSecond>::FromStandard(
320  NumericType& /*value*/) noexcept {}
321 
322 template <>
323 template <typename NumericType>
324 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MetrePerSecond>::ToStandard(
325  NumericType& /*value*/) noexcept {}
326 
327 template <>
328 template <typename NumericType>
329 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MetrePerMinute>::FromStandard(
330  NumericType& value) noexcept {
331  value *= static_cast<NumericType>(60.0L);
332 }
333 
334 template <>
335 template <typename NumericType>
336 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MetrePerMinute>::ToStandard(
337  NumericType& value) noexcept {
338  value /= static_cast<NumericType>(60.0L);
339 }
340 
341 template <>
342 template <typename NumericType>
343 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MetrePerHour>::FromStandard(
344  NumericType& value) noexcept {
345  value *= static_cast<NumericType>(3600.0L);
346 }
347 
348 template <>
349 template <typename NumericType>
350 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MetrePerHour>::ToStandard(
351  NumericType& value) noexcept {
352  value /= static_cast<NumericType>(3600.0L);
353 }
354 
355 template <>
356 template <typename NumericType>
357 inline constexpr void Conversion<Unit::Speed, Unit::Speed::NauticalMilePerSecond>::FromStandard(
358  NumericType& value) noexcept {
359  value /= static_cast<NumericType>(1852.0L);
360 }
361 
362 template <>
363 template <typename NumericType>
364 inline constexpr void Conversion<Unit::Speed, Unit::Speed::NauticalMilePerSecond>::ToStandard(
365  NumericType& value) noexcept {
366  value *= static_cast<NumericType>(1852.0L);
367 }
368 
369 template <>
370 template <typename NumericType>
371 inline constexpr void Conversion<Unit::Speed, Unit::Speed::NauticalMilePerMinute>::FromStandard(
372  NumericType& value) noexcept {
373  value *= static_cast<NumericType>(60.0L) / static_cast<NumericType>(1852.0L);
374 }
375 
376 template <>
377 template <typename NumericType>
378 inline constexpr void Conversion<Unit::Speed, Unit::Speed::NauticalMilePerMinute>::ToStandard(
379  NumericType& value) noexcept {
380  value *= static_cast<NumericType>(1852.0L) / static_cast<NumericType>(60.0L);
381 }
382 
383 template <>
384 template <typename NumericType>
385 inline constexpr void Conversion<Unit::Speed, Unit::Speed::Knot>::FromStandard(
386  NumericType& value) noexcept {
387  value *= static_cast<NumericType>(3600.0L) / static_cast<NumericType>(1852.0L);
388 }
389 
390 template <>
391 template <typename NumericType>
392 inline constexpr void Conversion<Unit::Speed, Unit::Speed::Knot>::ToStandard(
393  NumericType& value) noexcept {
394  value *= static_cast<NumericType>(1852.0L) / static_cast<NumericType>(3600.0L);
395 }
396 
397 template <>
398 template <typename NumericType>
399 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilePerSecond>::FromStandard(
400  NumericType& value) noexcept {
401  value /= static_cast<NumericType>(1609.344L);
402 }
403 
404 template <>
405 template <typename NumericType>
406 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilePerSecond>::ToStandard(
407  NumericType& value) noexcept {
408  value *= static_cast<NumericType>(1609.344L);
409 }
410 
411 template <>
412 template <typename NumericType>
413 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilePerMinute>::FromStandard(
414  NumericType& value) noexcept {
415  value *= static_cast<NumericType>(60.0L) / static_cast<NumericType>(1609.344L);
416 }
417 
418 template <>
419 template <typename NumericType>
420 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilePerMinute>::ToStandard(
421  NumericType& value) noexcept {
422  value *= static_cast<NumericType>(1609.344L) / static_cast<NumericType>(60.0L);
423 }
424 
425 template <>
426 template <typename NumericType>
427 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilePerHour>::FromStandard(
428  NumericType& value) noexcept {
429  value *= static_cast<NumericType>(3600.0L) / static_cast<NumericType>(1609.344L);
430 }
431 
432 template <>
433 template <typename NumericType>
434 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilePerHour>::ToStandard(
435  NumericType& value) noexcept {
436  value *= static_cast<NumericType>(1609.344L) / static_cast<NumericType>(3600.0L);
437 }
438 
439 template <>
440 template <typename NumericType>
441 inline constexpr void Conversion<Unit::Speed, Unit::Speed::KilometrePerSecond>::FromStandard(
442  NumericType& value) noexcept {
443  value *= static_cast<NumericType>(0.001L);
444 }
445 
446 template <>
447 template <typename NumericType>
448 inline constexpr void Conversion<Unit::Speed, Unit::Speed::KilometrePerSecond>::ToStandard(
449  NumericType& value) noexcept {
450  value *= static_cast<NumericType>(1000.0L);
451 }
452 
453 template <>
454 template <typename NumericType>
455 inline constexpr void Conversion<Unit::Speed, Unit::Speed::KilometrePerMinute>::FromStandard(
456  NumericType& value) noexcept {
457  value *= static_cast<NumericType>(0.06L);
458 }
459 
460 template <>
461 template <typename NumericType>
462 inline constexpr void Conversion<Unit::Speed, Unit::Speed::KilometrePerMinute>::ToStandard(
463  NumericType& value) noexcept {
464  value *= static_cast<NumericType>(1000.0L) / static_cast<NumericType>(60.0L);
465 }
466 
467 template <>
468 template <typename NumericType>
469 inline constexpr void Conversion<Unit::Speed, Unit::Speed::KilometrePerHour>::FromStandard(
470  NumericType& value) noexcept {
471  value *= static_cast<NumericType>(3.6L);
472 }
473 
474 template <>
475 template <typename NumericType>
476 inline constexpr void Conversion<Unit::Speed, Unit::Speed::KilometrePerHour>::ToStandard(
477  NumericType& value) noexcept {
478  value *= static_cast<NumericType>(1000.0L) / static_cast<NumericType>(3600.0L);
479 }
480 
481 template <>
482 template <typename NumericType>
483 inline constexpr void Conversion<Unit::Speed, Unit::Speed::YardPerSecond>::FromStandard(
484  NumericType& value) noexcept {
485  value /= static_cast<NumericType>(0.9144L);
486 }
487 
488 template <>
489 template <typename NumericType>
490 inline constexpr void Conversion<Unit::Speed, Unit::Speed::YardPerSecond>::ToStandard(
491  NumericType& value) noexcept {
492  value *= static_cast<NumericType>(0.9144L);
493 }
494 
495 template <>
496 template <typename NumericType>
497 inline constexpr void Conversion<Unit::Speed, Unit::Speed::YardPerMinute>::FromStandard(
498  NumericType& value) noexcept {
499  value *= static_cast<NumericType>(60.0L) / static_cast<NumericType>(0.9144L);
500 }
501 
502 template <>
503 template <typename NumericType>
504 inline constexpr void Conversion<Unit::Speed, Unit::Speed::YardPerMinute>::ToStandard(
505  NumericType& value) noexcept {
506  value *= static_cast<NumericType>(0.9144L) / static_cast<NumericType>(60.0L);
507 }
508 
509 template <>
510 template <typename NumericType>
511 inline constexpr void Conversion<Unit::Speed, Unit::Speed::YardPerHour>::FromStandard(
512  NumericType& value) noexcept {
513  value *= static_cast<NumericType>(3600.0L) / static_cast<NumericType>(0.9144L);
514 }
515 
516 template <>
517 template <typename NumericType>
518 inline constexpr void Conversion<Unit::Speed, Unit::Speed::YardPerHour>::ToStandard(
519  NumericType& value) noexcept {
520  value *= static_cast<NumericType>(0.9144L) / static_cast<NumericType>(3600.0L);
521 }
522 
523 template <>
524 template <typename NumericType>
525 inline constexpr void Conversion<Unit::Speed, Unit::Speed::FootPerSecond>::FromStandard(
526  NumericType& value) noexcept {
527  value /= static_cast<NumericType>(0.3048L);
528 }
529 
530 template <>
531 template <typename NumericType>
532 inline constexpr void Conversion<Unit::Speed, Unit::Speed::FootPerSecond>::ToStandard(
533  NumericType& value) noexcept {
534  value *= static_cast<NumericType>(0.3048L);
535 }
536 
537 template <>
538 template <typename NumericType>
539 inline constexpr void Conversion<Unit::Speed, Unit::Speed::FootPerMinute>::FromStandard(
540  NumericType& value) noexcept {
541  value *= static_cast<NumericType>(60.0L) / static_cast<NumericType>(0.3048L);
542 }
543 
544 template <>
545 template <typename NumericType>
546 inline constexpr void Conversion<Unit::Speed, Unit::Speed::FootPerMinute>::ToStandard(
547  NumericType& value) noexcept {
548  value *= static_cast<NumericType>(0.3048L) / static_cast<NumericType>(60.0L);
549 }
550 
551 template <>
552 template <typename NumericType>
553 inline constexpr void Conversion<Unit::Speed, Unit::Speed::FootPerHour>::FromStandard(
554  NumericType& value) noexcept {
555  value *= static_cast<NumericType>(3600.0L) / static_cast<NumericType>(0.3048L);
556 }
557 
558 template <>
559 template <typename NumericType>
560 inline constexpr void Conversion<Unit::Speed, Unit::Speed::FootPerHour>::ToStandard(
561  NumericType& value) noexcept {
562  value *= static_cast<NumericType>(0.3048L) / static_cast<NumericType>(3600.0L);
563 }
564 
565 template <>
566 template <typename NumericType>
567 inline constexpr void Conversion<Unit::Speed, Unit::Speed::DecimetrePerSecond>::FromStandard(
568  NumericType& value) noexcept {
569  value *= static_cast<NumericType>(10.0L);
570 }
571 
572 template <>
573 template <typename NumericType>
574 inline constexpr void Conversion<Unit::Speed, Unit::Speed::DecimetrePerSecond>::ToStandard(
575  NumericType& value) noexcept {
576  value *= static_cast<NumericType>(0.1L);
577 }
578 
579 template <>
580 template <typename NumericType>
581 inline constexpr void Conversion<Unit::Speed, Unit::Speed::DecimetrePerMinute>::FromStandard(
582  NumericType& value) noexcept {
583  value *= static_cast<NumericType>(600.0L);
584 }
585 
586 template <>
587 template <typename NumericType>
588 inline constexpr void Conversion<Unit::Speed, Unit::Speed::DecimetrePerMinute>::ToStandard(
589  NumericType& value) noexcept {
590  value /= static_cast<NumericType>(600.0L);
591 }
592 
593 template <>
594 template <typename NumericType>
595 inline constexpr void Conversion<Unit::Speed, Unit::Speed::DecimetrePerHour>::FromStandard(
596  NumericType& value) noexcept {
597  value *= static_cast<NumericType>(36000.0L);
598 }
599 
600 template <>
601 template <typename NumericType>
602 inline constexpr void Conversion<Unit::Speed, Unit::Speed::DecimetrePerHour>::ToStandard(
603  NumericType& value) noexcept {
604  value /= static_cast<NumericType>(36000.0L);
605 }
606 
607 template <>
608 template <typename NumericType>
609 inline constexpr void Conversion<Unit::Speed, Unit::Speed::InchPerSecond>::FromStandard(
610  NumericType& value) noexcept {
611  value /= static_cast<NumericType>(0.0254L);
612 }
613 
614 template <>
615 template <typename NumericType>
616 inline constexpr void Conversion<Unit::Speed, Unit::Speed::InchPerSecond>::ToStandard(
617  NumericType& value) noexcept {
618  value *= static_cast<NumericType>(0.0254L);
619 }
620 
621 template <>
622 template <typename NumericType>
623 inline constexpr void Conversion<Unit::Speed, Unit::Speed::InchPerMinute>::FromStandard(
624  NumericType& value) noexcept {
625  value *= static_cast<NumericType>(60.0L) / static_cast<NumericType>(0.0254L);
626 }
627 
628 template <>
629 template <typename NumericType>
630 inline constexpr void Conversion<Unit::Speed, Unit::Speed::InchPerMinute>::ToStandard(
631  NumericType& value) noexcept {
632  value *= static_cast<NumericType>(0.0254L) / static_cast<NumericType>(60.0L);
633 }
634 
635 template <>
636 template <typename NumericType>
637 inline constexpr void Conversion<Unit::Speed, Unit::Speed::InchPerHour>::FromStandard(
638  NumericType& value) noexcept {
639  value *= static_cast<NumericType>(3600.0L) / static_cast<NumericType>(0.0254L);
640 }
641 
642 template <>
643 template <typename NumericType>
644 inline constexpr void Conversion<Unit::Speed, Unit::Speed::InchPerHour>::ToStandard(
645  NumericType& value) noexcept {
646  value *= static_cast<NumericType>(0.0254L) / static_cast<NumericType>(3600.0L);
647 }
648 
649 template <>
650 template <typename NumericType>
651 inline constexpr void Conversion<Unit::Speed, Unit::Speed::CentimetrePerSecond>::FromStandard(
652  NumericType& value) noexcept {
653  value *= static_cast<NumericType>(100.0L);
654 }
655 
656 template <>
657 template <typename NumericType>
658 inline constexpr void Conversion<Unit::Speed, Unit::Speed::CentimetrePerSecond>::ToStandard(
659  NumericType& value) noexcept {
660  value *= static_cast<NumericType>(0.01L);
661 }
662 
663 template <>
664 template <typename NumericType>
665 inline constexpr void Conversion<Unit::Speed, Unit::Speed::CentimetrePerMinute>::FromStandard(
666  NumericType& value) noexcept {
667  value *= static_cast<NumericType>(6000.0L);
668 }
669 
670 template <>
671 template <typename NumericType>
672 inline constexpr void Conversion<Unit::Speed, Unit::Speed::CentimetrePerMinute>::ToStandard(
673  NumericType& value) noexcept {
674  value /= static_cast<NumericType>(6000.0L);
675 }
676 
677 template <>
678 template <typename NumericType>
679 inline constexpr void Conversion<Unit::Speed, Unit::Speed::CentimetrePerHour>::FromStandard(
680  NumericType& value) noexcept {
681  value *= static_cast<NumericType>(360000.0L);
682 }
683 
684 template <>
685 template <typename NumericType>
686 inline constexpr void Conversion<Unit::Speed, Unit::Speed::CentimetrePerHour>::ToStandard(
687  NumericType& value) noexcept {
688  value /= static_cast<NumericType>(360000.0L);
689 }
690 
691 template <>
692 template <typename NumericType>
693 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MillimetrePerSecond>::FromStandard(
694  NumericType& value) noexcept {
695  value *= static_cast<NumericType>(1000.0L);
696 }
697 
698 template <>
699 template <typename NumericType>
700 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MillimetrePerSecond>::ToStandard(
701  NumericType& value) noexcept {
702  value *= static_cast<NumericType>(0.001L);
703 }
704 
705 template <>
706 template <typename NumericType>
707 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MillimetrePerMinute>::FromStandard(
708  NumericType& value) noexcept {
709  value *= static_cast<NumericType>(60000.0L);
710 }
711 
712 template <>
713 template <typename NumericType>
714 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MillimetrePerMinute>::ToStandard(
715  NumericType& value) noexcept {
716  value /= static_cast<NumericType>(60000.0L);
717 }
718 
719 template <>
720 template <typename NumericType>
721 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MillimetrePerHour>::FromStandard(
722  NumericType& value) noexcept {
723  value *= static_cast<NumericType>(3600000.0L);
724 }
725 
726 template <>
727 template <typename NumericType>
728 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MillimetrePerHour>::ToStandard(
729  NumericType& value) noexcept {
730  value /= static_cast<NumericType>(3600000.0L);
731 }
732 
733 template <>
734 template <typename NumericType>
735 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilliinchPerSecond>::FromStandard(
736  NumericType& value) noexcept {
737  value /= static_cast<NumericType>(0.0000254L);
738 }
739 
740 template <>
741 template <typename NumericType>
742 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilliinchPerSecond>::ToStandard(
743  NumericType& value) noexcept {
744  value *= static_cast<NumericType>(0.0000254L);
745 }
746 
747 template <>
748 template <typename NumericType>
749 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilliinchPerMinute>::FromStandard(
750  NumericType& value) noexcept {
751  value *= static_cast<NumericType>(60.0L) / static_cast<NumericType>(0.0000254L);
752 }
753 
754 template <>
755 template <typename NumericType>
756 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilliinchPerMinute>::ToStandard(
757  NumericType& value) noexcept {
758  value *= static_cast<NumericType>(0.0000254L) / static_cast<NumericType>(60.0L);
759 }
760 
761 template <>
762 template <typename NumericType>
763 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilliinchPerHour>::FromStandard(
764  NumericType& value) noexcept {
765  value *= static_cast<NumericType>(3600.0L) / static_cast<NumericType>(0.0000254L);
766 }
767 
768 template <>
769 template <typename NumericType>
770 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MilliinchPerHour>::ToStandard(
771  NumericType& value) noexcept {
772  value *= static_cast<NumericType>(0.0000254L) / static_cast<NumericType>(3600.0L);
773 }
774 
775 template <>
776 template <typename NumericType>
777 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicrometrePerSecond>::FromStandard(
778  NumericType& value) noexcept {
779  value *= static_cast<NumericType>(1000000.0L);
780 }
781 
782 template <>
783 template <typename NumericType>
784 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicrometrePerSecond>::ToStandard(
785  NumericType& value) noexcept {
786  value *= static_cast<NumericType>(0.000001L);
787 }
788 
789 template <>
790 template <typename NumericType>
791 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicrometrePerMinute>::FromStandard(
792  NumericType& value) noexcept {
793  value *= static_cast<NumericType>(60000000.0L);
794 }
795 
796 template <>
797 template <typename NumericType>
798 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicrometrePerMinute>::ToStandard(
799  NumericType& value) noexcept {
800  value /= static_cast<NumericType>(60000000.0L);
801 }
802 
803 template <>
804 template <typename NumericType>
805 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicrometrePerHour>::FromStandard(
806  NumericType& value) noexcept {
807  value *= static_cast<NumericType>(3600000000.0L);
808 }
809 
810 template <>
811 template <typename NumericType>
812 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicrometrePerHour>::ToStandard(
813  NumericType& value) noexcept {
814  value /= static_cast<NumericType>(3600000000.0L);
815 }
816 
817 template <>
818 template <typename NumericType>
819 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicroinchPerSecond>::FromStandard(
820  NumericType& value) noexcept {
821  value /= static_cast<NumericType>(0.0000000254L);
822 }
823 
824 template <>
825 template <typename NumericType>
826 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicroinchPerSecond>::ToStandard(
827  NumericType& value) noexcept {
828  value *= static_cast<NumericType>(0.0000000254L);
829 }
830 
831 template <>
832 template <typename NumericType>
833 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicroinchPerMinute>::FromStandard(
834  NumericType& value) noexcept {
835  value *= static_cast<NumericType>(60.0L) / static_cast<NumericType>(0.0000000254L);
836 }
837 
838 template <>
839 template <typename NumericType>
840 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicroinchPerMinute>::ToStandard(
841  NumericType& value) noexcept {
842  value *= static_cast<NumericType>(0.0000000254L) / static_cast<NumericType>(60.0L);
843 }
844 
845 template <>
846 template <typename NumericType>
847 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicroinchPerHour>::FromStandard(
848  NumericType& value) noexcept {
849  value *= static_cast<NumericType>(3600.0L) / static_cast<NumericType>(0.0000000254L);
850 }
851 
852 template <>
853 template <typename NumericType>
854 inline constexpr void Conversion<Unit::Speed, Unit::Speed::MicroinchPerHour>::ToStandard(
855  NumericType& value) noexcept {
856  value *= static_cast<NumericType>(0.0000000254L) / static_cast<NumericType>(3600.0L);
857 }
858 
859 template <typename NumericType>
860 inline const std::map<Unit::Speed, std::function<void(NumericType* values, const std::size_t size)>>
861  MapOfConversionsFromStandard<Unit::Speed, NumericType>{
863  Conversions<Unit::Speed, Unit::Speed::MetrePerSecond>::FromStandard<NumericType> },
865  Conversions<Unit::Speed, Unit::Speed::MetrePerMinute>::FromStandard<NumericType> },
867  Conversions<Unit::Speed, Unit::Speed::MetrePerHour>::FromStandard<NumericType> },
869  Conversions<Unit::Speed, Unit::Speed::NauticalMilePerSecond>::FromStandard<NumericType>},
871  Conversions<Unit::Speed, Unit::Speed::NauticalMilePerMinute>::FromStandard<NumericType>},
872  {Unit::Speed::Knot, Conversions<Unit::Speed, Unit::Speed::Knot>::FromStandard<NumericType> },
874  Conversions<Unit::Speed, Unit::Speed::MilePerSecond>::FromStandard<NumericType> },
876  Conversions<Unit::Speed, Unit::Speed::MilePerMinute>::FromStandard<NumericType> },
878  Conversions<Unit::Speed, Unit::Speed::MilePerHour>::FromStandard<NumericType> },
880  Conversions<Unit::Speed, Unit::Speed::KilometrePerSecond>::FromStandard<NumericType> },
882  Conversions<Unit::Speed, Unit::Speed::KilometrePerMinute>::FromStandard<NumericType> },
884  Conversions<Unit::Speed, Unit::Speed::KilometrePerHour>::FromStandard<NumericType> },
886  Conversions<Unit::Speed, Unit::Speed::YardPerSecond>::FromStandard<NumericType> },
888  Conversions<Unit::Speed, Unit::Speed::YardPerMinute>::FromStandard<NumericType> },
890  Conversions<Unit::Speed, Unit::Speed::YardPerHour>::FromStandard<NumericType> },
892  Conversions<Unit::Speed, Unit::Speed::FootPerSecond>::FromStandard<NumericType> },
894  Conversions<Unit::Speed, Unit::Speed::FootPerMinute>::FromStandard<NumericType> },
896  Conversions<Unit::Speed, Unit::Speed::FootPerHour>::FromStandard<NumericType> },
898  Conversions<Unit::Speed, Unit::Speed::DecimetrePerSecond>::FromStandard<NumericType> },
900  Conversions<Unit::Speed, Unit::Speed::DecimetrePerMinute>::FromStandard<NumericType> },
902  Conversions<Unit::Speed, Unit::Speed::DecimetrePerHour>::FromStandard<NumericType> },
904  Conversions<Unit::Speed, Unit::Speed::InchPerSecond>::FromStandard<NumericType> },
906  Conversions<Unit::Speed, Unit::Speed::InchPerMinute>::FromStandard<NumericType> },
908  Conversions<Unit::Speed, Unit::Speed::InchPerHour>::FromStandard<NumericType> },
910  Conversions<Unit::Speed, Unit::Speed::CentimetrePerSecond>::FromStandard<NumericType> },
912  Conversions<Unit::Speed, Unit::Speed::CentimetrePerMinute>::FromStandard<NumericType> },
914  Conversions<Unit::Speed, Unit::Speed::CentimetrePerHour>::FromStandard<NumericType> },
916  Conversions<Unit::Speed, Unit::Speed::MillimetrePerSecond>::FromStandard<NumericType> },
918  Conversions<Unit::Speed, Unit::Speed::MillimetrePerMinute>::FromStandard<NumericType> },
920  Conversions<Unit::Speed, Unit::Speed::MillimetrePerHour>::FromStandard<NumericType> },
922  Conversions<Unit::Speed, Unit::Speed::MilliinchPerSecond>::FromStandard<NumericType> },
924  Conversions<Unit::Speed, Unit::Speed::MilliinchPerMinute>::FromStandard<NumericType> },
926  Conversions<Unit::Speed, Unit::Speed::MilliinchPerHour>::FromStandard<NumericType> },
928  Conversions<Unit::Speed, Unit::Speed::MicrometrePerSecond>::FromStandard<NumericType> },
930  Conversions<Unit::Speed, Unit::Speed::MicrometrePerMinute>::FromStandard<NumericType> },
932  Conversions<Unit::Speed, Unit::Speed::MicrometrePerHour>::FromStandard<NumericType> },
934  Conversions<Unit::Speed, Unit::Speed::MicroinchPerSecond>::FromStandard<NumericType> },
936  Conversions<Unit::Speed, Unit::Speed::MicroinchPerMinute>::FromStandard<NumericType> },
938  Conversions<Unit::Speed, Unit::Speed::MicroinchPerHour>::FromStandard<NumericType> },
939 };
940 
941 template <typename NumericType>
942 inline const std::map<Unit::Speed,
943  std::function<void(NumericType* const values, const std::size_t size)>>
944  MapOfConversionsToStandard<Unit::Speed, NumericType>{
946  Conversions<Unit::Speed, Unit::Speed::MetrePerSecond>::ToStandard<NumericType> },
948  Conversions<Unit::Speed, Unit::Speed::MetrePerMinute>::ToStandard<NumericType> },
950  Conversions<Unit::Speed, Unit::Speed::MetrePerHour>::ToStandard<NumericType> },
952  Conversions<Unit::Speed, Unit::Speed::NauticalMilePerSecond>::ToStandard<NumericType>},
954  Conversions<Unit::Speed, Unit::Speed::NauticalMilePerMinute>::ToStandard<NumericType>},
955  {Unit::Speed::Knot, Conversions<Unit::Speed, Unit::Speed::Knot>::ToStandard<NumericType> },
957  Conversions<Unit::Speed, Unit::Speed::MilePerSecond>::ToStandard<NumericType> },
959  Conversions<Unit::Speed, Unit::Speed::MilePerMinute>::ToStandard<NumericType> },
961  Conversions<Unit::Speed, Unit::Speed::MilePerHour>::ToStandard<NumericType> },
963  Conversions<Unit::Speed, Unit::Speed::KilometrePerSecond>::ToStandard<NumericType> },
965  Conversions<Unit::Speed, Unit::Speed::KilometrePerMinute>::ToStandard<NumericType> },
967  Conversions<Unit::Speed, Unit::Speed::KilometrePerHour>::ToStandard<NumericType> },
969  Conversions<Unit::Speed, Unit::Speed::YardPerSecond>::ToStandard<NumericType> },
971  Conversions<Unit::Speed, Unit::Speed::YardPerMinute>::ToStandard<NumericType> },
973  Conversions<Unit::Speed, Unit::Speed::YardPerHour>::ToStandard<NumericType> },
975  Conversions<Unit::Speed, Unit::Speed::FootPerSecond>::ToStandard<NumericType> },
977  Conversions<Unit::Speed, Unit::Speed::FootPerMinute>::ToStandard<NumericType> },
979  Conversions<Unit::Speed, Unit::Speed::FootPerHour>::ToStandard<NumericType> },
981  Conversions<Unit::Speed, Unit::Speed::DecimetrePerSecond>::ToStandard<NumericType> },
983  Conversions<Unit::Speed, Unit::Speed::DecimetrePerMinute>::ToStandard<NumericType> },
985  Conversions<Unit::Speed, Unit::Speed::DecimetrePerHour>::ToStandard<NumericType> },
987  Conversions<Unit::Speed, Unit::Speed::InchPerSecond>::ToStandard<NumericType> },
989  Conversions<Unit::Speed, Unit::Speed::InchPerMinute>::ToStandard<NumericType> },
991  Conversions<Unit::Speed, Unit::Speed::InchPerHour>::ToStandard<NumericType> },
993  Conversions<Unit::Speed, Unit::Speed::CentimetrePerSecond>::ToStandard<NumericType> },
995  Conversions<Unit::Speed, Unit::Speed::CentimetrePerMinute>::ToStandard<NumericType> },
997  Conversions<Unit::Speed, Unit::Speed::CentimetrePerHour>::ToStandard<NumericType> },
999  Conversions<Unit::Speed, Unit::Speed::MillimetrePerSecond>::ToStandard<NumericType> },
1001  Conversions<Unit::Speed, Unit::Speed::MillimetrePerMinute>::ToStandard<NumericType> },
1003  Conversions<Unit::Speed, Unit::Speed::MillimetrePerHour>::ToStandard<NumericType> },
1005  Conversions<Unit::Speed, Unit::Speed::MilliinchPerSecond>::ToStandard<NumericType> },
1007  Conversions<Unit::Speed, Unit::Speed::MilliinchPerMinute>::ToStandard<NumericType> },
1009  Conversions<Unit::Speed, Unit::Speed::MilliinchPerHour>::ToStandard<NumericType> },
1011  Conversions<Unit::Speed, Unit::Speed::MicrometrePerSecond>::ToStandard<NumericType> },
1013  Conversions<Unit::Speed, Unit::Speed::MicrometrePerMinute>::ToStandard<NumericType> },
1015  Conversions<Unit::Speed, Unit::Speed::MicrometrePerHour>::ToStandard<NumericType> },
1017  Conversions<Unit::Speed, Unit::Speed::MicroinchPerSecond>::ToStandard<NumericType> },
1019  Conversions<Unit::Speed, Unit::Speed::MicroinchPerMinute>::ToStandard<NumericType> },
1021  Conversions<Unit::Speed, Unit::Speed::MicroinchPerHour>::ToStandard<NumericType> },
1022 };
1023 
1024 } // namespace Internal
1025 
1026 } // namespace PhQ
1027 
1028 #endif // PHQ_UNIT_SPEED_HPP
ElectricCurrent
Electric current units.
Mass
Mass units.
Definition: Mass.hpp:53
Length
Length units.
Definition: Length.hpp:53
SubstanceAmount
Amount of substance units.
Temperature
Temperature units. Not to be confused with temperature difference units. For example,...
Definition: Temperature.hpp:55
Time
Time units.
Definition: Time.hpp:53
Speed
Speed units.
Definition: Speed.hpp:53
@ YardPerSecond
Yard per second (yd/s) speed unit.
@ MetrePerSecond
Metre per second (m/s) speed unit.
@ CentimetrePerHour
Centimetre per hour (cm/hr) speed unit.
@ FootPerHour
Foot per hour (ft/hr) speed unit.
@ MetrePerMinute
Metre per minute (m/min) speed unit.
@ NauticalMilePerSecond
Nautical mile per second (nmi/s) speed unit.
@ MilePerSecond
Mile per second (mi/s) speed unit.
@ DecimetrePerSecond
Decimetre per second (dm/s) speed unit.
@ MillimetrePerMinute
Millimetre per minute (mm/min) speed unit.
@ KilometrePerSecond
Kilometre per second (km/s) speed unit.
@ InchPerHour
Inch per hour (in/hr) speed unit.
@ Knot
Knot (kn) speed unit, also known as nautical mile per hour.
@ InchPerMinute
Inch per minute (in/min) speed unit.
@ KilometrePerHour
Kilometre per hour (km/hr) speed unit.
@ DecimetrePerHour
Decimetre per hour (dm/hr) speed unit.
@ MillimetrePerHour
Millimetre per hour (mm/hr) speed unit.
@ MilePerMinute
Mile per minute (mi/min) speed unit.
@ YardPerHour
Yard per hour (yd/hr) speed unit.
@ DecimetrePerMinute
Decimetre per minute (dm/min) speed unit.
@ MilliinchPerHour
Milliinch per hour (mil/hr) speed unit.
@ MilliinchPerSecond
Milliinch per second (mil/s) speed unit.
@ FootPerMinute
Foot per minute (ft/min) speed unit.
@ FootPerSecond
Foot per second (ft/s) speed unit.
@ MetrePerHour
Metre per hour (m/hr) speed unit.
@ MilePerHour
Mile per hour (mi/hr) speed unit.
@ MilliinchPerMinute
Milliinch per minute (mil/min) speed unit.
@ MicrometrePerSecond
Micrometre per second (μm/s) speed unit.
@ YardPerMinute
Yard per minute (yd/min) speed unit.
@ MicroinchPerSecond
Microinch per second (μin/s) speed unit.
@ MicrometrePerHour
Micrometre per hour (μm/hr) speed unit.
@ KilometrePerMinute
Kilometre per minute (km/min) speed unit.
@ InchPerSecond
Inch per second (in/s) speed unit.
@ CentimetrePerSecond
Centimetre per second (cm/s) speed unit.
@ MicrometrePerMinute
Micrometre per minute (μm/min) speed unit.
@ MillimetrePerSecond
Millimetre per second (mm/s) speed unit.
@ NauticalMilePerMinute
Nautical mile per minute (nmi/min) speed unit.
@ MicroinchPerMinute
Microinch per minute (μin/min) speed unit.
@ CentimetrePerMinute
Centimetre per minute (cm/min) speed unit.
@ MicroinchPerHour
Microinch per hour (μin/hr) speed unit.
Namespace that encompasses all of the Physical Quantities library's content.
@ FootPoundSecondRankine
Foot-pound-second-rankine (ft·lbf·s·°R) system.
@ MillimetreGramSecondKelvin
Millimetre-gram-second-kelvin (mm·g·s·K) system.
@ MetreKilogramSecondKelvin
Metre-kilogram-second-kelvin (m·kg·s·K) system.
@ InchPoundSecondRankine
Inch-pound-second-rankine (in·lbf·s·°R) system.
std::string_view Abbreviation(const Enumeration enumeration)
Returns the abbreviation of a given enumeration value. For example, PhQ::Abbreviation(PhQ::Unit::Time...
Definition: Base.hpp:89
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)