What I am trying to do is convert two points in spherical coordinates to geographic coordinates, in order to them make use of the vincenty distance function, in order to accurately measure the distance between the two points on a unit sphere.
The following code fails to transform a pair of spherical points to a pairs of geographic ones, returning inf values for the elements in p1_g and p2_g.
Any suggestion of what I am doing wrong is much appreciated.
VectorXd p1(2) ;
VectorXd p2(2) ;
p1 << -2.35619, 0.955317 ;
p2 << 1.47275, 2.53697 ;
namespace bg = boost::geometry;
typedef boost::geometry::srs::spheroid<double> SpheroidType;
SpheroidType spheriod(1.0,1.0);
typedef boost::geometry::strategy::distance::vincenty<SpheroidType>
VincentyStrategy;
VincentyStrategy vincenty(spheriod);
bg::model::point<double, 2, bg::cs::spherical<bg::radian>> p1_s(p1(0), p1(1));
bg::model::point<double, 2, bg::cs::spherical<bg::radian>> p2_s(p2(0), p2(1));
bg::model::point<double, 2, bg::cs::geographic<bg::radian> > p1_g;
bg::model::point<double, 2, bg::cs::geographic<bg::radian> > p2_g;
bg::transform(p1_s, p1_g, vincenty);
bg::transform(p2_s, p2_g, vincenty);
auto dist = bg::distance(p1_g, p2_g, vincenty);