$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
Subject: [geometry] spherical_equitorial to cartesian transform confusion
From: joe_at_[hidden]
Date: 2012-07-29 21:37:01
Most of the time things in my model are spherical_equatorial with 
altitude,
using degrees. But it would be cool to be able to transform arbitrary 
things in
my model into 3d cartesian coordinates, for example to use GGL to 
compute the
straight line distance between points rather than do the trig myself.
Well I don't understand how the provided transform stuff is supposed to 
work. I
get the "WTF" seen below with boost 1.50.0. If I convert various
spherical_equatorial points to cartesian 'distance' always returns only 
the
change in altitude.
Is what I'm trying to do actually implemented?
----------------------------------------
class MyLL  { double lat, lng, alt; ... }
BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET(MyLL, double, 
bg::cs::spherical_equatorial<bg::degree>, get_lng, get_lat, get_alt, 
set_lng, set_lat, set_alt)
MyLL amsterdam(52.37, 4.90, 0);
bg::model::point<double, 3, bg::cs::cartesian> cartesian_amsterdam;
bg::transform(amsterdam, cartesian_amsterdam);
std::cout << bg::dsv(amsterdam) << std::endl; // (4.9, 52.37, 0)
std::cout << bg::dsv(cartesian_amsterdam) << std::endl; // WTF: (0, 0, 
0)
MyLL paris(48.86, 2.35, 0);
bg::model::point<double, 3, bg::cs::cartesian> cartesian_paris;
bg::transform(paris, cartesian_paris);
/* I expect this to return a straight line distance, a la law of 
cosines. */
bg::distance(cartesian_amsterdam, cartesian_paris); )
/* doesn't work because transform doesn't work like I thought, but 
ultimately I
  * expect the result should be:
  *   double gamma = bg::distance(paris, amsterdam);
  *   double alen = EarthRadius + paris.get_alt();
  *   double blen = EarthRadius + amsterdam.get_alt();
  *   double distance = sqrt( alen*alen + blen*blen - (2*alen*blen * 
std::cos(gamma)) );
  */