OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
speed.hpp
1#pragma once
2#include <ossia/network/dataspace/dataspace_base.hpp>
3#include <ossia/network/dataspace/dataspace_base_defs_fwd.hpp>
4#include <ossia/network/domain/domain.hpp>
5
6namespace ossia
7{
8
9template <typename T>
10struct speed_ratio;
11
12using meter_per_second_u = speed_ratio<std::ratio<1>>;
13using miles_per_hour_u = speed_ratio<std::ratio<254 * 12 * 5280, 3600 * 10000>>;
14using kilometer_per_hour_u = speed_ratio<std::ratio<1000, 3600>>;
15using knot_u = speed_ratio<std::ratio<1852, 3600>>;
16using foot_per_hour_u = speed_ratio<std::ratio<254 * 12, 3600 * 10000>>;
17using foot_per_second_u = speed_ratio<std::ratio<254 * 12, 10000>>;
18struct speed_u;
19template <typename Impl>
20struct speed_unit
21{
22 using is_unit = std::true_type;
23 using neutral_unit = meter_per_second_u;
24 using value_type = float;
25 using concrete_type = Impl;
26 using dataspace_type = speed_u;
27 using is_multidimensional = std::false_type;
28};
29
30template <typename T>
31struct speed_ratio : public linear_unit<speed_unit<speed_ratio<T>>, T>
32{
33 using linear_unit<speed_unit<speed_ratio<T>>, T>::linear_unit;
34
35 static ossia::domain domain() { return {}; }
36
37 static constexpr auto bounding() { return ossia::bounding_mode::FREE; }
38};
39
40template <>
41struct unit_traits<meter_per_second_u>
42{
43 static constexpr auto text() { constexpr_return(ossia::make_string_array("m/s")); }
44};
45
46template <>
47struct unit_traits<miles_per_hour_u>
48{
49 static constexpr auto text()
50 {
51 constexpr_return(ossia::make_string_array("mph", "mi/h"));
52 }
53};
54
55template <>
56struct unit_traits<kilometer_per_hour_u>
57{
58 static constexpr auto text()
59 {
60 constexpr_return(ossia::make_string_array("km/h", "kmph"));
61 }
62};
63
64template <>
65struct unit_traits<knot_u>
66{
67 static constexpr auto text() { constexpr_return(ossia::make_string_array("kn")); }
68};
69
70template <>
71struct unit_traits<foot_per_hour_u>
72{
73 static constexpr auto text() { constexpr_return(ossia::make_string_array("ft/h")); }
74};
75
76template <>
77struct unit_traits<foot_per_second_u>
78{
79 static constexpr auto text() { constexpr_return(ossia::make_string_array("ft/s")); }
80};
81}
Definition git_info.h:7
domain A domain of values
Definition domain_base.hpp:23