0

如何以度为单位定义增强单位角度?下面显示了有效的弧度和无效的度数。

#include <boost/units/unit.hpp>
#include <boost/units/systems/si/io.hpp>
#include <boost/units/systems/angle/degrees.hpp>

// This works for defining an angle in radians
boost::units::quantity<
    boost::units::unit<
        boost::units::plane_angle_dimension,
        boost::units::si::system
    >
> my_angle_radians(2.0 * boost::units::si::radian);

// This is what I'm trying to do that doesn't work
boost::units::quantity<
    boost::units::unit<
        boost::units::plane_angle_dimension,
        boost::units::degree::system
    >
> my_angle_degree(2.0 * boost::units::angle::degree_base_unit);
4

1 回答 1

1

使用boost::units::degree::degree

my_angle_degree(2.0 * boost::units::degree::degree);

两条线

BOOST_UNITS_STATIC_CONSTANT(degree,plane_angle);
BOOST_UNITS_STATIC_CONSTANT(degrees,plane_angle);

成为boost::units::degree命名空间中的这两个静态常量:

static const plane_angle degree;
static const plane_angle degrees;
于 2021-06-03T13:46:16.060 回答