annotate DEPENDENCIES/generic/include/boost/geometry/arithmetic/dot_product.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@16 4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@16 6
Chris@16 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@16 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@16 9
Chris@16 10 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 13
Chris@16 14 #ifndef BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
Chris@16 15 #define BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
Chris@16 16
Chris@16 17
Chris@16 18 #include <cstddef>
Chris@16 19
Chris@16 20 #include <boost/concept/requires.hpp>
Chris@16 21
Chris@16 22 #include <boost/geometry/geometries/concepts/point_concept.hpp>
Chris@16 23 #include <boost/geometry/util/select_coordinate_type.hpp>
Chris@16 24
Chris@16 25 namespace boost { namespace geometry
Chris@16 26 {
Chris@16 27
Chris@16 28 #ifndef DOXYGEN_NO_DETAIL
Chris@16 29 namespace detail
Chris@16 30 {
Chris@16 31
Chris@16 32 template <typename P1, typename P2, std::size_t Dimension, std::size_t DimensionCount>
Chris@16 33 struct dot_product_maker
Chris@16 34 {
Chris@16 35 typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
Chris@16 36
Chris@16 37 static inline coordinate_type apply(P1 const& p1, P2 const& p2)
Chris@16 38 {
Chris@16 39 return get<Dimension>(p1) * get<Dimension>(p2)
Chris@16 40 + dot_product_maker<P1, P2, Dimension+1, DimensionCount>::apply(p1, p2);
Chris@16 41 }
Chris@16 42 };
Chris@16 43
Chris@16 44 template <typename P1, typename P2, std::size_t DimensionCount>
Chris@16 45 struct dot_product_maker<P1, P2, DimensionCount, DimensionCount>
Chris@16 46 {
Chris@16 47 typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
Chris@16 48
Chris@16 49 static inline coordinate_type apply(P1 const& p1, P2 const& p2)
Chris@16 50 {
Chris@16 51 return get<DimensionCount>(p1) * get<DimensionCount>(p2);
Chris@16 52 }
Chris@16 53 };
Chris@16 54
Chris@16 55 } // namespace detail
Chris@16 56 #endif // DOXYGEN_NO_DETAIL
Chris@16 57
Chris@16 58
Chris@16 59 /*!
Chris@16 60 \brief Computes the dot product (or scalar product) of 2 vectors (points).
Chris@16 61 \ingroup arithmetic
Chris@101 62 \tparam Point1 \tparam_point
Chris@101 63 \tparam Point2 \tparam_point
Chris@16 64 \param p1 first point
Chris@16 65 \param p2 second point
Chris@16 66 \return the dot product
Chris@16 67 */
Chris@101 68 template <typename Point1, typename Point2>
Chris@101 69 inline typename select_coordinate_type<Point1, Point2>::type dot_product(
Chris@101 70 Point1 const& p1, Point2 const& p2)
Chris@16 71 {
Chris@101 72 BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point1>) );
Chris@101 73 BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point2>) );
Chris@16 74
Chris@16 75 return detail::dot_product_maker
Chris@16 76 <
Chris@101 77 Point1, Point2,
Chris@101 78 0, dimension<Point1>::type::value - 1
Chris@16 79 >::apply(p1, p2);
Chris@16 80 }
Chris@16 81
Chris@16 82 }} // namespace boost::geometry
Chris@16 83
Chris@16 84 #endif // BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP