123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_LINE_INTERPOLATE_HPP
- #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_LINE_INTERPOLATE_HPP
- #include <boost/geometry/core/assert.hpp>
- #include <boost/geometry/core/coordinate_dimension.hpp>
- #include <boost/geometry/core/coordinate_type.hpp>
- #include <boost/geometry/strategies/line_interpolate.hpp>
- #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
- #include <boost/geometry/util/algorithm.hpp>
- #include <boost/geometry/util/numeric_cast.hpp>
- #include <boost/geometry/util/select_calculation_type.hpp>
- namespace boost { namespace geometry
- {
- namespace strategy { namespace line_interpolate
- {
- template
- <
- typename CalculationType = void,
- typename DistanceStrategy = distance::pythagoras<CalculationType>
- >
- class cartesian
- {
- public:
- template <typename Point, typename Fraction, typename Distance>
- inline void apply(Point const& p0,
- Point const& p1,
- Fraction const& fraction,
- Point & p,
- Distance const&) const
- {
- typedef typename select_calculation_type_alt
- <
- CalculationType, Point
- >::type calc_t;
- typedef typename coordinate_type<Point>::type coord_t;
-
- Fraction const one_minus_fraction = 1-fraction;
- geometry::detail::for_each_dimension<Point>([&](auto dimension)
- {
-
-
-
- calc_t coord0 = util::numeric_cast<calc_t>(get<dimension>(p0));
- calc_t coord1 = util::numeric_cast<calc_t>(get<dimension>(p1));
- calc_t result = calc_t(coord1 * fraction) + calc_t(coord0 * one_minus_fraction);
- set<dimension>(p, util::numeric_cast<coord_t>(result));
- });
- }
- };
- #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
- namespace services
- {
- template <>
- struct default_strategy<cartesian_tag>
- {
- typedef strategy::line_interpolate::cartesian<> type;
- };
- }
- #endif
- }}
- }}
- #endif
|