File indexing completed on 2025-01-18 09:35:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
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 }
0074 #endif
0075
0076 }}
0077
0078 #endif