Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
AngularAcceleration.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_ANGULAR_ACCELERATION_HPP
26 #define PHQ_UNIT_ANGULAR_ACCELERATION_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 Angular acceleration units.
53 enum class AngularAcceleration : int8_t {
54  /// \brief Radian per square second (rad/s^2) angular acceleration unit.
56 
57  /// \brief Radian per square minute (rad/min^2) angular acceleration unit.
59 
60  /// \brief Radian per square hour (rad/hr^2) angular acceleration unit.
62 
63  /// \brief Degree per square second (deg/s^2) angular acceleration unit.
65 
66  /// \brief Degree per square minute (deg/min^2) angular acceleration unit.
68 
69  /// \brief Degree per square hour (deg/hr^2) angular acceleration unit.
71 
72  /// \brief Arcminute per square second (arcmin/s^2) angular acceleration unit.
74 
75  /// \brief Arcminute per square minute (arcmin/min^2) angular acceleration unit.
77 
78  /// \brief Arcminute per square hour (arcmin/hr^2) angular acceleration unit.
80 
81  /// \brief Arcsecond per square second (arcsec/s^2) angular acceleration unit.
83 
84  /// \brief Arcsecond per square minute (arcsec/min^2) angular acceleration unit.
86 
87  /// \brief Arcsecond per square hour (arcsec/hr^2) angular acceleration unit.
89 
90  /// \brief Revolution per square second (rev/s^2) angular acceleration unit.
92 
93  /// \brief Revolution per square minute (rev/min^2) angular acceleration unit.
95 
96  /// \brief Revolution per square hour (rev/hr^2) angular acceleration unit.
98 };
99 
100 } // namespace Unit
101 
102 /// \brief Standard angular acceleration unit: radian per square second (rad/s^2).
103 template <>
104 inline constexpr const Unit::AngularAcceleration Standard<Unit::AngularAcceleration>{
106 
107 /// \brief Physical dimension set of angular acceleration units.
108 template <>
109 inline constexpr const Dimensions RelatedDimensions<Unit::AngularAcceleration>{
110  Dimensions{Dimension::Time{-2}, Dimension::Length{0}, Dimension::Mass{0},
112  Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
113 };
114 
115 inline std::ostream& operator<<(std::ostream& stream, const Unit::AngularAcceleration unit) {
116  stream << Abbreviation(unit);
117  return stream;
118 }
119 
120 namespace Internal {
121 
122 template <>
123 inline const std::map<UnitSystem, Unit::AngularAcceleration>
124  ConsistentUnits<Unit::AngularAcceleration>{
129 };
130 
131 template <>
132 inline const std::map<Unit::AngularAcceleration, UnitSystem>
133  RelatedUnitSystems<Unit::AngularAcceleration>{};
134 
135 template <>
136 inline const std::map<Unit::AngularAcceleration, std::string_view>
137  Abbreviations<Unit::AngularAcceleration>{
153 };
154 
155 // clang-format off
156 
157 template <>
158 inline const std::unordered_map<std::string_view, Unit::AngularAcceleration> Spellings<
214 };
215 
216 // clang-format on
217 
218 template <>
219 template <typename NumericType>
220 inline constexpr void
221 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RadianPerSquareSecond>::
222  FromStandard(NumericType& /*value*/) noexcept {}
223 
224 template <>
225 template <typename NumericType>
226 inline constexpr void
227 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RadianPerSquareSecond>::ToStandard(
228  NumericType& /*value*/) noexcept {}
229 
230 template <>
231 template <typename NumericType>
232 inline constexpr void
233 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RadianPerSquareMinute>::
234  FromStandard(NumericType& value) noexcept {
235  value *= static_cast<NumericType>(3600.0L);
236 }
237 
238 template <>
239 template <typename NumericType>
240 inline constexpr void
241 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RadianPerSquareMinute>::ToStandard(
242  NumericType& value) noexcept {
243  value /= static_cast<NumericType>(3600.0L);
244 }
245 
246 template <>
247 template <typename NumericType>
248 inline constexpr void
249 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RadianPerSquareHour>::FromStandard(
250  NumericType& value) noexcept {
251  value *= static_cast<NumericType>(12960000.0L);
252 }
253 
254 template <>
255 template <typename NumericType>
256 inline constexpr void
257 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RadianPerSquareHour>::ToStandard(
258  NumericType& value) noexcept {
259  value /= static_cast<NumericType>(12960000.0L);
260 }
261 
262 template <>
263 template <typename NumericType>
264 inline constexpr void
265 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::DegreePerSquareSecond>::
266  FromStandard(NumericType& value) noexcept {
267  value *= static_cast<NumericType>(180.0L) / Pi<NumericType>;
268 }
269 
270 template <>
271 template <typename NumericType>
272 inline constexpr void
273 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::DegreePerSquareSecond>::ToStandard(
274  NumericType& value) noexcept {
275  value *= Pi<NumericType> / static_cast<NumericType>(180.0L);
276 }
277 
278 template <>
279 template <typename NumericType>
280 inline constexpr void
281 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::DegreePerSquareMinute>::
282  FromStandard(NumericType& value) noexcept {
283  value *= static_cast<NumericType>(648000.0L) / Pi<NumericType>;
284 }
285 
286 template <>
287 template <typename NumericType>
288 inline constexpr void
289 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::DegreePerSquareMinute>::ToStandard(
290  NumericType& value) noexcept {
291  value *= Pi<NumericType> / static_cast<NumericType>(648000.0L);
292 }
293 
294 template <>
295 template <typename NumericType>
296 inline constexpr void
297 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::DegreePerSquareHour>::FromStandard(
298  NumericType& value) noexcept {
299  value *= static_cast<NumericType>(2332800000.0L) / Pi<NumericType>;
300 }
301 
302 template <>
303 template <typename NumericType>
304 inline constexpr void
305 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::DegreePerSquareHour>::ToStandard(
306  NumericType& value) noexcept {
307  value *= Pi<NumericType> / static_cast<NumericType>(2332800000.0L);
308 }
309 
310 template <>
311 template <typename NumericType>
312 inline constexpr void
313 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcminutePerSquareSecond>::
314  FromStandard(NumericType& value) noexcept {
315  value *= static_cast<NumericType>(10800.0L) / Pi<NumericType>;
316 }
317 
318 template <>
319 template <typename NumericType>
320 inline constexpr void
321 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcminutePerSquareSecond>::
322  ToStandard(NumericType& value) noexcept {
323  value *= Pi<NumericType> / static_cast<NumericType>(10800.0L);
324 }
325 
326 template <>
327 template <typename NumericType>
328 inline constexpr void
329 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcminutePerSquareMinute>::
330  FromStandard(NumericType& value) noexcept {
331  value *= static_cast<NumericType>(38880000.0L) / Pi<NumericType>;
332 }
333 
334 template <>
335 template <typename NumericType>
336 inline constexpr void
337 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcminutePerSquareMinute>::
338  ToStandard(NumericType& value) noexcept {
339  value *= Pi<NumericType> / static_cast<NumericType>(38880000.0L);
340 }
341 
342 template <>
343 template <typename NumericType>
344 inline constexpr void
345 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcminutePerSquareHour>::
346  FromStandard(NumericType& value) noexcept {
347  value *= static_cast<NumericType>(139968000000.0L) / Pi<NumericType>;
348 }
349 
350 template <>
351 template <typename NumericType>
352 inline constexpr void
353 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcminutePerSquareHour>::
354  ToStandard(NumericType& value) noexcept {
355  value *= Pi<NumericType> / static_cast<NumericType>(139968000000.0L);
356 }
357 
358 template <>
359 template <typename NumericType>
360 inline constexpr void
361 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcsecondPerSquareSecond>::
362  FromStandard(NumericType& value) noexcept {
363  value *= static_cast<NumericType>(648000.0L) / Pi<NumericType>;
364 }
365 
366 template <>
367 template <typename NumericType>
368 inline constexpr void
369 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcsecondPerSquareSecond>::
370  ToStandard(NumericType& value) noexcept {
371  value *= Pi<NumericType> / static_cast<NumericType>(648000.0L);
372 }
373 
374 template <>
375 template <typename NumericType>
376 inline constexpr void
377 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcsecondPerSquareMinute>::
378  FromStandard(NumericType& value) noexcept {
379  value *= static_cast<NumericType>(2332800000.0L) / Pi<NumericType>;
380 }
381 
382 template <>
383 template <typename NumericType>
384 inline constexpr void
385 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcsecondPerSquareMinute>::
386  ToStandard(NumericType& value) noexcept {
387  value *= Pi<NumericType> / static_cast<NumericType>(2332800000.0L);
388 }
389 
390 template <>
391 template <typename NumericType>
392 inline constexpr void
393 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcsecondPerSquareHour>::
394  FromStandard(NumericType& value) noexcept {
395  value *= static_cast<NumericType>(8398080000000.0L) / Pi<NumericType>;
396 }
397 
398 template <>
399 template <typename NumericType>
400 inline constexpr void
401 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::ArcsecondPerSquareHour>::
402  ToStandard(NumericType& value) noexcept {
403  value *= Pi<NumericType> / static_cast<NumericType>(8398080000000.0L);
404 }
405 
406 template <>
407 template <typename NumericType>
408 inline constexpr void
409 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RevolutionPerSquareSecond>::
410  FromStandard(NumericType& value) noexcept {
411  value *= static_cast<NumericType>(0.5L) / Pi<NumericType>;
412 }
413 
414 template <>
415 template <typename NumericType>
416 inline constexpr void
417 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RevolutionPerSquareSecond>::
418  ToStandard(NumericType& value) noexcept {
419  value *= static_cast<NumericType>(2.0L) * Pi<NumericType>;
420 }
421 
422 template <>
423 template <typename NumericType>
424 inline constexpr void
425 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RevolutionPerSquareMinute>::
426  FromStandard(NumericType& value) noexcept {
427  value *= static_cast<NumericType>(1800.0L) / Pi<NumericType>;
428 }
429 
430 template <>
431 template <typename NumericType>
432 inline constexpr void
433 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RevolutionPerSquareMinute>::
434  ToStandard(NumericType& value) noexcept {
435  value *= Pi<NumericType> / static_cast<NumericType>(1800.0L);
436 }
437 
438 template <>
439 template <typename NumericType>
440 inline constexpr void
441 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RevolutionPerSquareHour>::
442  FromStandard(NumericType& value) noexcept {
443  value *= static_cast<NumericType>(6480000.0L) / Pi<NumericType>;
444 }
445 
446 template <>
447 template <typename NumericType>
448 inline constexpr void
449 Conversion<Unit::AngularAcceleration, Unit::AngularAcceleration::RevolutionPerSquareHour>::
450  ToStandard(NumericType& value) noexcept {
451  value *= Pi<NumericType> / static_cast<NumericType>(6480000.0L);
452 }
453 
454 template <typename NumericType>
455 inline const std::map<Unit::AngularAcceleration,
456  std::function<void(NumericType* values, const std::size_t size)>>
457  MapOfConversionsFromStandard<Unit::AngularAcceleration, NumericType>{
459  Conversions<Unit::AngularAcceleration,
460  Unit::AngularAcceleration::RadianPerSquareSecond>::FromStandard<NumericType> },
462  Conversions<Unit::AngularAcceleration,
463  Unit::AngularAcceleration::RadianPerSquareMinute>::FromStandard<NumericType> },
465  Conversions<Unit::AngularAcceleration,
466  Unit::AngularAcceleration::RadianPerSquareHour>::FromStandard<NumericType> },
468  Conversions<Unit::AngularAcceleration,
469  Unit::AngularAcceleration::DegreePerSquareSecond>::FromStandard<NumericType> },
471  Conversions<Unit::AngularAcceleration,
472  Unit::AngularAcceleration::DegreePerSquareMinute>::FromStandard<NumericType> },
474  Conversions<Unit::AngularAcceleration,
475  Unit::AngularAcceleration::DegreePerSquareHour>::FromStandard<NumericType> },
477  Conversions<
479  Unit::AngularAcceleration::ArcminutePerSquareSecond>::FromStandard<NumericType> },
481  Conversions<
483  Unit::AngularAcceleration::ArcminutePerSquareMinute>::FromStandard<NumericType> },
485  Conversions<Unit::AngularAcceleration,
486  Unit::AngularAcceleration::ArcminutePerSquareHour>::FromStandard<NumericType> },
488  Conversions<
490  Unit::AngularAcceleration::ArcsecondPerSquareSecond>::FromStandard<NumericType> },
492  Conversions<
494  Unit::AngularAcceleration::ArcsecondPerSquareMinute>::FromStandard<NumericType> },
496  Conversions<Unit::AngularAcceleration,
497  Unit::AngularAcceleration::ArcsecondPerSquareHour>::FromStandard<NumericType> },
499  Conversions<
501  Unit::AngularAcceleration::RevolutionPerSquareSecond>::FromStandard<NumericType>},
503  Conversions<
505  Unit::AngularAcceleration::RevolutionPerSquareMinute>::FromStandard<NumericType>},
507  Conversions<
509  Unit::AngularAcceleration::RevolutionPerSquareHour>::FromStandard<NumericType> },
510 };
511 
512 template <typename NumericType>
513 inline const std::map<Unit::AngularAcceleration,
514  std::function<void(NumericType* const values, const std::size_t size)>>
515  MapOfConversionsToStandard<Unit::AngularAcceleration, NumericType>{
517  Conversions<Unit::AngularAcceleration,
518  Unit::AngularAcceleration::RadianPerSquareSecond>::ToStandard<NumericType> },
520  Conversions<Unit::AngularAcceleration,
521  Unit::AngularAcceleration::RadianPerSquareMinute>::ToStandard<NumericType> },
523  Conversions<Unit::AngularAcceleration,
524  Unit::AngularAcceleration::RadianPerSquareHour>::ToStandard<NumericType> },
526  Conversions<Unit::AngularAcceleration,
527  Unit::AngularAcceleration::DegreePerSquareSecond>::ToStandard<NumericType> },
529  Conversions<Unit::AngularAcceleration,
530  Unit::AngularAcceleration::DegreePerSquareMinute>::ToStandard<NumericType> },
532  Conversions<Unit::AngularAcceleration,
533  Unit::AngularAcceleration::DegreePerSquareHour>::ToStandard<NumericType> },
535  Conversions<Unit::AngularAcceleration,
536  Unit::AngularAcceleration::ArcminutePerSquareSecond>::ToStandard<NumericType> },
538  Conversions<Unit::AngularAcceleration,
539  Unit::AngularAcceleration::ArcminutePerSquareMinute>::ToStandard<NumericType> },
541  Conversions<Unit::AngularAcceleration,
542  Unit::AngularAcceleration::ArcminutePerSquareHour>::ToStandard<NumericType> },
544  Conversions<Unit::AngularAcceleration,
545  Unit::AngularAcceleration::ArcsecondPerSquareSecond>::ToStandard<NumericType> },
547  Conversions<Unit::AngularAcceleration,
548  Unit::AngularAcceleration::ArcsecondPerSquareMinute>::ToStandard<NumericType> },
550  Conversions<Unit::AngularAcceleration,
551  Unit::AngularAcceleration::ArcsecondPerSquareHour>::ToStandard<NumericType> },
553  Conversions<
555  Unit::AngularAcceleration::RevolutionPerSquareSecond>::ToStandard<NumericType>},
557  Conversions<
559  Unit::AngularAcceleration::RevolutionPerSquareMinute>::ToStandard<NumericType>},
561  Conversions<Unit::AngularAcceleration,
562  Unit::AngularAcceleration::RevolutionPerSquareHour>::ToStandard<NumericType> },
563 };
564 
565 } // namespace Internal
566 
567 } // namespace PhQ
568 
569 #endif // PHQ_UNIT_ANGULAR_ACCELERATION_HPP
ElectricCurrent
Electric current units.
Mass
Mass units.
Definition: Mass.hpp:53
Length
Length units.
Definition: Length.hpp:53
SubstanceAmount
Amount of substance units.
AngularAcceleration
Angular acceleration units.
@ ArcminutePerSquareMinute
Arcminute per square minute (arcmin/min^2) angular acceleration unit.
@ RevolutionPerSquareMinute
Revolution per square minute (rev/min^2) angular acceleration unit.
@ DegreePerSquareSecond
Degree per square second (deg/s^2) angular acceleration unit.
@ ArcminutePerSquareHour
Arcminute per square hour (arcmin/hr^2) angular acceleration unit.
@ RadianPerSquareHour
Radian per square hour (rad/hr^2) angular acceleration unit.
@ DegreePerSquareHour
Degree per square hour (deg/hr^2) angular acceleration unit.
@ RevolutionPerSquareSecond
Revolution per square second (rev/s^2) angular acceleration unit.
@ ArcsecondPerSquareSecond
Arcsecond per square second (arcsec/s^2) angular acceleration unit.
@ ArcsecondPerSquareHour
Arcsecond per square hour (arcsec/hr^2) angular acceleration unit.
@ ArcminutePerSquareSecond
Arcminute per square second (arcmin/s^2) angular acceleration unit.
@ ArcsecondPerSquareMinute
Arcsecond per square minute (arcsec/min^2) angular acceleration unit.
@ DegreePerSquareMinute
Degree per square minute (deg/min^2) angular acceleration unit.
@ RadianPerSquareMinute
Radian per square minute (rad/min^2) angular acceleration unit.
@ RevolutionPerSquareHour
Revolution per square hour (rev/hr^2) angular acceleration unit.
@ RadianPerSquareSecond
Radian per square second (rad/s^2) angular acceleration unit.
Temperature
Temperature units. Not to be confused with temperature difference units. For example,...
Definition: Temperature.hpp:55
Time
Time units.
Definition: Time.hpp:53
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)