Boost logo

Boost :

Subject: [boost] Possible Bug in Boost Geometry's Huiller Algorithm
From: Brian Ahr (brian.ahr_at_[hidden])
Date: 2012-02-28 09:48:14


Hi Folks.

 I was looking at the implementation of the huiller algorithm in boost, and it seems to be partially incorrect.
 See boost/geometry/strategies/spherical/area_huiller.hpp

 In the apply() function, we have
if(lon2 < lon1){ E =-E;}
 which I believe should instead be
 calculation_type lon;if( lon2 < lon1 ) lon = lon1 - lon2;else lon = lon1 - lon2 + two_pi;if(2* half_pi < lon ) E =-E;
 according to Graphics Gems 5, pg 45 - 46. The comments at the top of the C++ file state that the code was derived from code in Graphics Gems 4, though the code was later corrected in Graphics Gems 5.
 I noticed this when trying to calculate areas of polygons on a sphere, where one of the points was (0, 0). In that case, it would always return a negative area, even though the polygon was defined counter-clockwise. Using a point other than (0,0) seemed to alleviate the problem, which got me wondering what was going on.

 Can anybody else confirm that this is an issue? Any suggestions for cleanly overriding boost's implementation until this is fixed?

 Thanks!
- Brian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk