Add operator for line/point/point

This commit is contained in:
Andreas Fabri 2020-02-25 16:47:12 +00:00
parent a4acfb0c56
commit 99eea7ac21
4 changed files with 29 additions and 4 deletions

View File

@ -541,8 +541,10 @@ namespace CartesianKernelFunctors {
typedef typename K::Point_2 Point_2;
typedef typename K::Line_2 Line_2;
typedef typename K::Equal_2 Equal_2;
typedef typename K::Less_signed_distance_to_line_2 Less_signed_distance_to_line_2;
public:
typedef Comparison_result result_type;
typedef typename K::Comparison_result result_type;
result_type
operator()(const Point_2& a, const Point_2& b,
@ -555,6 +557,15 @@ namespace CartesianKernelFunctors {
c.x(), c.y(),
d.x(), d.y());
}
result_type
operator()(const Line_2& l, const Point_2& p, const Point_2& q) const
{
Less_signed_distance_to_line_2 less = K().less_signed_distance_to_line_2_object();
if (less(l, p, q)) return SMALLER;
if (less(l, q, p)) return LARGER;
return EQUAL;
}
};
template <typename K>

View File

@ -803,6 +803,15 @@ namespace HomogeneousKernelFunctors {
return compare(scaled_dist_r_minus_scaled_dist_s, 0);
}
result_type
operator()(const Line_2& l, const Point_2& p, const Point_2& q) const
{
Less_signed_distance_to_line_2 less = K().less_signed_distance_to_line_2_object();
if (less(l, p, q)) return SMALLER;
if (less(l, q, p)) return LARGER;
return EQUAL;
}
};
template <typename K>

View File

@ -999,6 +999,13 @@ public:
const Kernel::Point_2& q,
const Kernel::Point_2& r,
const Kernel::Point_2& s);
/*!
compares the signed distance of `r` and `s` to the directed line `l`.
*/
Comparison_result operator()(const Kernel::Line_2& l,
const Kernel::Point_2& r,
const Kernel::Point_2& s);
/// @}
}; /* end Kernel::CompareSignedDistanceToLine_2 */

View File

@ -361,9 +361,7 @@ compare_signed_distance_to_line(const typename K::Line_2& l,
const typename K::Point_2& q,
const K& k)
{
if (k.less_signed_distance_to_line_2_object()(l, p, q)) return SMALLER;
if (k.less_signed_distance_to_line_2_object()(l, q, p)) return LARGER;
return EQUAL;
return k.compare_signed_distance_to_line_2_object()(l, p, q);
}
template < class K >