stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,335 @@
|
||||
// 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.
|
||||
|
||||
// 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/call_traits.hpp>
|
||||
#include <boost/concept/requires.hpp>
|
||||
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/geometries/concepts/point_concept.hpp>
|
||||
#include <boost/geometry/util/for_each_coordinate.hpp>
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
template <typename Point>
|
||||
struct param
|
||||
{
|
||||
typedef typename boost::call_traits
|
||||
<
|
||||
typename coordinate_type<Point>::type
|
||||
>::param_type type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Value, template <typename> class Function>
|
||||
struct value_operation
|
||||
{
|
||||
Value m_value;
|
||||
|
||||
inline value_operation(Value const &value)
|
||||
: m_value(value)
|
||||
{}
|
||||
|
||||
template <typename PointDst, std::size_t Index>
|
||||
inline void apply(PointDst& point_dst) const
|
||||
{
|
||||
set<Index>(point_dst,
|
||||
Function
|
||||
<
|
||||
typename geometry::select_most_precise
|
||||
<
|
||||
Value,
|
||||
typename geometry::coordinate_type<PointDst>::type
|
||||
>::type
|
||||
>()(get<Index>(point_dst), m_value));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename PointSrc, template <typename> class Function>
|
||||
struct point_operation
|
||||
{
|
||||
PointSrc const& m_point_src;
|
||||
|
||||
inline point_operation(PointSrc const& point)
|
||||
: m_point_src(point)
|
||||
{}
|
||||
|
||||
template <typename PointDst, std::size_t Index>
|
||||
inline void apply(PointDst& point_dst) const
|
||||
{
|
||||
set<Index>(point_dst,
|
||||
Function
|
||||
<
|
||||
typename geometry::select_most_precise
|
||||
<
|
||||
typename geometry::coordinate_type<PointSrc>::type,
|
||||
typename geometry::coordinate_type<PointDst>::type
|
||||
>::type
|
||||
>()(get<Index>(point_dst), get<Index>(m_point_src)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Value>
|
||||
struct value_assignment
|
||||
{
|
||||
Value m_value;
|
||||
|
||||
inline value_assignment(Value const &value)
|
||||
: m_value(value)
|
||||
{}
|
||||
|
||||
template <typename PointDst, std::size_t Index>
|
||||
inline void apply(PointDst& point_dst) const
|
||||
{
|
||||
set<Index>(point_dst, m_value);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename PointSrc>
|
||||
struct point_assignment
|
||||
{
|
||||
PointSrc const& m_point_src;
|
||||
|
||||
inline point_assignment(PointSrc const& point)
|
||||
: m_point_src(point)
|
||||
{}
|
||||
|
||||
template <typename PointDst, std::size_t Index>
|
||||
inline void apply(PointDst& point_dst) const
|
||||
{
|
||||
set<Index>(point_dst, get<Index>(m_point_src));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
/*!
|
||||
\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 detail::param<Point>::type value)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
|
||||
|
||||
for_each_coordinate(p,
|
||||
detail::value_operation
|
||||
<
|
||||
typename coordinate_type<Point>::type,
|
||||
std::plus
|
||||
>(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>) );
|
||||
|
||||
for_each_coordinate(p1, detail::point_operation<Point2, std::plus>(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 detail::param<Point>::type value)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
|
||||
|
||||
for_each_coordinate(p,
|
||||
detail::value_operation
|
||||
<
|
||||
typename coordinate_type<Point>::type,
|
||||
std::minus
|
||||
>(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>) );
|
||||
|
||||
for_each_coordinate(p1, detail::point_operation<Point2, std::minus>(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 detail::param<Point>::type value)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
|
||||
|
||||
for_each_coordinate(p,
|
||||
detail::value_operation
|
||||
<
|
||||
typename coordinate_type<Point>::type,
|
||||
std::multiplies
|
||||
>(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>) );
|
||||
|
||||
for_each_coordinate(p1, detail::point_operation<Point2, std::multiplies>(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 detail::param<Point>::type value)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
|
||||
|
||||
for_each_coordinate(p,
|
||||
detail::value_operation
|
||||
<
|
||||
typename coordinate_type<Point>::type,
|
||||
std::divides
|
||||
>(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>) );
|
||||
|
||||
for_each_coordinate(p1, detail::point_operation<Point2, std::divides>(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 detail::param<Point>::type value)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
|
||||
|
||||
for_each_coordinate(p,
|
||||
detail::value_assignment
|
||||
<
|
||||
typename coordinate_type<Point>::type
|
||||
>(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>) );
|
||||
|
||||
for_each_coordinate(p1, detail::point_assignment<Point2>(p2));
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
|
||||
@@ -0,0 +1,128 @@
|
||||
// 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.
|
||||
// Modifications 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_CROSS_PRODUCT_HPP
|
||||
#define BOOST_GEOMETRY_ARITHMETIC_CROSS_PRODUCT_HPP
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.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_MPL_ASSERT_MSG((false),
|
||||
NOT_IMPLEMENTED_FOR_THIS_DIMENSION,
|
||||
(mpl::size_t<Dimension>));
|
||||
};
|
||||
|
||||
template <>
|
||||
struct cross_product<2>
|
||||
{
|
||||
template <typename P1, typename P2, typename ResultP>
|
||||
static inline 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 inline 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));
|
||||
}
|
||||
};
|
||||
|
||||
} // 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>
|
||||
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;
|
||||
}
|
||||
|
||||
/*!
|
||||
\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 P>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ARITHMETIC_CROSS_PRODUCT_HPP
|
||||
@@ -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
|
||||
@@ -0,0 +1,84 @@
|
||||
// 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.
|
||||
|
||||
// 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 inline 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 inline 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
|
||||
*/
|
||||
template <typename Point1, typename Point2>
|
||||
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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user