我在玩 boost 1.47 中提供的新几何库,想知道是否可以定义 2D 极坐标系统。在头文件和文档中,我找到了极坐标系统的定义,但是当尝试将它与下面的示例代码一起使用时,我遇到了编译错误:
using namespace boost;
typedef geometry::cs::polar<geometry::radian> geometry_type;
typedef geometry::model::point<double, 2, geometry_type> point_type;
const double PI = math::constants::pi<double>();
point_type p1(0, 0);
point_type p2(1, PI/2);
double dist = geometry::distance(p1, p2); // COMPILATION FAILS HERE
在VC2010中我得到:“错误C2039:'type':不是'boost::geometry::traits::cs_tag'的成员”尝试编译上面的距离函数时。
这是从 boost 头文件 (boost/geometry/core/cs.hpp) 中提取的极坐标系统的定义:
/*!
\brief Polar coordinate system
\details Defines the polar coordinate system "in which each point
on a plane is determined by an angle and a distance"
\see http://en.wikipedia.org/wiki/Polar_coordinates
\ingroup cs
*/
template<typename DegreeOrRadian>
struct polar
{
typedef DegreeOrRadian units;
};
但我认为这个定义是不完整的,因为在其他任何地方都没有提到“极地”。我是否应该为一个简单的 2D 极坐标系统自己定义一个距离策略和其他需要的特征?