Ticket #7030: geom_distance.patch
File geom_distance.patch, 2.4 KB (added by , 10 years ago) |
---|
-
geometry/strategies/spherical/distance_cross_track.hpp
107 107 108 108 return_type crs_AD = course(sp1, p); 109 109 return_type crs_AB = course(sp1, sp2); 110 return_type XTD = m_radius * geometry::math::abs(asin(sin(d1 / m_radius) * sin(crs_AD - crs_AB)));111 110 112 #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK 113 std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " " << crs_AD * geometry::math::r2d << std::endl; 114 std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " " << crs_AB * geometry::math::r2d << std::endl; 115 std::cout << "XTD: " << XTD << " d1: " << d1 << " d2: " << d2 << std::endl; 111 return_type d_crs = crs_AD - crs_AB; 112 113 if( ( geometry::math::abs( d_crs ) < geometry::math::pi< return_type >() * 0.5 ) 114 || ( geometry::math::abs( d_crs ) > geometry::math::pi< return_type >() * 1.5 ) ) 115 { 116 return_type XTD = m_radius * geometry::math::abs( asin( sin( d1 / m_radius ) * sin( crs_AD - crs_AB ) )); 117 118 #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK 119 std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " " << crs_AD * geometry::math::r2d << std::endl; 120 std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " " << crs_AB * geometry::math::r2d << std::endl; 121 std::cout << "XTD: " << XTD << " d1: " << d1 << " d2: " << d2 << std::endl; 116 122 #endif 117 123 124 // Return shortest distance, projected point on segment sp1-sp2 125 return return_type( XTD ); 126 } 127 else 128 { 129 #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK 130 std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " " << crs_AD * geometry::math::r2d << std::endl; 131 std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " " << crs_AB * geometry::math::r2d << std::endl; 132 #endif 118 133 119 // Return shortest distance, either to projected point on segment sp1-sp2, or to sp1, or to sp2 120 return return_type((std::min)((std::min)(d1, d2), XTD)); 134 // Return shortest distance, either to sp1, or to sp2 135 return return_type( std::min( d1 , d2 ) ); 136 } 137 121 138 } 122 139 123 140 inline return_type radius() const { return m_radius; }