Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Loading...
Searching...
No Matches
AngularSpeed.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_SPEED_HPP
26#define PHQ_UNIT_ANGULAR_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
48namespace PhQ {
49
50namespace Unit {
51
52/// \brief Angular speed units.
53enum class AngularSpeed : int8_t {
54 /// \brief Radian per second (rad/s) angular speed unit.
56
57 /// \brief Radian per minute (rad/min) angular speed unit.
59
60 /// \brief Radian per hour (rad/hr) angular speed unit.
62
63 /// \brief Degree per second (deg/s) angular speed unit.
65
66 /// \brief Degree per minute (deg/min) angular speed unit.
68
69 /// \brief Degree per hour (deg/hr) angular speed unit.
71
72 /// \brief Arcminute per second (arcmin/s) angular speed unit.
74
75 /// \brief Arcminute per minute (arcmin/min) angular speed unit.
77
78 /// \brief Arcminute per hour (arcmin/hr) angular speed unit.
80
81 /// \brief Arcsecond per second (arcsec/s) angular speed unit.
83
84 /// \brief Arcsecond per minute (arcsec/min) angular speed unit.
86
87 /// \brief Arcsecond per hour (arcsec/hr) angular speed unit.
89
90 /// \brief Revolution per second (rev/s) angular speed unit.
92
93 /// \brief Revolution per minute (rev/min) angular speed unit.
95
96 /// \brief Revolution per hour (rev/hr) angular speed unit.
98};
99
100} // namespace Unit
101
102/// \brief Standard angular speed unit: radian per second (rad/s).
103template <>
104inline constexpr const Unit::
105 AngularSpeed Standard<Unit::AngularSpeed>{Unit::AngularSpeed::RadianPerSecond};
106
107/// \brief Physical dimension set of angular speed units.
108template <>
109inline constexpr const Dimensions RelatedDimensions<Unit::AngularSpeed>{
110 Dimensions{Dimension::Time{-1}, Dimension::Length{0}, Dimension::Mass{0},
111 Dimension::ElectricCurrent{0}, Dimension::Temperature{0},
112 Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
113};
114
115inline std::ostream& operator<<(std::ostream& stream, const Unit::AngularSpeed unit) {
116 stream << Abbreviation(unit);
117 return stream;
118}
119
120namespace Internal {
121
122template <>
123inline const std::map<UnitSystem, Unit::AngularSpeed> ConsistentUnits<Unit::AngularSpeed>{
128};
129
130template <>
131inline const std::map<Unit::AngularSpeed, UnitSystem> RelatedUnitSystems<Unit::AngularSpeed>{};
132
133template <>
134inline const std::map<Unit::AngularSpeed, std::string_view> Abbreviations<Unit::AngularSpeed>{
150};
151
152// clang-format off
153
154template <>
155inline const std::unordered_map<std::string_view, Unit::AngularSpeed> Spellings<Unit::AngularSpeed>{
174};
175
176// clang-format on
177
178template <>
179template <typename NumericType>
180inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerSecond>::
181 FromStandard(NumericType& /*value*/) noexcept {}
182
183template <>
184template <typename NumericType>
185inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerSecond>::
186 ToStandard(NumericType& /*value*/) noexcept {}
187
188template <>
189template <typename NumericType>
190inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerMinute>::
191 FromStandard(NumericType& value) noexcept {
192 value *= static_cast<NumericType>(60.0L);
193}
194
195template <>
196template <typename NumericType>
197inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerMinute>::
198 ToStandard(NumericType& value) noexcept {
199 value /= static_cast<NumericType>(60.0L);
200}
201
202template <>
203template <typename NumericType>
204inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerHour>::
205 FromStandard(NumericType& value) noexcept {
206 value *= static_cast<NumericType>(3600.0L);
207}
208
209template <>
210template <typename NumericType>
211inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerHour>::ToStandard(
212 NumericType& value) noexcept {
213 value /= static_cast<NumericType>(3600.0L);
214}
215
216template <>
217template <typename NumericType>
218inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerSecond>::
219 FromStandard(NumericType& value) noexcept {
220 value *= static_cast<NumericType>(180.0L) / Pi<NumericType>;
221}
222
223template <>
224template <typename NumericType>
225inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerSecond>::
226 ToStandard(NumericType& value) noexcept {
227 value *= Pi<NumericType> / static_cast<NumericType>(180.0L);
228}
229
230template <>
231template <typename NumericType>
232inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerMinute>::
233 FromStandard(NumericType& value) noexcept {
234 value *= static_cast<NumericType>(10800.0L) / Pi<NumericType>;
235}
236
237template <>
238template <typename NumericType>
239inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerMinute>::
240 ToStandard(NumericType& value) noexcept {
241 value *= Pi<NumericType> / static_cast<NumericType>(10800.0L);
242}
243
244template <>
245template <typename NumericType>
246inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerHour>::
247 FromStandard(NumericType& value) noexcept {
248 value *= static_cast<NumericType>(648000.0L) / Pi<NumericType>;
249}
250
251template <>
252template <typename NumericType>
253inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerHour>::ToStandard(
254 NumericType& value) noexcept {
255 value *= Pi<NumericType> / static_cast<NumericType>(648000.0L);
256}
257
258template <>
259template <typename NumericType>
260inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerSecond>::
261 FromStandard(NumericType& value) noexcept {
262 value *= static_cast<NumericType>(10800.0L) / Pi<NumericType>;
263}
264
265template <>
266template <typename NumericType>
267inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerSecond>::
268 ToStandard(NumericType& value) noexcept {
269 value *= Pi<NumericType> / static_cast<NumericType>(10800.0L);
270}
271
272template <>
273template <typename NumericType>
274inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerMinute>::
275 FromStandard(NumericType& value) noexcept {
276 value *= static_cast<NumericType>(648000.0L) / Pi<NumericType>;
277}
278
279template <>
280template <typename NumericType>
281inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerMinute>::
282 ToStandard(NumericType& value) noexcept {
283 value *= Pi<NumericType> / static_cast<NumericType>(648000.0L);
284}
285
286template <>
287template <typename NumericType>
288inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerHour>::
289 FromStandard(NumericType& value) noexcept {
290 value *= static_cast<NumericType>(38880000.0L) / Pi<NumericType>;
291}
292
293template <>
294template <typename NumericType>
295inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerHour>::
296 ToStandard(NumericType& value) noexcept {
297 value *= Pi<NumericType> / static_cast<NumericType>(38880000.0L);
298}
299
300template <>
301template <typename NumericType>
302inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerSecond>::
303 FromStandard(NumericType& value) noexcept {
304 value *= static_cast<NumericType>(648000.0L) / Pi<NumericType>;
305}
306
307template <>
308template <typename NumericType>
309inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerSecond>::
310 ToStandard(NumericType& value) noexcept {
311 value *= Pi<NumericType> / static_cast<NumericType>(648000.0L);
312}
313
314template <>
315template <typename NumericType>
316inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerMinute>::
317 FromStandard(NumericType& value) noexcept {
318 value *= static_cast<NumericType>(38880000.0L) / Pi<NumericType>;
319}
320
321template <>
322template <typename NumericType>
323inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerMinute>::
324 ToStandard(NumericType& value) noexcept {
325 value *= Pi<NumericType> / static_cast<NumericType>(38880000.0L);
326}
327
328template <>
329template <typename NumericType>
330inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerHour>::
331 FromStandard(NumericType& value) noexcept {
332 value *= static_cast<NumericType>(2332800000.0L) / Pi<NumericType>;
333}
334
335template <>
336template <typename NumericType>
337inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerHour>::
338 ToStandard(NumericType& value) noexcept {
339 value *= Pi<NumericType> / static_cast<NumericType>(2332800000.0L);
340}
341
342template <>
343template <typename NumericType>
344inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerSecond>::
345 FromStandard(NumericType& value) noexcept {
346 value *= static_cast<NumericType>(0.5L) / Pi<NumericType>;
347}
348
349template <>
350template <typename NumericType>
351inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerSecond>::
352 ToStandard(NumericType& value) noexcept {
353 value *= static_cast<NumericType>(2.0L) * Pi<NumericType>;
354}
355
356template <>
357template <typename NumericType>
358inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerMinute>::
359 FromStandard(NumericType& value) noexcept {
360 value *= static_cast<NumericType>(30.0L) / Pi<NumericType>;
361}
362
363template <>
364template <typename NumericType>
365inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerMinute>::
366 ToStandard(NumericType& value) noexcept {
367 value *= Pi<NumericType> / static_cast<NumericType>(30.0L);
368}
369
370template <>
371template <typename NumericType>
372inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerHour>::
373 FromStandard(NumericType& value) noexcept {
374 value *= static_cast<NumericType>(1800.0L) / Pi<NumericType>;
375}
376
377template <>
378template <typename NumericType>
379inline constexpr void Conversion<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerHour>::
380 ToStandard(NumericType& value) noexcept {
381 value *= Pi<NumericType> / static_cast<NumericType>(1800.0L);
382}
383
384template <typename NumericType>
385inline const std::
386 map<Unit::AngularSpeed, std::function<void(NumericType* values, const std::size_t size)>>
387 MapOfConversionsFromStandard<Unit::AngularSpeed, NumericType>{
389 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerSecond>::
390 FromStandard<NumericType>},
392 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerMinute>::
393 FromStandard<NumericType>},
395 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerHour>::
396 FromStandard<NumericType>},
398 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerSecond>::
399 FromStandard<NumericType>},
401 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerMinute>::
402 FromStandard<NumericType>},
404 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerHour>::
405 FromStandard<NumericType>},
407 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerSecond>::
408 FromStandard<NumericType>},
410 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerMinute>::
411 FromStandard<NumericType>},
413 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerHour>::
414 FromStandard<NumericType>},
416 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerSecond>::
417 FromStandard<NumericType>},
419 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerMinute>::
420 FromStandard<NumericType>},
422 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerHour>::
423 FromStandard<NumericType>},
425 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerSecond>::
426 FromStandard<NumericType>},
428 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerMinute>::
429 FromStandard<NumericType>},
431 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerHour>::
432 FromStandard<NumericType>},
433};
434
435template <typename NumericType>
436inline const std::map<Unit::AngularSpeed,
437 std::function<void(NumericType* const values, const std::size_t size)>>
438 MapOfConversionsToStandard<Unit::AngularSpeed, NumericType>{
440 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerSecond>::
441 ToStandard<NumericType> },
443 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerMinute>::
444 ToStandard<NumericType> },
446 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RadianPerHour>::ToStandard<NumericType>},
448 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerSecond>::
449 ToStandard<NumericType> },
451 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerMinute>::
452 ToStandard<NumericType> },
454 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::DegreePerHour>::ToStandard<NumericType>},
456 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerSecond>::
457 ToStandard<NumericType> },
459 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerMinute>::
460 ToStandard<NumericType> },
462 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcminutePerHour>::
463 ToStandard<NumericType> },
465 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerSecond>::
466 ToStandard<NumericType> },
468 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerMinute>::
469 ToStandard<NumericType> },
471 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::ArcsecondPerHour>::
472 ToStandard<NumericType> },
474 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerSecond>::
475 ToStandard<NumericType> },
477 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerMinute>::
478 ToStandard<NumericType> },
480 Conversions<Unit::AngularSpeed, Unit::AngularSpeed::RevolutionPerHour>::
481 ToStandard<NumericType> },
482};
483
484} // namespace Internal
485
486} // namespace PhQ
487
488#endif // PHQ_UNIT_ANGULAR_SPEED_HPP
AngularSpeed
Angular speed units.
@ ArcminutePerHour
Arcminute per hour (arcmin/hr) angular speed unit.
@ ArcminutePerSecond
Arcminute per second (arcmin/s) angular speed unit.
@ DegreePerHour
Degree per hour (deg/hr) angular speed unit.
@ RevolutionPerMinute
Revolution per minute (rev/min) angular speed unit.
@ RevolutionPerSecond
Revolution per second (rev/s) angular speed unit.
@ ArcsecondPerSecond
Arcsecond per second (arcsec/s) angular speed unit.
@ RevolutionPerHour
Revolution per hour (rev/hr) angular speed unit.
@ RadianPerSecond
Radian per second (rad/s) angular speed unit.
@ ArcminutePerMinute
Arcminute per minute (arcmin/min) angular speed unit.
@ RadianPerHour
Radian per hour (rad/hr) angular speed unit.
@ ArcsecondPerMinute
Arcsecond per minute (arcsec/min) angular speed unit.
@ DegreePerSecond
Degree per second (deg/s) angular speed unit.
@ DegreePerMinute
Degree per minute (deg/min) angular speed unit.
@ ArcsecondPerHour
Arcsecond per hour (arcsec/hr) angular speed unit.
@ RadianPerMinute
Radian per minute (rad/min) angular speed unit.
Namespace that encompasses all of the Physical Quantities library's content.
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)
@ 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