Skip to content

mp_units::utility::radian_of

Customization point: the unit of one radian for an angle quantity kind

Synopsis

Declared in <mp-units/utility/polar_vector.h>

template<QuantitySpec auto QS>
  requires(QS == get_kind(QS))
constexpr auto radian_of = unspecified;

Description

The polar and spherical facades convert an angle through it to call std::sin, std::cos, and std::atan2, so they work with any angle system whose radian is registered here. The library registers the angle of the SI and that of the angular system. Another angle system needs one specialization, keyed on its kind:

namespace my {
inline constexpr struct dim_angle : base_dimension<"A"> {} dim_angle;
inline constexpr struct angle : quantity_spec<dim_angle> {} angle;
inline constexpr struct radian : named_unit<"rad", kind_of<angle>> {} radian;
inline constexpr struct degree : named_unit<"deg", mag_ratio<1, 180> * π * radian> {} degree;
}

template<>
inline constexpr auto mp_units::utility::radian_of<kind_of<my::angle>> = my::radian;

utility::polar_vector position{2. * m, 90. * my::degree};  // converts through my::radian

It accepts only a kind, which is what get_quantity_spec of a bare unit yields, so a specialization keyed on a concrete quantity specification doesn't compile. The facades reject an angle unit whose kind has no radian registered.

Template Parameters

NameDescription
QSthe kind of the angle quantities

See Also