2#include <ossia/network/dataspace/dataspace_base.hpp>
3#include <ossia/network/domain/domain.hpp>
8template <
typename Impl>
11 using is_unit = std::true_type;
12 using is_multidimensional = std::true_type;
13 using dataspace_type = position_u;
14 using neutral_unit = cartesian_3d_u;
15 using concrete_type = Impl;
18struct OSSIA_EXPORT cartesian_3d_u :
public position_unit<cartesian_3d_u>
20 static constexpr auto text()
22 constexpr_return(ossia::make_string_array(
"cart3D",
"xyz"));
24 static constexpr auto array_parameters()
26 constexpr_return(ossia::make_string_view(
"xyz"));
28 static constexpr auto units()
30 constexpr_return(ossia::make_string_array(
"distance.m",
"distance.m",
"distance.m"));
32 using value_type = vec3f;
33 static constexpr strong_value<neutral_unit>
34 to_neutral(strong_value<concrete_type> self)
39 static constexpr value_type from_neutral(strong_value<neutral_unit> self)
41 return self.dataspace_value;
44 static ossia::vecf_domain<3> domain()
46 return vecf_domain<3>{
47 ossia::make_vec(-1.f, -1.f, -1.f), ossia::make_vec(1.f, 1.f, 1.f)};
50 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
53struct OSSIA_EXPORT cartesian_2d_u :
public position_unit<cartesian_2d_u>
55 static constexpr auto text()
57 constexpr_return(ossia::make_string_array(
"cart2D",
"xy"));
59 static constexpr auto array_parameters()
61 constexpr_return(ossia::make_string_view(
"xy"));
63 static constexpr auto units()
65 constexpr_return(ossia::make_string_array(
"distance.m",
"distance.m"));
67 using value_type = vec2f;
68 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
70 return {self.dataspace_value[0], self.dataspace_value[1], 0.f};
73 static value_type from_neutral(strong_value<neutral_unit> self)
75 return {self.dataspace_value[0], self.dataspace_value[1]};
78 static ossia::vecf_domain<2> domain()
80 return vecf_domain{ossia::make_vec(-1.f, -1.f), ossia::make_vec(1.f, 1.f)};
83 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
86struct OSSIA_EXPORT spherical_u :
public position_unit<spherical_u>
88 static constexpr auto text()
90 constexpr_return(ossia::make_string_array(
"spherical",
"rtp"));
92 static constexpr auto array_parameters()
94 constexpr_return(ossia::make_string_view(
"rtp"));
96 static constexpr auto units()
99 ossia::make_string_array(
"distance.m",
"angle.radiant",
"angle.radiant"));
101 using value_type = vec3f;
102 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self);
104 static value_type from_neutral(strong_value<neutral_unit> self);
106 static ossia::vecf_domain<3> domain()
108 return vecf_domain<3>{
109 ossia::make_vec(0.f, -pi, -half_pi), ossia::make_vec(1.f, pi, half_pi)};
112 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
115struct OSSIA_EXPORT polar_u :
public position_unit<polar_u>
117 static constexpr auto text()
119 constexpr_return(ossia::make_string_array(
"polar",
"rp"));
121 static constexpr auto array_parameters()
123 constexpr_return(ossia::make_string_view(
"rp"));
125 static constexpr auto units()
127 constexpr_return(ossia::make_string_array(
"distance.m",
"angle.radiant"));
129 using value_type = vec2f;
130 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
132 const auto r = self.dataspace_value[0];
133 const auto t = self.dataspace_value[1];
135 return {(float)(std::cos(t) * r), (
float)(std::sin(t) * r)};
138 static value_type from_neutral(strong_value<neutral_unit> self)
140 const auto x = self.dataspace_value[0];
141 const auto y = self.dataspace_value[1];
143 return {(float)(ossia::norm(x, y)), (
float)(std::atan2(y, x))};
146 static ossia::vecf_domain<2> domain()
148 return vecf_domain<2>{ossia::make_vec(0.f, -pi), ossia::make_vec(1.f, pi)};
151 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
154struct OSSIA_EXPORT aed_u :
public position_unit<aed_u>
156 static constexpr auto text()
158 constexpr_return(ossia::make_string_array(
"AED",
"aed"));
160 static constexpr auto array_parameters()
162 constexpr_return(ossia::make_string_view(
"aed"));
164 static constexpr auto units()
167 ossia::make_string_array(
"angle.degree",
"angle.degree",
"distance.m"));
169 using value_type = vec3f;
170 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self);
172 static value_type from_neutral(strong_value<neutral_unit> self);
174 static ossia::vecf_domain<3> domain()
176 return vecf_domain<3>{
177 ossia::make_vec(-180.f, -180.f, 0.f), ossia::make_vec(180.f, 180.f, 1.f)};
180 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
183struct OSSIA_EXPORT ad_u :
public position_unit<ad_u>
185 static constexpr auto text()
187 constexpr_return(ossia::make_string_array(
"AD",
"ad"));
189 static constexpr auto array_parameters()
191 constexpr_return(ossia::make_string_view(
"ad"));
193 static constexpr auto units()
195 constexpr_return(ossia::make_string_array(
"angle.degree",
"distance.m"));
197 using value_type = vec2f;
198 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
200 const auto a = self.dataspace_value[0] * deg_to_rad - half_pi;
201 const auto d = self.dataspace_value[1];
203 return {(float)(std::sin(-a) * d), (
float)(std::cos(-a) * d), 0.f};
206 static value_type from_neutral(strong_value<neutral_unit> self)
208 const auto x = self.dataspace_value[0];
209 const auto y = self.dataspace_value[1];
212 -(float)(std::atan2(y, x) + half_pi * rad_to_deg), (
float)(ossia::norm(x, y))};
215 static ossia::vecf_domain<2> domain()
217 return vecf_domain<2>{ossia::make_vec(-180.f, 0.f), ossia::make_vec(180.f, 0.f)};
220 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
223struct OSSIA_EXPORT opengl_u :
public position_unit<opengl_u>
225 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"openGL")); }
226 static constexpr auto array_parameters()
228 constexpr_return(ossia::make_string_view(
"xyz"));
230 static constexpr auto units()
232 constexpr_return(ossia::make_string_array(
"distance.m",
"distance.m",
"distance.m"));
234 using value_type = vec3f;
235 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
237 return {self.dataspace_value[0], -self.dataspace_value[2], self.dataspace_value[1]};
240 static value_type from_neutral(strong_value<neutral_unit> self)
242 return {self.dataspace_value[0], self.dataspace_value[2], -self.dataspace_value[1]};
245 static ossia::vecf_domain<3> domain()
248 ossia::make_vec(-1.f, -1.f, -1.f), ossia::make_vec(1.f, 1.f, 1.f)};
251 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
254struct OSSIA_EXPORT cylindrical_u :
public position_unit<cylindrical_u>
256 static constexpr auto text()
258 constexpr_return(ossia::make_string_array(
"cylindrical",
"rtz"));
260 static constexpr auto array_parameters()
262 constexpr_return(ossia::make_string_view(
"rtz"));
264 static constexpr auto units()
267 ossia::make_string_array(
"distance.m",
"angle.degree",
"distance.m"));
269 using value_type = vec3f;
270 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self);
272 static value_type from_neutral(strong_value<neutral_unit> self);
274 static ossia::vecf_domain<3> domain()
276 return vecf_domain<3>{
277 ossia::make_vec(0.f, -180.f, 0.f), ossia::make_vec(1.f, 180.f, 1.f)};
279 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
282struct OSSIA_EXPORT azd_u :
public position_unit<azd_u>
284 static constexpr auto text()
286 constexpr_return(ossia::make_string_array(
"AZD",
"azd"));
288 static constexpr auto array_parameters()
290 constexpr_return(ossia::make_string_view(
"azd"));
292 static constexpr auto units()
295 ossia::make_string_array(
"angle.degree",
"distance.m",
"distance.m"));
297 using value_type = vec3f;
298 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self);
300 static value_type from_neutral(strong_value<neutral_unit> self);
302 static ossia::vecf_domain<3> domain()
304 return vecf_domain<3>{
305 ossia::make_vec(-180.f, -1.f, 0.f), ossia::make_vec(180.f, 1.f, 1.f)};
307 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }