Added thirdparty: boost library

This commit is contained in:
Viacheslav Demydiuk
2024-01-06 19:55:56 +02:00
parent bf49f439e1
commit bccd1e7051
15683 changed files with 3239840 additions and 0 deletions
+249
View File
@@ -0,0 +1,249 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2021.
// Modifications copyright (c) 2021 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
#define BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
#include <functional>
#include <boost/concept/requires.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/geometries/concepts/point_concept.hpp>
#include <boost/geometry/util/algorithm.hpp>
#include <boost/geometry/util/select_coordinate_type.hpp>
namespace boost { namespace geometry
{
/*!
\brief Adds the same value to each coordinate of a point
\ingroup arithmetic
\details
\tparam Point \tparam_point
\param p point
\param value value to add
*/
template <typename Point>
inline void add_value(Point& p, typename coordinate_type<Point>::type const& value)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
detail::for_each_dimension<Point>([&](auto index)
{
set<index>(p, get<index>(p) + value);
});
}
/*!
\brief Adds a point to another
\ingroup arithmetic
\details The coordinates of the second point will be added to those of the first point.
The second point is not modified.
\tparam Point1 \tparam_point
\tparam Point2 \tparam_point
\param p1 first point
\param p2 second point
*/
template <typename Point1, typename Point2>
inline void add_point(Point1& p1, Point2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
detail::for_each_dimension<Point1>([&](auto index)
{
using calc_t = typename select_coordinate_type<Point1, Point2>::type;
set<index>(p1, calc_t(get<index>(p1)) + calc_t(get<index>(p2)));
});
}
/*!
\brief Subtracts the same value to each coordinate of a point
\ingroup arithmetic
\details
\tparam Point \tparam_point
\param p point
\param value value to subtract
*/
template <typename Point>
inline void subtract_value(Point& p, typename coordinate_type<Point>::type const& value)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
detail::for_each_dimension<Point>([&](auto index)
{
set<index>(p, get<index>(p) - value);
});
}
/*!
\brief Subtracts a point to another
\ingroup arithmetic
\details The coordinates of the second point will be subtracted to those of the first point.
The second point is not modified.
\tparam Point1 \tparam_point
\tparam Point2 \tparam_point
\param p1 first point
\param p2 second point
*/
template <typename Point1, typename Point2>
inline void subtract_point(Point1& p1, Point2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
detail::for_each_dimension<Point1>([&](auto index)
{
using calc_t = typename select_coordinate_type<Point1, Point2>::type;
set<index>(p1, calc_t(get<index>(p1)) - calc_t(get<index>(p2)));
});
}
/*!
\brief Multiplies each coordinate of a point by the same value
\ingroup arithmetic
\details
\tparam Point \tparam_point
\param p point
\param value value to multiply by
*/
template <typename Point>
inline void multiply_value(Point& p, typename coordinate_type<Point>::type const& value)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
detail::for_each_dimension<Point>([&](auto index)
{
set<index>(p, get<index>(p) * value);
});
}
/*!
\brief Multiplies a point by another
\ingroup arithmetic
\details The coordinates of the first point will be multiplied by those of the second point.
The second point is not modified.
\tparam Point1 \tparam_point
\tparam Point2 \tparam_point
\param p1 first point
\param p2 second point
\note This is *not* a dot, cross or wedge product. It is a mere field-by-field multiplication.
*/
template <typename Point1, typename Point2>
inline void multiply_point(Point1& p1, Point2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
detail::for_each_dimension<Point1>([&](auto index)
{
using calc_t = typename select_coordinate_type<Point1, Point2>::type;
set<index>(p1, calc_t(get<index>(p1)) * calc_t(get<index>(p2)));
});
}
/*!
\brief Divides each coordinate of the same point by a value
\ingroup arithmetic
\details
\tparam Point \tparam_point
\param p point
\param value value to divide by
*/
template <typename Point>
inline void divide_value(Point& p, typename coordinate_type<Point>::type const& value)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
detail::for_each_dimension<Point>([&](auto index)
{
set<index>(p, get<index>(p) / value);
});
}
/*!
\brief Divides a point by another
\ingroup arithmetic
\details The coordinates of the first point will be divided by those of the second point.
The second point is not modified.
\tparam Point1 \tparam_point
\tparam Point2 \tparam_point
\param p1 first point
\param p2 second point
*/
template <typename Point1, typename Point2>
inline void divide_point(Point1& p1, Point2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
detail::for_each_dimension<Point1>([&](auto index)
{
using calc_t = typename select_coordinate_type<Point1, Point2>::type;
set<index>(p1, calc_t(get<index>(p1)) / calc_t(get<index>(p2)));
});
}
/*!
\brief Assign each coordinate of a point the same value
\ingroup arithmetic
\details
\tparam Point \tparam_point
\param p point
\param value value to assign
*/
template <typename Point>
inline void assign_value(Point& p, typename coordinate_type<Point>::type const& value)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
detail::for_each_dimension<Point>([&](auto index)
{
set<index>(p, value);
});
}
/*!
\brief Assign a point with another
\ingroup arithmetic
\details The coordinates of the first point will be assigned those of the second point.
The second point is not modified.
\tparam Point1 \tparam_point
\tparam Point2 \tparam_point
\param p1 first point
\param p2 second point
*/
template <typename Point1, typename Point2>
inline void assign_point(Point1& p1, Point2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<Point1>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
detail::for_each_dimension<Point1>([&](auto index)
{
set<index>(p1, get<index>(p2));
});
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
+210
View File
@@ -0,0 +1,210 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// This file was modified by Oracle on 2016-2020.
// Modifications copyright (c) 2016-2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ARITHMETIC_CROSS_PRODUCT_HPP
#define BOOST_GEOMETRY_ARITHMETIC_CROSS_PRODUCT_HPP
#include <cstddef>
#include <type_traits>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/make.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/static_assert.hpp>
#include <boost/geometry/geometries/concepts/point_concept.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <std::size_t Dimension>
struct cross_product
{
// We define cross product only for 2d (see Wolfram) and 3d.
// In Math, it is also well-defined for 7-dimension.
// Generalisation of cross product to n-dimension is defined as
// wedge product but it is not direct analogue to binary cross product.
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
"Not implemented for this Dimension.",
std::integral_constant<std::size_t, Dimension>);
};
template <>
struct cross_product<2>
{
template <typename P1, typename P2, typename ResultP>
static void apply(P1 const& p1, P2 const& p2, ResultP& result)
{
assert_dimension<P1, 2>();
assert_dimension<P2, 2>();
assert_dimension<ResultP, 2>();
// For 2-dimensions, analog of the cross product U(x,y) and V(x,y) is
// Ux * Vy - Uy * Vx
// which is returned as 0-component (or X) of 2d vector, 1-component is undefined.
set<0>(result, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
}
};
template <>
struct cross_product<3>
{
template <typename P1, typename P2, typename ResultP>
static void apply(P1 const& p1, P2 const& p2, ResultP& result)
{
assert_dimension<P1, 3>();
assert_dimension<P2, 3>();
assert_dimension<ResultP, 3>();
set<0>(result, get<1>(p1) * get<2>(p2) - get<2>(p1) * get<1>(p2));
set<1>(result, get<2>(p1) * get<0>(p2) - get<0>(p1) * get<2>(p2));
set<2>(result, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
}
template <typename ResultP, typename P1, typename P2>
static constexpr ResultP apply(P1 const& p1, P2 const& p2)
{
assert_dimension<P1, 3>();
assert_dimension<P2, 3>();
assert_dimension<ResultP, 3>();
return traits::make<ResultP>::apply(
get<1>(p1) * get<2>(p2) - get<2>(p1) * get<1>(p2),
get<2>(p1) * get<0>(p2) - get<0>(p1) * get<2>(p2),
get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
}
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
/*!
\brief Computes the cross product of two vectors.
\details All vectors should have the same dimension, 3 or 2.
\ingroup arithmetic
\param p1 first vector
\param p2 second vector
\return the cross product vector
*/
template
<
typename ResultP, typename P1, typename P2,
std::enable_if_t
<
dimension<ResultP>::value != 3
|| ! traits::make<ResultP>::is_specialized,
int
> = 0
>
inline ResultP cross_product(P1 const& p1, P2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concepts::Point<ResultP>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<P1>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<P2>) );
ResultP result;
detail::cross_product<dimension<ResultP>::value>::apply(p1, p2, result);
return result;
}
template
<
typename ResultP, typename P1, typename P2,
std::enable_if_t
<
dimension<ResultP>::value == 3
&& traits::make<ResultP>::is_specialized,
int
> = 0
>
// workaround for VS2015
#if !defined(_MSC_VER) || (_MSC_VER >= 1910)
constexpr
#endif
inline ResultP cross_product(P1 const& p1, P2 const& p2)
{
BOOST_CONCEPT_ASSERT((concepts::Point<ResultP>));
BOOST_CONCEPT_ASSERT((concepts::ConstPoint<P1>));
BOOST_CONCEPT_ASSERT((concepts::ConstPoint<P2>));
return detail::cross_product<3>::apply<ResultP>(p1, p2);
}
/*!
\brief Computes the cross product of two vectors.
\details All vectors should have the same dimension, 3 or 2.
\ingroup arithmetic
\param p1 first vector
\param p2 second vector
\return the cross product vector
\qbk{[heading Examples]}
\qbk{[cross_product] [cross_product_output]}
*/
template
<
typename P,
std::enable_if_t
<
dimension<P>::value != 3
|| ! traits::make<P>::is_specialized,
int
> = 0
>
inline P cross_product(P const& p1, P const& p2)
{
BOOST_CONCEPT_ASSERT((concepts::Point<P>));
BOOST_CONCEPT_ASSERT((concepts::ConstPoint<P>));
P result;
detail::cross_product<dimension<P>::value>::apply(p1, p2, result);
return result;
}
template
<
typename P,
std::enable_if_t
<
dimension<P>::value == 3
&& traits::make<P>::is_specialized,
int
> = 0
>
// workaround for VS2015
#if !defined(_MSC_VER) || (_MSC_VER >= 1910)
constexpr
#endif
inline P cross_product(P const& p1, P const& p2)
{
BOOST_CONCEPT_ASSERT((concepts::Point<P>));
BOOST_CONCEPT_ASSERT((concepts::ConstPoint<P>));
return detail::cross_product<3>::apply<P>(p1, p2);
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ARITHMETIC_CROSS_PRODUCT_HPP
+78
View File
@@ -0,0 +1,78 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
#define BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
#include <cstddef>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/geometries/concepts/point_concept.hpp>
#include <boost/geometry/util/select_coordinate_type.hpp>
#include <boost/numeric/conversion/cast.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <typename ReturnType, typename U, typename V>
class calculate_determinant
{
template <typename T>
static inline ReturnType rt(T const& v)
{
return boost::numeric_cast<ReturnType>(v);
}
public :
static inline ReturnType apply(U const& ux, U const& uy
, V const& vx, V const& vy)
{
return rt(ux) * rt(vy) - rt(uy) * rt(vx);
}
};
template <typename ReturnType, typename U, typename V>
inline ReturnType determinant(U const& ux, U const& uy
, V const& vx, V const& vy)
{
return calculate_determinant
<
ReturnType, U, V
>::apply(ux, uy, vx, vy);
}
template <typename ReturnType, typename U, typename V>
inline ReturnType determinant(U const& u, V const& v)
{
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<U>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<V>) );
return calculate_determinant
<
ReturnType,
typename geometry::coordinate_type<U>::type,
typename geometry::coordinate_type<V>::type
>::apply(get<0>(u), get<1>(u), get<0>(v), get<1>(v));
}
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
+96
View File
@@ -0,0 +1,96 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
#define BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
#include <cstddef>
#include <boost/concept/requires.hpp>
#include <boost/geometry/geometries/concepts/point_concept.hpp>
#include <boost/geometry/util/select_coordinate_type.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <typename P1, typename P2, std::size_t Dimension, std::size_t DimensionCount>
struct dot_product_maker
{
typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
static constexpr coordinate_type apply(P1 const& p1, P2 const& p2)
{
return get<Dimension>(p1) * get<Dimension>(p2)
+ dot_product_maker<P1, P2, Dimension+1, DimensionCount>::apply(p1, p2);
}
};
template <typename P1, typename P2, std::size_t DimensionCount>
struct dot_product_maker<P1, P2, DimensionCount, DimensionCount>
{
typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
static constexpr coordinate_type apply(P1 const& p1, P2 const& p2)
{
return get<DimensionCount>(p1) * get<DimensionCount>(p2);
}
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
/*!
\brief Computes the dot product (or scalar product) of 2 vectors (points).
\ingroup arithmetic
\tparam Point1 \tparam_point
\tparam Point2 \tparam_point
\param p1 first point
\param p2 second point
\return the dot product
\qbk{[heading Examples]}
\qbk{[dot_product] [dot_product_output]}
*/
template <typename Point1, typename Point2>
// workaround for VS2015
#if !defined(_MSC_VER) || (_MSC_VER >= 1910)
constexpr
#endif
inline typename select_coordinate_type<Point1, Point2>::type dot_product(
Point1 const& p1, Point2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point1>) );
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point2>) );
return detail::dot_product_maker
<
Point1, Point2,
0, dimension<Point1>::type::value - 1
>::apply(p1, p2);
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
+113
View File
@@ -0,0 +1,113 @@
// Boost.Geometry
// Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ARITHMETIC_LINE_FUNCTIONS_HPP
#define BOOST_GEOMETRY_ARITHMETIC_LINE_FUNCTIONS_HPP
#include <boost/geometry/arithmetic/determinant.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/config.hpp>
#include <boost/geometry/geometries/infinite_line.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/select_most_precise.hpp>
namespace boost { namespace geometry
{
namespace arithmetic
{
template <typename Line, typename Line::type Line::* member1, typename Line::type Line::* member2>
inline auto determinant(Line const& p, Line const& q)
{
return geometry::detail::determinant<typename Line::type>(p.*member1, p.*member2,
q.*member1, q.*member2);
}
template <typename Point, typename Line, typename Type>
inline Point assign_intersection_point(Line const& p, Line const& q, Type const& denominator)
{
BOOST_ASSERT(denominator != Type(0));
// x = | pb pc | / d and y = | pc pa | / d
// | qb qc | | qc qa |
Point result;
geometry::set<0>(result, determinant<Line, &Line::b, &Line::c>(p, q) / denominator);
geometry::set<1>(result, determinant<Line, &Line::c, &Line::a>(p, q) / denominator);
return result;
}
// Calculates intersection point of two infinite lines.
// Returns true if the lines intersect.
// Returns false if lines are parallel (or collinear, possibly opposite)
template <typename Line, typename Point>
inline bool intersection_point(Line const& p, Line const& q, Point& ip)
{
auto const denominator = determinant<Line, &Line::a, &Line::b>(p, q);
constexpr decltype(denominator) const zero = 0;
if (math::equals(denominator, zero))
{
// Lines are parallel
return false;
}
ip = assign_intersection_point<Point>(p, q, denominator);
return true;
}
//! Return a distance-side-measure for a point to a line
//! Point is located left of the line if value is positive,
//! right of the line is value is negative, and on the line if the value
//! is exactly zero
template <typename Type, typename CoordinateType>
inline
typename select_most_precise<Type, CoordinateType>::type
side_value(model::infinite_line<Type> const& line,
CoordinateType const& x, CoordinateType const& y)
{
// https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line#Line_defined_by_an_equation
// Distance from point to line in general form is given as:
// (a * x + b * y + c) / sqrt(a * a + b * b);
// In most use cases comparisons are enough, saving the sqrt
// and often even the division.
// Also, this gives positive values for points left to the line,
// and negative values for points right to the line.
return line.a * x + line.b * y + line.c;
}
template <typename Type, typename Point>
inline
typename select_most_precise
<
Type,
typename geometry::coordinate_type<Point>::type
>::type
side_value(model::infinite_line<Type> const& line, Point const& p)
{
return side_value(line, geometry::get<0>(p), geometry::get<1>(p));
}
template <typename Type>
inline bool is_degenerate(model::infinite_line<Type> const& line)
{
static Type const zero = 0;
return math::equals(line.a, zero) && math::equals(line.b, zero);
}
} // namespace arithmetic
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ARITHMETIC_LINE_FUNCTIONS_HPP
+71
View File
@@ -0,0 +1,71 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2016, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ARITHMETIC_NORMALIZE_HPP
#define BOOST_GEOMETRY_ARITHMETIC_NORMALIZE_HPP
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/arithmetic/arithmetic.hpp>
#include <boost/geometry/arithmetic/dot_product.hpp>
#include <boost/geometry/util/math.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <typename Point>
inline typename coordinate_type<Point>::type vec_length_sqr(Point const& pt)
{
return dot_product(pt, pt);
}
template <typename Point>
inline typename coordinate_type<Point>::type vec_length(Point const& pt)
{
// NOTE: hypot() could be used instead of sqrt()
return math::sqrt(dot_product(pt, pt));
}
template <typename Point>
inline bool vec_normalize(Point & pt, typename coordinate_type<Point>::type & len)
{
typedef typename coordinate_type<Point>::type coord_t;
coord_t const c0 = 0;
len = vec_length(pt);
if (math::equals(len, c0))
{
return false;
}
divide_value(pt, len);
return true;
}
template <typename Point>
inline bool vec_normalize(Point & pt)
{
typedef typename coordinate_type<Point>::type coord_t;
coord_t len;
return vec_normalize(pt, len);
}
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ARITHMETIC_NORMALIZE_HPP