20 { T::radians_per_rep } -> std::convertible_to<double>;
21 { T::unit_label } -> std::convertible_to<std::string_view>;
25 template<std::
floating_po
int Rep, AngularUnitTraits Units>
33 template<std::convertible_to<Rep> Rep2>
39 template<AngularUnitTraits Units2>
45 template<std::convertible_to<Rep> Rep2, AngularUnitTraits Units2>
51 constexpr Rep
count()
const {
return value_; }
72 template<std::convertible_to<Rep> Rep2>
77 template<std::convertible_to<Rep> Rep2>
84 template<std::convertible_to<Rep> Rep2>
95 std::floating_point
Rep1,
97 std::floating_point
Rep2,
110 std::floating_point
Rep1,
112 std::floating_point
Rep2,
125 std::floating_point
Rep1,
127 std::floating_point
Rep2,
138 std::floating_point
Rep1,
140 std::floating_point
Rep2,
150 template<std::
floating_po
int Rep, AngularUnitTraits Units>
153 return o <<
angle.
count() <<
' ' << Units::unit_label;
158 template<std::
floating_po
int Rep, AngularUnitTraits Units>
168 std::floating_point Rep1,
170 std::floating_point Rep2,
173struct std::common_type<
osc::Angle<Rep1, Units1>,
osc::Angle<Rep2, Units2>> {
175 using units =
typename std::conditional_t<(Units1::radians_per_rep > Units2::radians_per_rep), Units1, Units2>;
179template<std::
floating_po
int Rep, osc::AngularUnitTraits Units>
180struct std::formatter<
osc::Angle<Rep, Units>> final {
181 template<
class ParseCtx>
182 constexpr auto parse(ParseCtx& ctx) {
return inner_.parse(ctx); }
184 template<
class FmtCtx>
187 auto it = inner_.format(angle.
count(), ctx);
189 it = std::ranges::copy(Units::unit_label, it).out;
193 std::formatter<Rep> inner_;
201 struct RadianAngularUnitTraits
final {
202 static inline constexpr double radians_per_rep = 1.0;
203 static inline constexpr std::string_view unit_label =
"rad";
219 struct DegreesAngularUnitTraits
final {
220 static inline constexpr double radians_per_rep = std::numbers::pi_v<double>/180.0;
221 static inline constexpr std::string_view unit_label =
"deg";
237 struct TurnsAngularUnitTraits
final {
238 static inline constexpr double radians_per_rep = 2.0*std::numbers::pi_v<double>;
239 static inline constexpr std::string_view unit_label =
"turn";
263 std::floating_point
Rep1,
265 std::floating_point
Rep2,
270 using CA = std::common_type_t<
decltype(x),
decltype(y)>;
271 return CA{std::fmod(
CA{x}.count(),
CA{y}.count())};
278 std::floating_point
Rep1,
280 std::floating_point
Rep2,
283 requires (not std::is_same_v<Units1, Units2>)
286 using CA = std::common_type_t<
decltype(x),
decltype(y)>;
294 std::floating_point
Rep1,
296 std::floating_point
Rep2,
299 requires (not std::is_same_v<Units1, Units2>)
302 using CA = std::common_type_t<
decltype(x),
decltype(y)>;
310 std::floating_point Rep,
311 AngularUnitTraits
Units,
312 std::convertible_to<Angle<Rep, Units>>
AngleMin,
313 std::convertible_to<Angle<Rep, Units>>
AngleMax
316 not std::is_same_v<Angle<Rep, Units>,
AngleMin>
or
317 not std::is_same_v<Angle<Rep, Units>,
AngleMax>
or
318 not std::is_same_v<AngleMin, AngleMax>
constexpr friend Angle operator*(const Angle &lhs, const Rep2 &scalar)
Definition angle.h:78
constexpr friend Angle & operator+=(Angle &lhs, const Angle &rhs)
Definition angle.h:59
constexpr Angle(const Angle< Rep2, Units2 > &other)
Definition angle.h:46
constexpr Angle()=default
Rep value_type
Definition angle.h:28
constexpr friend Angle & operator-=(Angle &lhs, const Angle &rhs)
Definition angle.h:65
constexpr Angle operator-() const
Definition angle.h:55
constexpr friend Angle operator/(const Angle &lhs, const Rep2 &scalar)
Definition angle.h:85
constexpr Angle(const Rep2 &value_)
Definition angle.h:34
constexpr Rep count() const
Definition angle.h:51
constexpr friend Angle operator*(const Rep2 &scalar, const Angle &rhs)
Definition angle.h:73
constexpr Angle operator+() const
Definition angle.h:53
constexpr friend auto operator<=>(const Angle &, const Angle &)=default
constexpr Angle(const Angle< Rep, Units2 > &other)
Definition angle.h:40
Definition custom_decoration_generator.h:5
std::ostream & operator<<(std::ostream &, const Object &)
constexpr auto min(Angle< Rep1, Units1 > x, Angle< Rep2, Units2 > y) -> std::common_type_t< decltype(x), decltype(y)>
Definition angle.h:284
constexpr Angle< Rep, Units > clamp(const Angle< Rep, Units > &v, const AngleMin &min, const AngleMax &max)
Definition angle.h:320
bool operator==(const Class &, const Class &)
constexpr auto max(Angle< Rep1, Units1 > x, Angle< Rep2, Units2 > y) -> std::common_type_t< decltype(x), decltype(y)>
Definition angle.h:300
constexpr std::common_type_t< Angle< Rep1, Units1 >, Angle< Rep2, Units2 > > operator+(const Angle< Rep1, Units1 > &lhs, const Angle< Rep2, Units2 > &rhs)
Definition angle.h:100
auto mod(Angle< Rep1, Units1 > x, Angle< Rep2, Units2 > y) -> std::common_type_t< decltype(x), decltype(y)>
Definition angle.h:268
constexpr U to(T &&value)
Definition conversion.h:56
constexpr auto operator<=>(const Angle< Rep1, Units1 > &lhs, const Angle< Rep2, Units2 > &rhs)
Definition angle.h:143
constexpr std::common_type_t< Angle< Rep1, Units1 >, Angle< Rep2, Units2 > > operator-(const Angle< Rep1, Units1 > &lhs, const Angle< Rep2, Units2 > &rhs)
Definition angle.h:115
static constexpr bool value
Definition scalar.h:12
typename std::conditional_t<(Units1::radians_per_rep > Units2::radians_per_rep), Units1, Units2 > units
Definition angle.h:175