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'のメンバーではありません」というメッセージが表示されます。
これは、ブーストヘッダーファイル(ブースト/ジオメトリ/コア/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極座標系のために、距離戦略やその他の必要な特性をすべて自分で定義することになっていますか?