|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69335 - in trunk/boost/geometry: algorithms extensions/contrib strategies
From: barend.gehrels_at_[hidden]
Date: 2011-02-27 11:20:07
Author: barendgehrels
Date: 2011-02-27 11:20:00 EST (Sun, 27 Feb 2011)
New Revision: 69335
URL: http://svn.boost.org/trac/boost/changeset/69335
Log:
Some adaptions for ttmath type
Doc update in (sym)difference
Text files modified:
trunk/boost/geometry/algorithms/buffer.hpp | 2
trunk/boost/geometry/algorithms/centroid.hpp | 14 ++++++++----
trunk/boost/geometry/algorithms/difference.hpp | 19 +++--------------
trunk/boost/geometry/algorithms/sym_difference.hpp | 2
trunk/boost/geometry/extensions/contrib/ttmath_stub.hpp | 6 +++++
trunk/boost/geometry/strategies/strategy_transform.hpp | 41 +++++++++++++++++++++++++--------------
6 files changed, 47 insertions(+), 37 deletions(-)
Modified: trunk/boost/geometry/algorithms/buffer.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/buffer.hpp (original)
+++ trunk/boost/geometry/algorithms/buffer.hpp 2011-02-27 11:20:00 EST (Sun, 27 Feb 2011)
@@ -58,7 +58,7 @@
static const std::size_t N = dimension<BoxIn>::value;
box_loop<BoxIn, BoxOut, T, min_corner, 0, N>::apply(box_in, -distance, box_out);
- box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, +distance, box_out);
+ box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, distance, box_out);
}
Modified: trunk/boost/geometry/algorithms/centroid.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/centroid.hpp (original)
+++ trunk/boost/geometry/algorithms/centroid.hpp 2011-02-27 11:20:00 EST (Sun, 27 Feb 2011)
@@ -230,18 +230,22 @@
typedef typename boost::range_iterator<Linestring const>::type point_iterator_type;
typedef segment_returning_iterator<point_iterator_type, point_type> segment_iterator;
- double length = double();
- std::pair<double, double> average_sum;
+ typedef geometry::distance_result<Linestring>::type distance_type;
+ distance_type length = distance_type();
+ std::pair<distance_type, distance_type> average_sum;
segment_iterator it(boost::begin(line), boost::end(line));
segment_iterator end(boost::end(line));
while (it != end)
{
- double const d = geometry::distance(it->first, it->second);
+
+ distance_type const d = geometry::distance(it->first, it->second);
length += d;
- double const mx = (get<0>(it->first) + get<0>(it->second)) / 2;
- double const my = (get<1>(it->first) + get<1>(it->second)) / 2;
+ distance_type two(2);
+
+ distance_type const mx = (get<0>(it->first) + get<0>(it->second)) / two;
+ distance_type const my = (get<1>(it->first) + get<1>(it->second)) / two;
average_sum.first += d * mx;
average_sum.second += d * my;
++it;
Modified: trunk/boost/geometry/algorithms/difference.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/difference.hpp (original)
+++ trunk/boost/geometry/algorithms/difference.hpp 2011-02-27 11:20:00 EST (Sun, 27 Feb 2011)
@@ -20,7 +20,7 @@
\brief_calc2{difference} \brief_strategy
\ingroup difference
\details \details_calc2{difference_inserter, spatial set theoretic difference}
- \brief_strategy. details_inserter{difference}
+ \brief_strategy. \details_inserter{difference}
\tparam GeometryOut output geometry type, must be specified
\tparam Geometry1 \tparam_geometry
\tparam Geometry2 \tparam_geometry
@@ -60,7 +60,7 @@
\brief_calc2{difference}
\ingroup difference
\details \details_calc2{difference_inserter, spatial set theoretic difference}.
- details_inserter{difference}
+ \details_inserter{difference}
\tparam GeometryOut output geometry type, must be specified
\tparam Geometry1 \tparam_geometry
\tparam Geometry2 \tparam_geometry
@@ -70,11 +70,7 @@
\param out \param_out{difference}
\return \return_out
-\qbk{[include reference/algorithms/difference.qbk]}
-\qbk{
-[heading Example]
-[difference] [difference_output]
-}
+\qbk{[include reference/algorithms/difference_inserter.qbk]}
*/
template
<
@@ -109,17 +105,12 @@
\details \details_calc2{difference, spatial set theoretic difference}.
\tparam Geometry1 \tparam_geometry
\tparam Geometry2 \tparam_geometry
-\tparam Collection output collection, either a multi-geometry,
- or a std::vector<Geometry> / std::deque<Geometry> etc
+\tparam Collection \tparam_output_collection
\param geometry1 \param_geometry
\param geometry2 \param_geometry
\param output_collection the output collection
\qbk{[include reference/algorithms/difference.qbk]}
-\qbk{
-[heading Example]
-[difference_inserter] [difference_inserter_output]
-}
*/
template
<
@@ -142,8 +133,6 @@
}
-
-
}} // namespace boost::geometry
Modified: trunk/boost/geometry/algorithms/sym_difference.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/sym_difference.hpp (original)
+++ trunk/boost/geometry/algorithms/sym_difference.hpp 2011-02-27 11:20:00 EST (Sun, 27 Feb 2011)
@@ -22,7 +22,7 @@
\brief \brief_calc2{symmetric difference} \brief_strategy
\ingroup sym_difference
\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}
- \brief_strategy. details_inserter{sym_difference}
+ \brief_strategy. \details_inserter{sym_difference}
\tparam GeometryOut output geometry type, must be specified
\tparam Geometry1 \tparam_geometry
\tparam Geometry2 \tparam_geometry
Modified: trunk/boost/geometry/extensions/contrib/ttmath_stub.hpp
==============================================================================
--- trunk/boost/geometry/extensions/contrib/ttmath_stub.hpp (original)
+++ trunk/boost/geometry/extensions/contrib/ttmath_stub.hpp 2011-02-27 11:20:00 EST (Sun, 27 Feb 2011)
@@ -64,6 +64,12 @@
return ATan(v);
}
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> acos(Big<Exponent, Mantissa> const& v)
+ {
+ return ACos(v);
+ }
+
template <uint Exponent, uint Mantissa>
inline Big<Exponent, Mantissa> atan2(Big<Exponent, Mantissa> const& y, Big<Exponent, Mantissa> const& x)
Modified: trunk/boost/geometry/strategies/strategy_transform.hpp
==============================================================================
--- trunk/boost/geometry/strategies/strategy_transform.hpp (original)
+++ trunk/boost/geometry/strategies/strategy_transform.hpp 2011-02-27 11:20:00 EST (Sun, 27 Feb 2011)
@@ -41,7 +41,8 @@
>
struct transform_coordinates
{
- static inline void transform(Src const& source, Dst& dest, double value)
+ template <typename T>
+ static inline void transform(Src const& source, Dst& dest, T value)
{
typedef typename select_coordinate_type<Src, Dst>::type coordinate_type;
@@ -59,7 +60,8 @@
>
struct transform_coordinates<Src, Dst, N, N, F>
{
- static inline void transform(Src const& source, Dst& dest, double value)
+ template <typename T>
+ static inline void transform(Src const& source, Dst& dest, T value)
{
}
};
@@ -147,22 +149,31 @@
{
/// Helper function for conversion, phi/theta are in radians
- template <typename P>
- inline void spherical_to_cartesian(double phi, double theta, double r, P& p)
+ template <typename P, typename T, typename R>
+ inline void spherical_to_cartesian(T phi, T theta, R r, P& p)
{
assert_dimension<P, 3>();
// http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_spherical_coordinates
// Phi = first, theta is second, r is third, see documentation on cs::spherical
- double const sin_theta = sin(theta);
- set<0>(p, r * sin_theta * cos(phi));
- set<1>(p, r * sin_theta * sin(phi));
- set<2>(p, r * cos(theta));
+
+ // (calculations are splitted to implement ttmath)
+
+ T r_sin_theta = r;
+ r_sin_theta *= sin(theta);
+
+ set<0>(p, r_sin_theta * cos(phi));
+ set<1>(p, r_sin_theta * sin(phi));
+
+ T r_cos_theta = r;
+ r_cos_theta *= cos(theta);
+
+ set<2>(p, r_cos_theta);
}
/// Helper function for conversion
- template <typename P>
- inline bool cartesian_to_spherical2(double x, double y, double z, P& p)
+ template <typename P, typename T>
+ inline bool cartesian_to_spherical2(T x, T y, T z, P& p)
{
assert_dimension<P, 2>();
@@ -170,10 +181,10 @@
#if defined(BOOST_GEOMETRY_TRANSFORM_CHECK_UNIT_SPHERE)
// TODO: MAYBE ONLY IF TO BE CHECKED?
- double const r = /*sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z);
+ T const r = /*sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z);
// Unit sphere, so r should be 1
- if (geometry::math::abs(r - 1.0) > double(1e-6))
+ if (geometry::math::abs(r - 1.0) > T(1e-6))
{
return false;
}
@@ -185,13 +196,13 @@
return true;
}
- template <typename P>
- inline bool cartesian_to_spherical3(double x, double y, double z, P& p)
+ template <typename P, typename T>
+ inline bool cartesian_to_spherical3(T x, T y, T z, P& p)
{
assert_dimension<P, 3>();
// http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates
- double const r = sqrt(x * x + y * y + z * z);
+ T const r = sqrt(x * x + y * y + z * z);
set<2>(p, r);
set_from_radian<0>(p, atan2(y, x));
if (r > 0.0)
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