mirror of https://github.com/CGAL/cgal
Fix Segment_3-Sphere_3 do intersect: detect fully contained segments
This commit is contained in:
parent
65b7d11acd
commit
6b6ab287a8
|
|
@ -28,12 +28,33 @@ do_intersect(const typename K::Sphere_3& sp,
|
|||
const K& k)
|
||||
{
|
||||
typedef typename K::RT RT;
|
||||
RT num, den;
|
||||
typedef typename K::Bounded_side Bounded_side;
|
||||
|
||||
typename K::Bounded_side_3 bounded_side = k.bounded_side_3_object();
|
||||
typename K::Compute_squared_radius_3 sq_radius = k.compute_squared_radius_3_object();
|
||||
typename K::Construct_center_3 center = k.construct_center_3_object();
|
||||
typename K::Construct_source_3 source = k.construct_source_3_object();
|
||||
typename K::Construct_target_3 target = k.construct_target_3_object();
|
||||
|
||||
const Bounded_side source_side = bounded_side(sp, source(seg));
|
||||
const Bounded_side target_side = bounded_side(sp, target(seg));
|
||||
|
||||
if(source_side != target_side)
|
||||
return true;
|
||||
else if(source_side == ON_BOUNDED_SIDE) // else if ==> both extremities are on the same side
|
||||
return false;
|
||||
else if(source_side == ON_BOUNDARY)
|
||||
return true;
|
||||
|
||||
CGAL_kernel_assertion(source_side == ON_UNBOUNDED_SIDE && target_side == ON_UNBOUNDED_SIDE);
|
||||
|
||||
// Both out can still be intersecting the sphere
|
||||
RT num, den;
|
||||
CGAL::internal::squared_distance_RT(center(sp), seg, num, den, k);
|
||||
|
||||
CGAL::internal::squared_distance_RT(sp.center(), seg, num, den, k);
|
||||
return !(compare_quotients<RT>(num, den,
|
||||
Rational_traits<typename K::FT>().numerator(sp.squared_radius()),
|
||||
Rational_traits<typename K::FT>().denominator(sp.squared_radius())) == LARGER);
|
||||
Rational_traits<typename K::FT>().numerator(sq_radius(sp)),
|
||||
Rational_traits<typename K::FT>().denominator(sq_radius(sp))) == LARGER);
|
||||
}
|
||||
|
||||
template <class K>
|
||||
|
|
|
|||
|
|
@ -68,16 +68,17 @@ public:
|
|||
// see segment_segment.cpp
|
||||
}
|
||||
|
||||
// @fixme EPICK
|
||||
void S_Sph()
|
||||
{
|
||||
std::cout << "Segment - Sphere\n";
|
||||
|
||||
// No intersection
|
||||
check_do_not_intersect(S(p(4,1,9), p(4,6,-1)), Sph(p(9,2,4), 1));
|
||||
check_do_not_intersect(S(p(-2,3,4), p(1,2,-1)), Sph(p(9,2,4), 10000));
|
||||
check_do_not_intersect(S(p(-2,3,4), p(1,2,-1)), Sph(p(9,2,4), 10000));
|
||||
|
||||
check_do_intersect(S(p(0,1,0), p(2,1,0)), Sph(p(1,0,0), 1));
|
||||
check_do_intersect(S(p(-2,3,4), p(1,2,-1)), Sph(p(9,2,4), 100));
|
||||
check_do_intersect(S(p(-2,3,4), p(3,2,-5)), Sph(p(9,2,4), 100));
|
||||
|
||||
for(int i=0; i<N; ++i)
|
||||
{
|
||||
|
|
@ -92,8 +93,6 @@ public:
|
|||
Sph sph(c, sqr);
|
||||
if(sph.oriented_side(s0) != sph.oriented_side(s1))
|
||||
check_do_intersect(sph, S(s0, s1));
|
||||
else
|
||||
check_do_not_intersect(sph, S(s0, s1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +181,7 @@ public:
|
|||
std::cout << "3D Segment Intersection tests\n";
|
||||
|
||||
S_S();
|
||||
// S_Sph(); // @fixme
|
||||
S_Sph();
|
||||
S_Tet();
|
||||
S_Tr();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue