OSSIA
Open Scenario System for Interactive Application
angle.hpp
1 #pragma once
2 #include <ossia/detail/math.hpp>
3 #include <ossia/network/dataspace/dataspace_base.hpp>
4 #include <ossia/network/domain/domain_base_impl.hpp>
5 namespace ossia
6 {
7 struct angle_u;
8 struct radian_u;
9 template <typename Impl>
10 struct angle_unit
11 {
12  using is_unit = std::true_type;
13  using neutral_unit = radian_u;
14  using value_type = float;
15  using concrete_type = Impl;
16  using dataspace_type = angle_u;
17  using is_multidimensional = std::false_type;
18 };
19 
20 struct OSSIA_EXPORT radian_u : public angle_unit<radian_u>
21 {
22  static constexpr auto text()
23  {
24  constexpr_return(ossia::make_string_array("radian", "rad"));
25  }
26 
27  static constexpr strong_value<neutral_unit>
28  to_neutral(strong_value<concrete_type> self)
29  {
30  return self;
31  }
32 
33  static constexpr value_type from_neutral(strong_value<neutral_unit> self)
34  {
35  return self.dataspace_value;
36  }
37 
38  static ossia::domain_base<float> domain() { return {0.f, float(ossia::two_pi)}; }
39 
40  static constexpr auto bounding() { return ossia::bounding_mode::WRAP; }
41 };
42 
43 struct OSSIA_EXPORT degree_u : public angle_unit<degree_u>
44 {
45  static constexpr auto text()
46  {
47  constexpr_return(ossia::make_string_array("degree", "deg"));
48  }
49 
50  static constexpr strong_value<neutral_unit>
51  to_neutral(strong_value<concrete_type> self)
52  {
53  return {self.dataspace_value * float(ossia::deg_to_rad)};
54  }
55 
56  static constexpr value_type from_neutral(strong_value<neutral_unit> self)
57  {
58  return self.dataspace_value * float(ossia::rad_to_deg);
59  }
60 
61  static ossia::domain_base<float> domain() { return {0.f, 360.f}; }
62 
63  static constexpr auto bounding() { return ossia::bounding_mode::WRAP; }
64 };
65 }
Definition: git_info.h:7