mirror of https://github.com/CGAL/cgal
Made compute_squared_smallest_orthogonal_circle_2() a kernel functor
and documented, tested, etc. it Previously in Alpha_shape_2
This commit is contained in:
parent
e65eae4802
commit
dd2e7f3a0c
|
|
@ -475,7 +475,39 @@ radical_axisC2(const RT &px, const RT &py, const We &pw,
|
|||
+RT(pw) - RT(qw);
|
||||
}
|
||||
|
||||
template< class FT >
|
||||
CGAL_KERNEL_MEDIUM_INLINE
|
||||
FT
|
||||
squared_radius_orthogonal_circleC2(const FT &px, const FT &py, const FT &pw,
|
||||
const FT &qx, const FT &qy, const FT &qw,
|
||||
const FT &rx, const FT &ry, const FT &rw)
|
||||
{
|
||||
FT FT4(4);
|
||||
FT dpx = px - rx;
|
||||
FT dpy = py - ry;
|
||||
FT dqx = qx - rx;
|
||||
FT dqy = qy - ry;
|
||||
FT dpp = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pw + rw;
|
||||
FT dqq = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qw + rw;
|
||||
|
||||
FT det0 = determinant(dpx, dpy, dqx, dqy);
|
||||
FT det1 = determinant(dpp, dpy, dqq, dqy);
|
||||
FT det2 = determinant(dpx, dpp, dqx, dqq);
|
||||
|
||||
return (CGAL_NTS square(det1) + CGAL_NTS square(det2)) /
|
||||
(FT4 * CGAL_NTS square(det0)) - rw;
|
||||
}
|
||||
|
||||
template< class FT >
|
||||
CGAL_KERNEL_MEDIUM_INLINE
|
||||
FT
|
||||
squared_radius_smallest_orthogonal_circleC2(const FT &px, const FT &py, const FT &pw,
|
||||
const FT &qx, const FT &qy, const FT &qw)
|
||||
{
|
||||
FT FT4(4);
|
||||
FT dpz = CGAL_NTS square(px - qx) + CGAL_NTS square(py - qy);
|
||||
return (CGAL_NTS square(dpz - pw + qw) / (FT4 * dpz) - qw);
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -2410,43 +2410,6 @@ public:
|
|||
/// @}
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernel23ConceptsFunctionObjects
|
||||
\cgalConcept
|
||||
|
||||
\sa `CGAL::Weighted_point_3<Kernel>`
|
||||
\sa `ComputePowerProduct_3` for the definition of orthogonal sphere
|
||||
|
||||
\cgalRefines `AdaptableFunctor`
|
||||
|
||||
*/
|
||||
class ComputeSquaredRadiusSmallestOrthogonalSphere_3 {
|
||||
public:
|
||||
/// \name Operations
|
||||
/// A model of this concept must provide:
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the squared radius of the
|
||||
smallest sphere orthogonal to the argument(s).
|
||||
*/
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw,
|
||||
const Kernel::Weighted_point_3& qw,
|
||||
const Kernel::Weighted_point_3& rw,
|
||||
const Kernel::Weighted_point_3& sw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw,
|
||||
const Kernel::Weighted_point_3& qw,
|
||||
const Kernel::Weighted_point_3& rw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw,
|
||||
const Kernel::Weighted_point_3& qw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw) const;
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernel23ConceptsFunctionObjects
|
||||
\cgalConcept
|
||||
|
|
@ -2894,6 +2857,75 @@ public:
|
|||
|
||||
}; /* end Kernel::ComputeSquaredRadius_3 */
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernel23ConceptsFunctionObjects
|
||||
\cgalConcept
|
||||
|
||||
\sa `CGAL::Weighted_point_2<Kernel>`
|
||||
\sa `ComputePowerProduct_3` for the definition of orthogonality for power distances.
|
||||
|
||||
\cgalRefines `AdaptableFunctor`
|
||||
|
||||
*/
|
||||
class ComputeSquaredRadiusSmallestOrthogonalCircle_2 {
|
||||
public:
|
||||
/// \name Operations
|
||||
/// A model of this concept must provide:
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the squared radius of the
|
||||
smallest sphere circle to the argument(s).
|
||||
*/
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_2& pw,
|
||||
const Kernel::Weighted_point_2& qw,
|
||||
const Kernel::Weighted_point_2& rw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_2& pw,
|
||||
const Kernel::Weighted_point_2& qw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_2& pw) const;
|
||||
|
||||
/// @}
|
||||
}; /* end Kernel::ComputeSquaredRadiusSmallestOrthogonalCircle_2 */
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernel23ConceptsFunctionObjects
|
||||
\cgalConcept
|
||||
|
||||
\sa `CGAL::Weighted_point_3<Kernel>`
|
||||
\sa `ComputePowerProduct_3` for the definition of orthogonal sphere
|
||||
|
||||
\cgalRefines `AdaptableFunctor`
|
||||
|
||||
*/
|
||||
class ComputeSquaredRadiusSmallestOrthogonalSphere_3 {
|
||||
public:
|
||||
/// \name Operations
|
||||
/// A model of this concept must provide:
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the squared radius of the
|
||||
smallest sphere orthogonal to the argument(s).
|
||||
*/
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw,
|
||||
const Kernel::Weighted_point_3& qw,
|
||||
const Kernel::Weighted_point_3& rw,
|
||||
const Kernel::Weighted_point_3& sw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw,
|
||||
const Kernel::Weighted_point_3& qw,
|
||||
const Kernel::Weighted_point_3& rw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw,
|
||||
const Kernel::Weighted_point_3& qw) const;
|
||||
|
||||
Kernel::FT operator() (const Kernel::Weighted_point_3& pw) const;
|
||||
|
||||
/// @}
|
||||
}; /* end Kernel::ComputeSquaredRadiusSmallestOrthogonalSphere_3 */
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernel23ConceptsFunctionObjects
|
||||
\cgalConcept
|
||||
|
|
|
|||
|
|
@ -790,6 +790,7 @@ A type representing weighted points in two dimensions.
|
|||
|
||||
\sa `ConstructWeightedPoint_2`
|
||||
\sa `ComparePowerDistance_2`
|
||||
\sa `ComputeSquaredRadiusSmallestOrthogonalCircle_2`
|
||||
\sa `ConstructRadicalAxis_2`
|
||||
\sa `ConstructWeightedCircumcenter_2`
|
||||
\sa `PowerSideOfOrientedPowerCircle_2`
|
||||
|
|
|
|||
|
|
@ -527,6 +527,11 @@ public:
|
|||
*/
|
||||
typedef unspecified_type Compute_squared_radius_2;
|
||||
|
||||
/*!
|
||||
a model of `Kernel::ComputeSquaredRadiusSmallestOrthogonalCircle_2`
|
||||
*/
|
||||
typedef unspecified_type Compute_squared_radius_smallest_orthogonal_circle_2;
|
||||
|
||||
/*!
|
||||
a model of `Kernel::ComputeArea_2`
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -321,6 +321,7 @@
|
|||
- `Kernel::ComputeSquaredLengthDividedByPiSquare_3`
|
||||
- `Kernel::ComputeSquaredRadius_2`
|
||||
- `Kernel::ComputeSquaredRadius_3`
|
||||
- `Kernel::ComputeSquaredRadiusSmallestOrthogonalCircle_2`
|
||||
- `Kernel::ComputeSquaredRadiusSmallestOrthogonalSphere_3`
|
||||
- `Kernel::ComputeVolume_3`
|
||||
- `Kernel::ComputeWeight_2`
|
||||
|
|
|
|||
|
|
@ -538,6 +538,37 @@ public:
|
|||
};
|
||||
|
||||
|
||||
template < typename K >
|
||||
class Compute_squared_radius_smallest_orthogonal_circle_2
|
||||
{
|
||||
public:
|
||||
typedef typename K::Weighted_point_2 Weighted_point_2;
|
||||
typedef typename K::FT FT;
|
||||
|
||||
typedef FT result_type;
|
||||
|
||||
FT operator()(const Weighted_point_2& p,
|
||||
const Weighted_point_2& q,
|
||||
const Weighted_point_2& r) const
|
||||
{
|
||||
return squared_radius_orthogonal_circleC2(p.x(), p.y(), p.weight(),
|
||||
q.x(), q.y(), q.weight(),
|
||||
r.x(), r.y(), r.weight());
|
||||
}
|
||||
|
||||
FT operator()(const Weighted_point_2& p,
|
||||
const Weighted_point_2& q) const
|
||||
{
|
||||
return squared_radius_smallest_orthogonal_circleC2(p.x(), p.y(), p.weight(),
|
||||
q.x(), q.y(), q.weight());
|
||||
}
|
||||
|
||||
FT operator()(const Weighted_point_2& p) const
|
||||
{
|
||||
return - p.weight();
|
||||
}
|
||||
};
|
||||
|
||||
template < typename K >
|
||||
class Compute_squared_radius_smallest_orthogonal_sphere_3
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1069,6 +1069,33 @@ squared_radius(const Point_2<K>& p, const Point_2<K>& q, const Point_2<K>& r)
|
|||
return internal::squared_radius(p, q, r, K());
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::FT
|
||||
squared_radius_smallest_orthogonal_circle(const Weighted_point_2<K> &p)
|
||||
{
|
||||
return internal::squared_radius_smallest_orthogonal_circle(p, K());
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::FT
|
||||
squared_radius_smallest_orthogonal_circle(const Weighted_point_2<K> &p,
|
||||
const Weighted_point_2<K> &q)
|
||||
{
|
||||
return internal::squared_radius_smallest_orthogonal_circle(p, q, K());
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::FT
|
||||
squared_radius_smallest_orthogonal_circle(const Weighted_point_2<K> &p,
|
||||
const Weighted_point_2<K> &q,
|
||||
const Weighted_point_2<K> &r)
|
||||
{
|
||||
return internal::squared_radius_smallest_orthogonal_circle(p, q, r, K());
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Point_2
|
||||
|
|
|
|||
|
|
@ -970,6 +970,36 @@ squared_radius(const typename K::Point_2 &p,
|
|||
return k.compute_squared_radius_2_object()(p, q, r);
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::FT
|
||||
squared_radius_smallest_orthogonal_circle(const typename K::Weighted_point_2 &p,
|
||||
const K &k)
|
||||
{
|
||||
return k.compute_squared_radius_smallest_orthogonal_circle_2_object()(p);
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::FT
|
||||
squared_radius_smallest_orthogonal_circle(const typename K::Weighted_point_2 &p,
|
||||
const typename K::Weighted_point_2 &q,
|
||||
const K &k)
|
||||
{
|
||||
return k.compute_squared_radius_smallest_orthogonal_circle_2_object()(p, q);
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::FT
|
||||
squared_radius_smallest_orthogonal_circle(const typename K::Weighted_point_2 &p,
|
||||
const typename K::Weighted_point_2 &q,
|
||||
const typename K::Weighted_point_2 &r,
|
||||
const K &k)
|
||||
{
|
||||
return k.compute_squared_radius_smallest_orthogonal_circle_2_object()(p, q, r);
|
||||
}
|
||||
|
||||
template < class K >
|
||||
inline
|
||||
typename K::Point_2
|
||||
|
|
|
|||
|
|
@ -300,6 +300,8 @@ CGAL_Kernel_cons(Construct_weighted_circumcenter_3,
|
|||
construct_weighted_circumcenter_3_object)
|
||||
CGAL_Kernel_cons(Compute_power_product_3,
|
||||
compute_power_product_3_object)
|
||||
CGAL_Kernel_cons(Compute_squared_radius_smallest_orthogonal_circle_2,
|
||||
compute_squared_radius_smallest_orthogonal_circle_2_object)
|
||||
CGAL_Kernel_cons(Compute_squared_radius_smallest_orthogonal_sphere_3,
|
||||
compute_squared_radius_smallest_orthogonal_sphere_3_object)
|
||||
CGAL_Kernel_cons(Compute_power_distance_to_power_sphere_3,
|
||||
|
|
|
|||
|
|
@ -69,6 +69,13 @@ _test_fct_weighted_point_2(const R& )
|
|||
CGAL::Weighted_point_2<R> wp8_b( p8, 6);
|
||||
CGAL::Weighted_point_2<R> wp10_b( p10, -8);
|
||||
|
||||
CGAL::Point_2<R> p_00(RT(0), RT(0) ); // 0, 0
|
||||
CGAL::Point_2<R> p_10(RT(4), RT(0), RT(1) ); // 4,0
|
||||
CGAL::Point_2<R> p_01(RT(0), RT(5), RT(1) ); // 0,5
|
||||
CGAL::Weighted_point_2<R> wp_00( p_00, RT(0) );
|
||||
CGAL::Weighted_point_2<R> wp_10( p_10, RT(16) );
|
||||
CGAL::Weighted_point_2<R> wp_01( p_01, RT(25) );
|
||||
|
||||
assert( CGAL::compare_power_distance(p1, wp1, wp1) == CGAL::compare_distance(p1, p1, p1));
|
||||
assert( CGAL::compare_power_distance(p1, wp2, wp4) == CGAL::compare_distance(p1, p2, p4));
|
||||
|
||||
|
|
@ -109,6 +116,22 @@ _test_fct_weighted_point_2(const R& )
|
|||
assert(power_side_of_oriented_power_circle(wp1_b, wp4_b, wp5_b, wp5_b) == CGAL::ON_ORIENTED_BOUNDARY );
|
||||
assert(power_side_of_oriented_power_circle(wp1_b, wp4_b, wp5_b, wp6_b) == CGAL::ON_NEGATIVE_SIDE );
|
||||
|
||||
std::cout << ".";
|
||||
|
||||
assert( CGAL::squared_radius_smallest_orthogonal_circle(wp1) == RT(0) );
|
||||
assert( CGAL::squared_radius_smallest_orthogonal_circle(wp1_b) == -wp1_b.weight() );
|
||||
|
||||
std::cout << CGAL::squared_radius_smallest_orthogonal_circle(wp1_b, wp3_b) << std::endl;
|
||||
|
||||
assert( CGAL::squared_radius_smallest_orthogonal_circle(wp3, wp8) == RT(1) );
|
||||
assert( CGAL::squared_radius_smallest_orthogonal_circle(wp1_b, wp3_b) == RT(-3));
|
||||
|
||||
std::cout << CGAL::weighted_circumcenter(wp_00, wp_10, wp_01) << std::endl;
|
||||
|
||||
assert( CGAL::squared_radius_smallest_orthogonal_circle(wp1, wp3, wp5)
|
||||
== CGAL::squared_radius(p1, p3, p5));
|
||||
assert( CGAL::squared_radius_smallest_orthogonal_circle(wp_00, wp_10, wp_01) == RT(0));
|
||||
|
||||
std::cout << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -387,6 +387,14 @@ test_new_2(const R& rep)
|
|||
tmp23b = Compute_squared_radius(p3, p4);
|
||||
tmp23b = Compute_squared_radius(p3, p4, p5);
|
||||
|
||||
typename R::Compute_squared_radius_smallest_orthogonal_circle_2
|
||||
compute_squared_radius_smallest_orthogonal_circle
|
||||
= rep.compute_squared_radius_smallest_orthogonal_circle_2_object();
|
||||
tmp23b = compute_squared_radius_smallest_orthogonal_circle(wp4);
|
||||
tmp23b = compute_squared_radius_smallest_orthogonal_circle(wp4, wp5);
|
||||
tmp23b = compute_squared_radius_smallest_orthogonal_circle(wp4, wp5, wp6);
|
||||
(void) tmp23b;
|
||||
|
||||
typename R::Equal_2 equal
|
||||
= rep.equal_2_object();
|
||||
bool tmp24 = equal(p2,p3);
|
||||
|
|
|
|||
Loading…
Reference in New Issue