Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76884 - in trunk/boost/geometry: arithmetic policies/relate strategies/cartesian
From: barend.gehrels_at_[hidden]
Date: 2012-02-04 12:16:51


Author: barendgehrels
Date: 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
New Revision: 76884
URL: http://svn.boost.org/trac/boost/changeset/76884

Log:
We stick to the way more common term determinant for 2d side/area/centroid calculations.
It is in detail - we might use LA or another library in the future
Added:
   trunk/boost/geometry/arithmetic/determinant.hpp (contents, props changed)
Text files modified:
   trunk/boost/geometry/policies/relate/direction.hpp | 4 ++--
   trunk/boost/geometry/policies/relate/intersection_points.hpp | 6 +++---
   trunk/boost/geometry/strategies/cartesian/area_surveyor.hpp | 4 ++--
   trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp | 4 ++--
   trunk/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp | 4 ++--
   trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp | 4 ++--
   6 files changed, 13 insertions(+), 13 deletions(-)

Added: trunk/boost/geometry/arithmetic/determinant.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/geometry/arithmetic/determinant.hpp 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
@@ -0,0 +1,76 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
+#define BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename ReturnType, typename U, typename V>
+class calculate_determinant
+{
+ template <typename T>
+ static inline ReturnType rt(T const& v)
+ {
+ return boost::numeric_cast<ReturnType>(v);
+ }
+
+public :
+
+ static inline ReturnType apply(U const& ux, U const& uy
+ , V const& vx, V const& vy)
+ {
+ return rt(ux) * rt(vy) - rt(uy) * rt(vx);
+ }
+};
+
+template <typename ReturnType, typename U, typename V>
+inline ReturnType determinant(U const& ux, U const& uy
+ , V const& vx, V const& vy)
+{
+ return calculate_determinant
+ <
+ ReturnType, U, V
+ >::apply(ux, uy, vx, vy);
+}
+
+
+template <typename ReturnType, typename U, typename V>
+inline ReturnType determinant(U const& u, V const& v)
+{
+ BOOST_CONCEPT_ASSERT( (concept::ConstPoint<U>) );
+ BOOST_CONCEPT_ASSERT( (concept::ConstPoint<V>) );
+
+ return calculate_determinant
+ <
+ ReturnType,
+ typename geometry::coordinate_type<U>::type,
+ typename geometry::coordinate_type<V>::type
+ >::apply(get<0>(u), get<1>(u), get<0>(v), get<1>(v));
+}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP

Modified: trunk/boost/geometry/policies/relate/direction.hpp
==============================================================================
--- trunk/boost/geometry/policies/relate/direction.hpp (original)
+++ trunk/boost/geometry/policies/relate/direction.hpp 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
@@ -15,7 +15,7 @@
 
 #include <boost/concept_check.hpp>
 
-#include <boost/geometry/arithmetic/cross_product.hpp>
+#include <boost/geometry/arithmetic/determinant.hpp>
 #include <boost/geometry/strategies/side_info.hpp>
 
 #include <boost/geometry/util/math.hpp>
@@ -263,7 +263,7 @@
         // Waiting for implementing spherical...
 
         rtype const zero = rtype();
- return geometry::cross_product2<rtype>(ux, uy, vx, vy) > zero;
+ return geometry::detail::determinant<rtype>(ux, uy, vx, vy) > zero;
     }
 
     template <std::size_t I>

Modified: trunk/boost/geometry/policies/relate/intersection_points.hpp
==============================================================================
--- trunk/boost/geometry/policies/relate/intersection_points.hpp (original)
+++ trunk/boost/geometry/policies/relate/intersection_points.hpp 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
@@ -16,7 +16,7 @@
 #include <boost/concept_check.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 
-#include <boost/geometry/arithmetic/cross_product.hpp>
+#include <boost/geometry/arithmetic/determinant.hpp>
 #include <boost/geometry/core/access.hpp>
 #include <boost/geometry/strategies/side_info.hpp>
 #include <boost/geometry/util/select_calculation_type.hpp>
@@ -64,8 +64,8 @@
         // Calculate other determinants - Cramers rule
         promoted_type const wx = get<0, 0>(s1) - get<0, 0>(s2);
         promoted_type const wy = get<0, 1>(s1) - get<0, 1>(s2);
