mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-13 00:22:10 +00:00
Some adaptions for ttmath type
Doc update in (sym)difference [SVN r69335]
This commit is contained in:
@@ -58,7 +58,7 @@ inline void buffer_box(BoxIn const& box_in, T const& distance, BoxOut& box_out)
|
||||
static const std::size_t N = dimension<BoxIn>::value;
|
||||
|
||||
box_loop<BoxIn, BoxOut, T, min_corner, 0, N>::apply(box_in, -distance, box_out);
|
||||
box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, +distance, box_out);
|
||||
box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, distance, box_out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -230,18 +230,22 @@ struct centroid_linestring
|
||||
typedef typename boost::range_iterator<Linestring const>::type point_iterator_type;
|
||||
typedef segment_returning_iterator<point_iterator_type, point_type> segment_iterator;
|
||||
|
||||
double length = double();
|
||||
std::pair<double, double> average_sum;
|
||||
typedef geometry::distance_result<Linestring>::type distance_type;
|
||||
distance_type length = distance_type();
|
||||
std::pair<distance_type, distance_type> average_sum;
|
||||
|
||||
segment_iterator it(boost::begin(line), boost::end(line));
|
||||
segment_iterator end(boost::end(line));
|
||||
while (it != end)
|
||||
{
|
||||
double const d = geometry::distance(it->first, it->second);
|
||||
|
||||
distance_type const d = geometry::distance(it->first, it->second);
|
||||
length += d;
|
||||
|
||||
double const mx = (get<0>(it->first) + get<0>(it->second)) / 2;
|
||||
double const my = (get<1>(it->first) + get<1>(it->second)) / 2;
|
||||
distance_type two(2);
|
||||
|
||||
distance_type const mx = (get<0>(it->first) + get<0>(it->second)) / two;
|
||||
distance_type const my = (get<1>(it->first) + get<1>(it->second)) / two;
|
||||
average_sum.first += d * mx;
|
||||
average_sum.second += d * my;
|
||||
++it;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace boost { namespace geometry
|
||||
\brief_calc2{difference} \brief_strategy
|
||||
\ingroup difference
|
||||
\details \details_calc2{difference_inserter, spatial set theoretic difference}
|
||||
\brief_strategy. details_inserter{difference}
|
||||
\brief_strategy. \details_inserter{difference}
|
||||
\tparam GeometryOut output geometry type, must be specified
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
@@ -60,7 +60,7 @@ inline OutputIterator difference_inserter(Geometry1 const& geometry1,
|
||||
\brief_calc2{difference}
|
||||
\ingroup difference
|
||||
\details \details_calc2{difference_inserter, spatial set theoretic difference}.
|
||||
details_inserter{difference}
|
||||
\details_inserter{difference}
|
||||
\tparam GeometryOut output geometry type, must be specified
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
@@ -70,11 +70,7 @@ inline OutputIterator difference_inserter(Geometry1 const& geometry1,
|
||||
\param out \param_out{difference}
|
||||
\return \return_out
|
||||
|
||||
\qbk{[include reference/algorithms/difference.qbk]}
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[difference] [difference_output]
|
||||
}
|
||||
\qbk{[include reference/algorithms/difference_inserter.qbk]}
|
||||
*/
|
||||
template
|
||||
<
|
||||
@@ -109,17 +105,12 @@ inline OutputIterator difference_inserter(Geometry1 const& geometry1,
|
||||
\details \details_calc2{difference, spatial set theoretic difference}.
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
\tparam Collection output collection, either a multi-geometry,
|
||||
or a std::vector<Geometry> / std::deque<Geometry> etc
|
||||
\tparam Collection \tparam_output_collection
|
||||
\param geometry1 \param_geometry
|
||||
\param geometry2 \param_geometry
|
||||
\param output_collection the output collection
|
||||
|
||||
\qbk{[include reference/algorithms/difference.qbk]}
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[difference_inserter] [difference_inserter_output]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
@@ -142,8 +133,6 @@ inline void difference(Geometry1 const& geometry1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace boost { namespace geometry
|
||||
\brief \brief_calc2{symmetric difference} \brief_strategy
|
||||
\ingroup sym_difference
|
||||
\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}
|
||||
\brief_strategy. details_inserter{sym_difference}
|
||||
\brief_strategy. \details_inserter{sym_difference}
|
||||
\tparam GeometryOut output geometry type, must be specified
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
|
||||
@@ -64,6 +64,12 @@ namespace ttmath
|
||||
return ATan(v);
|
||||
}
|
||||
|
||||
template <uint Exponent, uint Mantissa>
|
||||
inline Big<Exponent, Mantissa> acos(Big<Exponent, Mantissa> const& v)
|
||||
{
|
||||
return ACos(v);
|
||||
}
|
||||
|
||||
|
||||
template <uint Exponent, uint Mantissa>
|
||||
inline Big<Exponent, Mantissa> atan2(Big<Exponent, Mantissa> const& y, Big<Exponent, Mantissa> const& x)
|
||||
|
||||
@@ -41,7 +41,8 @@ template
|
||||
>
|
||||
struct transform_coordinates
|
||||
{
|
||||
static inline void transform(Src const& source, Dst& dest, double value)
|
||||
template <typename T>
|
||||
static inline void transform(Src const& source, Dst& dest, T value)
|
||||
{
|
||||
typedef typename select_coordinate_type<Src, Dst>::type coordinate_type;
|
||||
|
||||
@@ -59,7 +60,8 @@ template
|
||||
>
|
||||
struct transform_coordinates<Src, Dst, N, N, F>
|
||||
{
|
||||
static inline void transform(Src const& source, Dst& dest, double value)
|
||||
template <typename T>
|
||||
static inline void transform(Src const& source, Dst& dest, T value)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -147,22 +149,31 @@ namespace detail
|
||||
{
|
||||
|
||||
/// Helper function for conversion, phi/theta are in radians
|
||||
template <typename P>
|
||||
inline void spherical_to_cartesian(double phi, double theta, double r, P& p)
|
||||
template <typename P, typename T, typename R>
|
||||
inline void spherical_to_cartesian(T phi, T theta, R r, P& p)
|
||||
{
|
||||
assert_dimension<P, 3>();
|
||||
|
||||
// http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_spherical_coordinates
|
||||
// Phi = first, theta is second, r is third, see documentation on cs::spherical
|
||||
double const sin_theta = sin(theta);
|
||||
set<0>(p, r * sin_theta * cos(phi));
|
||||
set<1>(p, r * sin_theta * sin(phi));
|
||||
set<2>(p, r * cos(theta));
|
||||
|
||||
// (calculations are splitted to implement ttmath)
|
||||
|
||||
T r_sin_theta = r;
|
||||
r_sin_theta *= sin(theta);
|
||||
|
||||
set<0>(p, r_sin_theta * cos(phi));
|
||||
set<1>(p, r_sin_theta * sin(phi));
|
||||
|
||||
T r_cos_theta = r;
|
||||
r_cos_theta *= cos(theta);
|
||||
|
||||
set<2>(p, r_cos_theta);
|
||||
}
|
||||
|
||||
/// Helper function for conversion
|
||||
template <typename P>
|
||||
inline bool cartesian_to_spherical2(double x, double y, double z, P& p)
|
||||
template <typename P, typename T>
|
||||
inline bool cartesian_to_spherical2(T x, T y, T z, P& p)
|
||||
{
|
||||
assert_dimension<P, 2>();
|
||||
|
||||
@@ -170,10 +181,10 @@ namespace detail
|
||||
|
||||
#if defined(BOOST_GEOMETRY_TRANSFORM_CHECK_UNIT_SPHERE)
|
||||
// TODO: MAYBE ONLY IF TO BE CHECKED?
|
||||
double const r = /*sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z);
|
||||
T const r = /*sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z);
|
||||
|
||||
// Unit sphere, so r should be 1
|
||||
if (geometry::math::abs(r - 1.0) > double(1e-6))
|
||||
if (geometry::math::abs(r - 1.0) > T(1e-6))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -185,13 +196,13 @@ namespace detail
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline bool cartesian_to_spherical3(double x, double y, double z, P& p)
|
||||
template <typename P, typename T>
|
||||
inline bool cartesian_to_spherical3(T x, T y, T z, P& p)
|
||||
{
|
||||
assert_dimension<P, 3>();
|
||||
|
||||
// http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates
|
||||
double const r = sqrt(x * x + y * y + z * z);
|
||||
T const r = sqrt(x * x + y * y + z * z);
|
||||
set<2>(p, r);
|
||||
set_from_radian<0>(p, atan2(y, x));
|
||||
if (r > 0.0)
|
||||
|
||||
Reference in New Issue
Block a user