Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@16: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@16: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP Chris@16: #define BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP Chris@16: Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: #ifndef DOXYGEN_NO_DETAIL Chris@16: namespace detail Chris@16: { Chris@16: Chris@16: template Chris@16: struct dot_product_maker Chris@16: { Chris@16: typedef typename select_coordinate_type::type coordinate_type; Chris@16: Chris@16: static inline coordinate_type apply(P1 const& p1, P2 const& p2) Chris@16: { Chris@16: return get(p1) * get(p2) Chris@16: + dot_product_maker::apply(p1, p2); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct dot_product_maker Chris@16: { Chris@16: typedef typename select_coordinate_type::type coordinate_type; Chris@16: Chris@16: static inline coordinate_type apply(P1 const& p1, P2 const& p2) Chris@16: { Chris@16: return get(p1) * get(p2); Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: #endif // DOXYGEN_NO_DETAIL Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Computes the dot product (or scalar product) of 2 vectors (points). Chris@16: \ingroup arithmetic Chris@101: \tparam Point1 \tparam_point Chris@101: \tparam Point2 \tparam_point Chris@16: \param p1 first point Chris@16: \param p2 second point Chris@16: \return the dot product Chris@16: */ Chris@101: template Chris@101: inline typename select_coordinate_type::type dot_product( Chris@101: Point1 const& p1, Point2 const& p2) Chris@16: { Chris@101: BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); Chris@101: BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); Chris@16: Chris@16: return detail::dot_product_maker Chris@16: < Chris@101: Point1, Point2, Chris@101: 0, dimension::type::value - 1 Chris@16: >::apply(p1, p2); Chris@16: } Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: #endif // BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP