1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
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)
11 #ifndef BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
12 #define BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
17 #include <boost/geometry/core/access.hpp>
18 #include <boost/geometry/geometries/concepts/point_concept.hpp>
19 #include <boost/geometry/util/select_coordinate_type.hpp>
21 #include <boost/numeric/conversion/cast.hpp>
23 namespace boost { namespace geometry
26 #ifndef DOXYGEN_NO_DETAIL
30 template <typename ReturnType, typename U, typename V>
31 class calculate_determinant
34 static inline ReturnType rt(T const& v)
36 return boost::numeric_cast<ReturnType>(v);
41 static inline ReturnType apply(U const& ux, U const& uy
42 , V const& vx, V const& vy)
44 return rt(ux) * rt(vy) - rt(uy) * rt(vx);
48 template <typename ReturnType, typename U, typename V>
49 inline ReturnType determinant(U const& ux, U const& uy
50 , V const& vx, V const& vy)
52 return calculate_determinant
55 >::apply(ux, uy, vx, vy);
59 template <typename ReturnType, typename U, typename V>
60 inline ReturnType determinant(U const& u, V const& v)
62 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<U>) );
63 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<V>) );
65 return calculate_determinant
68 typename geometry::coordinate_type<U>::type,
69 typename geometry::coordinate_type<V>::type
70 >::apply(get<0>(u), get<1>(u), get<0>(v), get<1>(v));
74 #endif // DOXYGEN_NO_DETAIL
76 }} // namespace boost::geometry
78 #endif // BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP