Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63591 - in sandbox/geometry: boost/geometry/strategies libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2010-07-04 08:44:43


Author: barendgehrels
Date: 2010-07-04 08:44:42 EDT (Sun, 04 Jul 2010)
New Revision: 63591
URL: http://svn.boost.org/trac/boost/changeset/63591

Log:
Fix in new abs approach for transform (unit sphere forwards/backwards was not exactly 1.000 by rounding errors)
Text files modified:
   sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp | 6 ++++--
   sandbox/geometry/libs/geometry/test/algorithms/transform.cpp | 12 ++++++------
   2 files changed, 10 insertions(+), 8 deletions(-)

Modified: sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp 2010-07-04 08:44:42 EDT (Sun, 04 Jul 2010)
@@ -168,15 +168,17 @@
 
         // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates
 
+#if defined(BOOST_GEOMETRY_TRANSFORM_CHECK_UNIT_SPHERE)
         // TODO: MAYBE ONLY IF TO BE CHECKED?
- double const r = std::sqrt(x * x + y * y + z * z);
+ double const r = /*std::sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z);
 
         // Unit sphere, so r should be 1
- if (! geometry::math::equals(r, 1))
+ if (geometry::math::abs(r - 1.0) > double(1e-6))
         {
             return false;
         }
         // end todo
+#endif
 
         set_from_radian<0>(p, std::atan2(y, x));
         set_from_radian<1>(p, std::acos(z));

Modified: sandbox/geometry/libs/geometry/test/algorithms/transform.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/transform.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/transform.cpp 2010-07-04 08:44:42 EDT (Sun, 04 Jul 2010)
@@ -29,7 +29,7 @@
     boost::geometry::set<0>(p1, 1);
     boost::geometry::set<1>(p1, 2);
     P2 p2;
- boost::geometry::transform(p1, p2);
+ BOOST_CHECK(boost::geometry::transform(p1, p2));
 
     BOOST_CHECK_CLOSE(value * boost::geometry::get<0>(p1), double(boost::geometry::get<0>(p2)), 0.001);
     BOOST_CHECK_CLOSE(value * boost::geometry::get<1>(p1), double(boost::geometry::get<1>(p2)), 0.001);
@@ -42,7 +42,7 @@
     line1.push_back(boost::geometry::make<P1>(1, 1));
     line1.push_back(boost::geometry::make<P1>(2, 2));
     boost::geometry::linestring<P2> line2;
- boost::geometry::transform(line1, line2);
+ BOOST_CHECK(boost::geometry::transform(line1, line2));
     BOOST_CHECK_EQUAL(line1.size(), line2.size());
 
     std::ostringstream out1, out2;
@@ -72,10 +72,10 @@
         typedef point<T, 3, cs::spherical<DegreeOrRadian> > spherical_type;
         spherical_type sph1;
         assign(sph1, phi, theta, r);
- transform(sph1, p);
+ BOOST_CHECK(transform(sph1, p));
 
         spherical_type sph2;
- transform(p, sph2);
+ BOOST_CHECK(transform(p, sph2));
 
         BOOST_CHECK_CLOSE(double(boost::geometry::get<0>(sph1)), double(boost::geometry::get<0>(sph2)), 0.001);
         BOOST_CHECK_CLOSE(double(boost::geometry::get<1>(sph1)), double(boost::geometry::get<1>(sph2)), 0.001);
@@ -89,8 +89,8 @@
         typedef point<T, 2, cs::spherical<DegreeOrRadian> > spherical_type;
         spherical_type sph1, sph2;
         assign(sph1, phi, theta);
- transform(sph1, p);
- transform(p, sph2);
+ BOOST_CHECK(transform(sph1, p));
+ BOOST_CHECK(transform(p, sph2));
 
         BOOST_CHECK_CLOSE(double(boost::geometry::get<0>(sph1)), double(boost::geometry::get<0>(sph2)), 0.001);
         BOOST_CHECK_CLOSE(double(boost::geometry::get<1>(sph1)), double(boost::geometry::get<1>(sph2)), 0.001);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk