~ai.tron/armagetronad/0.4-winlibs-updated

« back to all changes in this revision

Viewing changes to boost/includes/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp

  • Committer: Nik K.
  • Date: 2013-11-07 16:58:35 UTC
  • Revision ID: nik.karbaum@gmail.com-20131107165835-kq99jz23drfj4dkh
Forgot to add some files; here they are

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Boost.Geometry Index
 
2
//
 
3
// squared distance between point and furthest point of the box or point
 
4
//
 
5
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
 
6
//
 
7
// Use, modification and distribution is subject to the Boost Software License,
 
8
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 
9
// http://www.boost.org/LICENSE_1_0.txt)
 
10
 
 
11
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
 
12
#define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
 
13
 
 
14
#include <boost/geometry/index/detail/algorithms/diff_abs.hpp>
 
15
#include <boost/geometry/index/detail/algorithms/sum_for_indexable.hpp>
 
16
 
 
17
namespace boost { namespace geometry { namespace index { namespace detail {
 
18
 
 
19
// minmaxdist component
 
20
 
 
21
struct comparable_distance_far_tag {};
 
22
 
 
23
template <
 
24
    typename Point,
 
25
    typename BoxIndexable,
 
26
    size_t DimensionIndex>
 
27
struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_far_tag, DimensionIndex>
 
28
{
 
29
    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
 
30
 
 
31
    inline static result_type apply(Point const& pt, BoxIndexable const& i)
 
32
    {
 
33
        typedef typename coordinate_type<Point>::type point_coord_t;
 
34
        typedef typename coordinate_type<BoxIndexable>::type indexable_coord_t;
 
35
 
 
36
        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
 
37
        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
 
38
        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
 
39
 
 
40
        result_type further_diff = 0;
 
41
 
 
42
        if ( (ind_c_min + ind_c_max) / 2 <= pt_c )
 
43
            further_diff = pt_c - ind_c_min;
 
44
        else
 
45
            further_diff = detail::diff_abs(pt_c, ind_c_max); // unsigned values protection
 
46
 
 
47
        return further_diff * further_diff;
 
48
    }
 
49
};
 
50
 
 
51
template <typename Point, typename Indexable>
 
52
typename geometry::default_distance_result<Point, Indexable>::type
 
53
comparable_distance_far(Point const& pt, Indexable const& i)
 
54
{
 
55
    return detail::sum_for_indexable<
 
56
        Point,
 
57
        Indexable,
 
58
        typename tag<Indexable>::type,
 
59
        detail::comparable_distance_far_tag,
 
60
        dimension<Indexable>::value
 
61
    >::apply(pt, i);
 
62
}
 
63
 
 
64
}}}} // namespace boost::geometry::index::detail
 
65
 
 
66
#endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP