Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:23

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0004 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
0005 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0006 
0007 // Use, modification and distribution is subject to the Boost Software License,
0008 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
0012 #define BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
0013 
0014 
0015 #include <cstddef>
0016 
0017 #include <boost/geometry/core/access.hpp>
0018 #include <boost/geometry/geometries/concepts/point_concept.hpp>
0019 #include <boost/geometry/util/select_coordinate_type.hpp>
0020 
0021 #include <boost/numeric/conversion/cast.hpp>
0022 
0023 namespace boost { namespace geometry
0024 {
0025 
0026 #ifndef DOXYGEN_NO_DETAIL
0027 namespace detail
0028 {
0029 
0030 template <typename ReturnType, typename U, typename V>
0031 class calculate_determinant
0032 {
0033     template <typename T>
0034     static inline ReturnType rt(T const& v)
0035     {
0036         return boost::numeric_cast<ReturnType>(v);
0037     }
0038 
0039 public :
0040 
0041     static inline ReturnType apply(U const& ux, U const& uy
0042                                  , V const& vx, V const& vy)
0043     {
0044         return rt(ux) * rt(vy) - rt(uy) * rt(vx);
0045     }
0046 };
0047 
0048 template <typename ReturnType, typename U, typename V>
0049 inline ReturnType determinant(U const& ux, U const& uy
0050                             , V const& vx, V const& vy)
0051 {
0052     return calculate_determinant
0053         <
0054             ReturnType, U, V
0055         >::apply(ux, uy, vx, vy);
0056 }
0057 
0058 
0059 template <typename ReturnType, typename U, typename V>
0060 inline ReturnType determinant(U const& u, V const& v)
0061 {
0062     BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<U>) );
0063     BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<V>) );
0064 
0065     return calculate_determinant
0066         <
0067             ReturnType,
0068             typename geometry::coordinate_type<U>::type,
0069             typename geometry::coordinate_type<V>::type
0070         >::apply(get<0>(u), get<1>(u), get<0>(v), get<1>(v));
0071 }
0072 
0073 } // namespace detail
0074 #endif // DOXYGEN_NO_DETAIL
0075 
0076 }} // namespace boost::geometry
0077 
0078 #endif // BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP