Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
6
|
Chris@16
|
7 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
9 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
|
Chris@16
|
12 #define BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
|
Chris@16
|
13
|
Chris@16
|
14
|
Chris@16
|
15 #include <cstddef>
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/geometry/core/access.hpp>
|
Chris@16
|
18 #include <boost/geometry/geometries/concepts/point_concept.hpp>
|
Chris@16
|
19 #include <boost/geometry/util/select_coordinate_type.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace geometry
|
Chris@16
|
22 {
|
Chris@16
|
23
|
Chris@16
|
24 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
25 namespace detail
|
Chris@16
|
26 {
|
Chris@16
|
27
|
Chris@16
|
28 template <typename ReturnType, typename U, typename V>
|
Chris@16
|
29 class calculate_determinant
|
Chris@16
|
30 {
|
Chris@16
|
31 template <typename T>
|
Chris@16
|
32 static inline ReturnType rt(T const& v)
|
Chris@16
|
33 {
|
Chris@16
|
34 return boost::numeric_cast<ReturnType>(v);
|
Chris@16
|
35 }
|
Chris@16
|
36
|
Chris@16
|
37 public :
|
Chris@16
|
38
|
Chris@16
|
39 static inline ReturnType apply(U const& ux, U const& uy
|
Chris@16
|
40 , V const& vx, V const& vy)
|
Chris@16
|
41 {
|
Chris@16
|
42 return rt(ux) * rt(vy) - rt(uy) * rt(vx);
|
Chris@16
|
43 }
|
Chris@16
|
44 };
|
Chris@16
|
45
|
Chris@16
|
46 template <typename ReturnType, typename U, typename V>
|
Chris@16
|
47 inline ReturnType determinant(U const& ux, U const& uy
|
Chris@16
|
48 , V const& vx, V const& vy)
|
Chris@16
|
49 {
|
Chris@16
|
50 return calculate_determinant
|
Chris@16
|
51 <
|
Chris@16
|
52 ReturnType, U, V
|
Chris@16
|
53 >::apply(ux, uy, vx, vy);
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56
|
Chris@16
|
57 template <typename ReturnType, typename U, typename V>
|
Chris@16
|
58 inline ReturnType determinant(U const& u, V const& v)
|
Chris@16
|
59 {
|
Chris@16
|
60 BOOST_CONCEPT_ASSERT( (concept::ConstPoint<U>) );
|
Chris@16
|
61 BOOST_CONCEPT_ASSERT( (concept::ConstPoint<V>) );
|
Chris@16
|
62
|
Chris@16
|
63 return calculate_determinant
|
Chris@16
|
64 <
|
Chris@101
|
65 ReturnType,
|
Chris@16
|
66 typename geometry::coordinate_type<U>::type,
|
Chris@16
|
67 typename geometry::coordinate_type<V>::type
|
Chris@16
|
68 >::apply(get<0>(u), get<1>(u), get<0>(v), get<1>(v));
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 } // namespace detail
|
Chris@16
|
72 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
73
|
Chris@16
|
74 }} // namespace boost::geometry
|
Chris@16
|
75
|
Chris@16
|
76 #endif // BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
|