123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- #ifndef BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
- #define BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
- #include <functional>
- #include <boost/concept/requires.hpp>
- #include <boost/geometry/core/coordinate_type.hpp>
- #include <boost/geometry/geometries/concepts/point_concept.hpp>
- #include <boost/geometry/util/algorithm.hpp>
- #include <boost/geometry/util/select_coordinate_type.hpp>
- namespace boost { namespace geometry
- {
- template <typename Point>
- inline void add_value(Point& p, typename coordinate_type<Point>::type const& value)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
- detail::for_each_dimension<Point>([&](auto index)
- {
- set<index>(p, get<index>(p) + value);
- });
- }
- template <typename Point1, typename Point2>
- inline void add_point(Point1& p1, Point2 const& p2)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
- BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
- detail::for_each_dimension<Point1>([&](auto index)
- {
- using calc_t = typename select_coordinate_type<Point1, Point2>::type;
- set<index>(p1, calc_t(get<index>(p1)) + calc_t(get<index>(p2)));
- });
- }
- template <typename Point>
- inline void subtract_value(Point& p, typename coordinate_type<Point>::type const& value)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
- detail::for_each_dimension<Point>([&](auto index)
- {
- set<index>(p, get<index>(p) - value);
- });
- }
- template <typename Point1, typename Point2>
- inline void subtract_point(Point1& p1, Point2 const& p2)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
- BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
- detail::for_each_dimension<Point1>([&](auto index)
- {
- using calc_t = typename select_coordinate_type<Point1, Point2>::type;
- set<index>(p1, calc_t(get<index>(p1)) - calc_t(get<index>(p2)));
- });
- }
- template <typename Point>
- inline void multiply_value(Point& p, typename coordinate_type<Point>::type const& value)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
- detail::for_each_dimension<Point>([&](auto index)
- {
- set<index>(p, get<index>(p) * value);
- });
- }
- template <typename Point1, typename Point2>
- inline void multiply_point(Point1& p1, Point2 const& p2)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
- BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
- detail::for_each_dimension<Point1>([&](auto index)
- {
- using calc_t = typename select_coordinate_type<Point1, Point2>::type;
- set<index>(p1, calc_t(get<index>(p1)) * calc_t(get<index>(p2)));
- });
- }
- template <typename Point>
- inline void divide_value(Point& p, typename coordinate_type<Point>::type const& value)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
- detail::for_each_dimension<Point>([&](auto index)
- {
- set<index>(p, get<index>(p) / value);
- });
- }
- template <typename Point1, typename Point2>
- inline void divide_point(Point1& p1, Point2 const& p2)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
- BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
- detail::for_each_dimension<Point1>([&](auto index)
- {
- using calc_t = typename select_coordinate_type<Point1, Point2>::type;
- set<index>(p1, calc_t(get<index>(p1)) / calc_t(get<index>(p2)));
- });
- }
- template <typename Point>
- inline void assign_value(Point& p, typename coordinate_type<Point>::type const& value)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
- detail::for_each_dimension<Point>([&](auto index)
- {
- set<index>(p, value);
- });
- }
- template <typename Point1, typename Point2>
- inline void assign_point(Point1& p1, Point2 const& p2)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
- BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
- detail::for_each_dimension<Point1>([&](auto index)
- {
- set<index>(p1, get<index>(p2));
- });
- }
- }}
- #endif
|