- promoted_type const d = geometry::determinant<promoted_type>(dx1, dy1, dx2, dy2);
- promoted_type const da = geometry::determinant<promoted_type>(dx2, dy2, wx, wy);
+ promoted_type const d = detail::determinant<promoted_type>(dx1, dy1, dx2, dy2);
+ promoted_type const da = detail::determinant<promoted_type>(dx2, dy2, wx, wy);
 
         // r: ratio 0-1 where intersection divides A/B
         promoted_type r = da / d;

Modified: trunk/boost/geometry/strategies/cartesian/area_surveyor.hpp
==============================================================================
--- trunk/boost/geometry/strategies/cartesian/area_surveyor.hpp (original)
+++ trunk/boost/geometry/strategies/cartesian/area_surveyor.hpp 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
@@ -17,7 +17,7 @@
 
 #include <boost/mpl/if.hpp>
 
-#include <boost/geometry/arithmetic/cross_product.hpp>
+#include <boost/geometry/arithmetic/determinant.hpp>
 #include <boost/geometry/core/coordinate_type.hpp>
 #include <boost/geometry/core/coordinate_dimension.hpp>
 #include <boost/geometry/util/select_most_precise.hpp>
@@ -99,7 +99,7 @@
                 summation& state)
     {
         // SUM += x2 * y1 - x1 * y2;
- state.sum += geometry::cross_product2<return_type>(p2, p1);
+ state.sum += detail::determinant<return_type>(p2, p1);
     }
 
     static inline return_type result(summation const& state)

Modified: trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp
==============================================================================
--- trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp (original)
+++ trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
@@ -16,7 +16,7 @@
 #include <boost/geometry/geometries/concepts/point_concept.hpp>
 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
 
-#include <boost/geometry/arithmetic/cross_product.hpp>
+#include <boost/geometry/arithmetic/determinant.hpp>
 #include <boost/geometry/algorithms/detail/assign_values.hpp>
 
 #include <boost/geometry/util/math.hpp>
@@ -203,7 +203,7 @@
         // Calculate the determinant/2D cross product
         // (Note, because we only check on zero,
         // the order a/b does not care)
- promoted_type const d = geometry::determinant
+ promoted_type const d = geometry::detail::determinant
             <
                 promoted_type
>(dx_a, dy_a, dx_b, dy_b);

Modified: trunk/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp
==============================================================================
--- trunk/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp (original)
+++ trunk/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
@@ -19,7 +19,7 @@
 #include <boost/numeric/conversion/cast.hpp>
 #include <boost/type_traits.hpp>
 
-#include <boost/geometry/arithmetic/cross_product.hpp>
+#include <boost/geometry/arithmetic/determinant.hpp>
 #include <boost/geometry/core/coordinate_type.hpp>
 #include <boost/geometry/core/point_type.hpp>
 #include <boost/geometry/strategies/centroid.hpp>
@@ -178,7 +178,7 @@
         calculation_type const y1 = boost::numeric_cast<calculation_type>(get<1>(p1));
         calculation_type const x2 = boost::numeric_cast<calculation_type>(get<0>(p2));
         calculation_type const y2 = boost::numeric_cast<calculation_type>(get<1>(p2));
- calculation_type const ai = geometry::cross_product2<calculation_type>(p1, p2);
+ calculation_type const ai = geometry::detail::determinant<calculation_type>(p1, p2);
         state.count++;
         state.sum_a2 += ai;
         state.sum_x += ai * (x1 + x2);

Modified: trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp
==============================================================================
--- trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp (original)
+++ trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp 2012-02-04 12:16:49 EST (Sat, 04 Feb 2012)
@@ -17,7 +17,7 @@
 #include <boost/mpl/if.hpp>
 #include <boost/type_traits.hpp>
 
-#include <boost/geometry/arithmetic/cross_product.hpp>
+#include <boost/geometry/arithmetic/determinant.hpp>
 #include <boost/geometry/core/access.hpp>
 #include <boost/geometry/util/select_coordinate_type.hpp>
 #include <boost/geometry/strategies/side.hpp>
@@ -86,7 +86,7 @@
         promoted_type const dpy = y - sy1;
 
         promoted_type const s
- = geometry::cross_product2<promoted_type>
+ = detail::determinant<promoted_type>
                 (
                     dx, dy,
                     dpx, dpy


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