mirror of https://github.com/CGAL/cgal
Add Kernel_23::Compare_squared_radius_2
This commit is contained in:
parent
ed337e9429
commit
7b2c8b40e1
|
|
@ -656,6 +656,42 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Compare_squared_radius_2
|
||||
{
|
||||
typedef typename K::Comparison_result Comparison_result;
|
||||
typedef typename K::Point_2 Point_2;
|
||||
typedef typename K::FT FT;
|
||||
|
||||
public:
|
||||
Comparison_result
|
||||
operator()(const Point_2& p, const Point_2& q, const Point_2& r, const FT& ft) const
|
||||
{
|
||||
FT num, den;
|
||||
squared_radiusC2(p.x(), p.y(),
|
||||
q.x(), q.y(),
|
||||
r.x(), r.y(),
|
||||
num, den);
|
||||
return CGAL::compare(num, den * ft);
|
||||
}
|
||||
|
||||
Comparison_result
|
||||
operator()(const Point_2& p, const Point_2& q, const FT& ft) const
|
||||
{
|
||||
FT num, den;
|
||||
squared_radiusC2(p.x(), p.y(),
|
||||
q.x(), q.y(),
|
||||
num, den);
|
||||
return CGAL::compare(num, den * ft);
|
||||
}
|
||||
|
||||
Comparison_result
|
||||
operator()(const Point_2&, const FT& ft) const
|
||||
{
|
||||
return - CGAL_NTS sign(ft);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Compare_squared_radius_3
|
||||
{
|
||||
|
|
@ -1178,11 +1214,24 @@ public:
|
|||
|
||||
FT
|
||||
operator()( const Point_2& p, const Point_2& q) const
|
||||
{ return squared_radiusC2(p.x(), p.y(), q.x(), q.y()); }
|
||||
{
|
||||
FT num, den;
|
||||
squared_radiusC2(p.x(), p.y(),
|
||||
q.x(), q.y(),
|
||||
num, den);
|
||||
return num / den;
|
||||
}
|
||||
|
||||
FT
|
||||
operator()( const Point_2& p, const Point_2& q, const Point_2& r) const
|
||||
{ return squared_radiusC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y()); }
|
||||
{
|
||||
FT num, den;
|
||||
squared_radiusC2(p.x(), p.y(),
|
||||
q.x(), q.y(),
|
||||
r.x(), r.y(),
|
||||
num, den);
|
||||
return num / den;
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace CartesianKernelFunctors
|
||||
|
|
|
|||
|
|
@ -338,47 +338,49 @@ line_project_pointC2(const FT &la, const FT &lb, const FT &lc,
|
|||
|
||||
template < class FT >
|
||||
CGAL_KERNEL_MEDIUM_INLINE
|
||||
FT
|
||||
void
|
||||
squared_radiusC2(const FT &px, const FT &py,
|
||||
const FT &qx, const FT &qy,
|
||||
const FT &rx, const FT &ry,
|
||||
FT &x, FT &y )
|
||||
FT &num, FT &den)
|
||||
{
|
||||
circumcenter_translateC2(qx-px, qy-py, rx-px, ry-py, x, y);
|
||||
FT r2 = CGAL_NTS square(x) + CGAL_NTS square(y);
|
||||
x += px;
|
||||
y += py;
|
||||
return r2;
|
||||
}
|
||||
// Translate r to origin to simplify the expression.
|
||||
FT prx = px - rx;
|
||||
FT pry = py - ry;
|
||||
FT pr2 = CGAL_NTS square(prx) + CGAL_NTS square(pry);
|
||||
FT qrx = qx - rx;
|
||||
FT qry = qy - ry;
|
||||
FT qr2 = CGAL_NTS square(qrx) + CGAL_NTS square(qry);
|
||||
|
||||
template < class FT >
|
||||
CGAL_KERNEL_MEDIUM_INLINE
|
||||
FT
|
||||
squared_radiusC2(const FT &px, const FT &py,
|
||||
const FT &qx, const FT &qy,
|
||||
const FT &rx, const FT &ry)
|
||||
{
|
||||
FT x, y;
|
||||
circumcenter_translateC2<FT>(qx-px, qy-py, rx-px, ry-py, x, y);
|
||||
return CGAL_NTS square(x) + CGAL_NTS square(y);
|
||||
FT num_x = determinant(qry, qr2,
|
||||
pry, pr2);
|
||||
FT num_y = determinant(qrx, qr2,
|
||||
prx, pr2);
|
||||
FT dden = determinant(qrx, qry,
|
||||
prx, pry);
|
||||
|
||||
num = CGAL_NTS square(num_x) + CGAL_NTS square(num_y);
|
||||
den = CGAL_NTS square(2 * dden);
|
||||
}
|
||||
|
||||
template < class FT >
|
||||
inline
|
||||
FT
|
||||
squared_distanceC2( const FT &px, const FT &py,
|
||||
const FT &qx, const FT &qy)
|
||||
squared_distanceC2(const FT &px, const FT &py,
|
||||
const FT &qx, const FT &qy)
|
||||
{
|
||||
return CGAL_NTS square(px-qx) + CGAL_NTS square(py-qy);
|
||||
}
|
||||
|
||||
template < class FT >
|
||||
inline
|
||||
FT
|
||||
void
|
||||
squared_radiusC2(const FT &px, const FT &py,
|
||||
const FT &qx, const FT &qy)
|
||||
const FT &qx, const FT &qy,
|
||||
FT &num, FT &den)
|
||||
{
|
||||
return squared_distanceC2(px, py,qx, qy) / 4;
|
||||
num = squared_distanceC2(px, py,qx, qy);
|
||||
den = 4;
|
||||
}
|
||||
|
||||
template < class FT >
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ namespace HomogeneousKernelFunctors {
|
|||
using CartesianKernelFunctors::Are_parallel_2;
|
||||
using CartesianKernelFunctors::Are_parallel_3;
|
||||
using CartesianKernelFunctors::Compute_squared_area_3;
|
||||
using CartesianKernelFunctors::Compare_squared_radius_2;
|
||||
using CartesianKernelFunctors::Compare_squared_radius_3;
|
||||
using CartesianKernelFunctors::Collinear_3;
|
||||
using CartesianKernelFunctors::Construct_line_3;
|
||||
|
|
|
|||
|
|
@ -365,6 +365,36 @@ compare_slopes(const Segment_2<K> &s1, const Segment_2<K> &s2)
|
|||
}
|
||||
#endif
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_radius(const Point_2<K> &p,
|
||||
const typename K::FT &sr)
|
||||
{
|
||||
return internal::compare_squared_radius(p, sr, K());
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_radius(const Point_2<K> &p,
|
||||
const Point_2<K> &q,
|
||||
const typename K::FT &sr)
|
||||
{
|
||||
return internal::compare_squared_radius(p, q, sr, K());
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_radius(const Point_2<K> &p,
|
||||
const Point_2<K> &q,
|
||||
const Point_2<K> &r,
|
||||
const typename K::FT &sr)
|
||||
{
|
||||
return internal::compare_squared_radius(p, q, r, sr, K());
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
|
|
|
|||
|
|
@ -383,6 +383,40 @@ compare_slope(const typename K::Point_2 &s1s,
|
|||
return k.compare_slope_2_object()(s1s, s1t, s2s, s2t);
|
||||
}
|
||||
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_radius(const typename K::Point_2 &p,
|
||||
const typename K::FT &sr,
|
||||
const K& k)
|
||||
{
|
||||
return k.compare_squared_radius_2_object()(p, sr);
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_radius(const typename K::Point_2 &p,
|
||||
const typename K::Point_2 &q,
|
||||
const typename K::FT &sr,
|
||||
const K& k)
|
||||
{
|
||||
return k.compare_squared_radius_2_object()(p, q, sr);
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
compare_squared_radius(const typename K::Point_2 &p,
|
||||
const typename K::Point_2 &q,
|
||||
const typename K::Point_2 &r,
|
||||
const typename K::FT &sr,
|
||||
const K& k)
|
||||
{
|
||||
return k.compare_squared_radius_2_object()(p, q, r, sr);
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Comparison_result
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ CGAL_Kernel_pred(Compare_squared_distance_2,
|
|||
compare_squared_distance_2_object)
|
||||
CGAL_Kernel_pred(Compare_squared_distance_3,
|
||||
compare_squared_distance_3_object)
|
||||
CGAL_Kernel_pred(Compare_squared_radius_2,
|
||||
compare_squared_radius_2_object)
|
||||
CGAL_Kernel_pred(Compare_squared_radius_3,
|
||||
compare_squared_radius_3_object)
|
||||
CGAL_Kernel_pred(Compare_weighted_squared_radius_3,
|
||||
|
|
|
|||
Loading…
Reference in New Issue