1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Incircle_C2.h $
// $Id: Incircle_C2.h 44317 2008-07-22 12:29:01Z spion $
//
//
// Author(s) : Menelaos Karavelas <mkaravel@cse.nd.edu>
#ifndef CGAL_APOLLONIUS_GRAPH_2_INCIRCLE_C2_H
#define CGAL_APOLLONIUS_GRAPH_2_INCIRCLE_C2_H
#include <CGAL/Apollonius_graph_2/basic.h>
#include <CGAL/Apollonius_graph_2/Predicate_constructions_C2.h>
#include <CGAL/Apollonius_graph_2/Bounded_side_of_ccw_circle_C2.h>
CGAL_BEGIN_NAMESPACE
CGAL_APOLLONIUS_GRAPH_2_BEGIN_NAMESPACE
//--------------------------------------------------------------------
template< class K >
class Sign_of_distance_from_bitangent_line_2
{
public:
typedef Bitangent_line_2<K> Bitangent_line;
typedef typename K::Site_2 Site_2;
typedef Inverted_weighted_point_2<K> Inverted_weighted_point;
typedef typename K::FT FT;
typedef typename K::Sign Sign;
public:
inline Sign
operator()(const Bitangent_line& bl, const Site_2& q,
const Field_with_sqrt_tag&) const
{
#ifdef AG2_PROFILE_PREDICATES
ag2_predicate_profiler::distance_from_bitangent_counter++;
#endif
FT a = bl.a1() + bl.a2() * CGAL::sqrt(bl.delta());
FT b = bl.b1() + bl.b2() * CGAL::sqrt(bl.delta());
FT c = bl.c1() + bl.c2() * CGAL::sqrt(bl.delta());
FT r = a * q.x() + b * q.y() + c - q.weight() * bl.d();
return CGAL::sign(r);
}
inline Sign
operator()(const Bitangent_line& bl, const Site_2& q,
const Integral_domain_without_division_tag&) const
{
#ifdef AG2_PROFILE_PREDICATES
ag2_predicate_profiler::distance_from_bitangent_counter++;
#endif
FT A = bl.a1() * q.x() + bl.b1() * q.y() + bl.c1()
- q.weight() * bl.d();
FT B = bl.a2() * q.x() + bl.b2() * q.y() + bl.c2();
return sign_a_plus_b_x_sqrt_c(A, B, bl.delta());
}
};
//--------------------------------------------------------------------
template< class K >
class Sign_of_distance_from_CCW_circle_2
{
public:
typedef Bitangent_line_2<K> Bitangent_line;
typedef Inverted_weighted_point_2<K> Inverted_weighted_point;
typedef typename K::FT FT;
typedef typename K::Sign Sign;
public:
inline Sign
operator()(const Bitangent_line& bl,
const Inverted_weighted_point& v,
const Field_with_sqrt_tag&) const
{
FT a = bl.a1() + bl.a2() * CGAL::sqrt(bl.delta());
FT b = bl.b1() + bl.b2() * CGAL::sqrt(bl.delta());
FT c = bl.c1() + bl.c2() * CGAL::sqrt(bl.delta());
FT r = a * v.x() + b * v.y() + c * v.p() - v.weight() * bl.d();
return CGAL::sign(r);
}
inline Sign
operator()(const Bitangent_line& bl,
const Inverted_weighted_point& v,
const Integral_domain_without_division_tag&) const
{
FT A = bl.a1() * v.x() + bl.b1() * v.y() + bl.c1() * v.p()
- v.weight() * bl.d();
FT B = bl.a2() * v.x() + bl.b2() * v.y() + bl.c2() * v.p();
return sign_a_plus_b_x_sqrt_c(A, B, bl.delta());
}
};
template < class Weighted_point >
class Weighted_point_less_than
{
public:
inline
bool operator()(const Weighted_point& p1,
const Weighted_point& p2) const
{
if ( p1.x() == p2.x() ) {
return p1.y() < p2.y();
}
return p1.x() < p2.x();
}
};
template < class K, class MTag >
class Vertex_conflict_2
{
public:
typedef K Kernel;
typedef MTag Method_tag;
typedef typename K::Point_2 Point_2;
typedef typename K::Site_2 Site_2;
typedef Weighted_point_inverter_2<K> Weighted_point_inverter;
typedef Inverted_weighted_point_2<K> Inverted_weighted_point;
typedef Bitangent_line_2<K> Bitangent_line;
typedef Voronoi_radius_2<K> Voronoi_radius;
typedef typename K::FT FT;
typedef typename K::Orientation Orientation;
typedef typename K::Sign Sign;
typedef typename K::Bounded_side Bounded_side;
typedef Bounded_side_of_CCW_circle_2<K> Bounded_side_of_CCW_circle;
typedef Sign_of_distance_from_bitangent_line_2<K>
Sign_of_distance_from_bitangent_line;
typedef Sign_of_distance_from_CCW_circle_2<K>
Sign_of_distance_from_CCW_circle;
private:
inline Orientation
orientation(const Bitangent_line& l, const Point_2& p,
const Field_with_sqrt_tag&) const
{
FT A = l.a1() * p.x() + l.b1() * p.y() + l.c1();
FT B = l.a2() * p.x() + l.b2() * p.y() + l.c2();
FT P = A + B * CGAL::sqrt(l.delta());
return CGAL::sign(P);
}
inline Orientation
orientation(const Bitangent_line& l, const Point_2& p,
const Integral_domain_without_division_tag&) const
{
FT A = l.a1() * p.x() + l.b1() * p.y() + l.c1();
FT B = l.a2() * p.x() + l.b2() * p.y() + l.c2();
return sign_a_plus_b_x_sqrt_c(A, B, l.delta());
}
inline Orientation
orientation(const Bitangent_line& l,
const Inverted_weighted_point& u) const
{
FT A = l.a1() * u.x() / u.p() + l.b1() * u.y() / u.p() + l.c1();
FT B = l.a2() * u.x() / u.p() + l.b2() * u.y() / u.p() + l.c2();
FT P = A + B * CGAL::sqrt(l.delta());
return CGAL::sign(P);
}
public:
typedef Sign result_type;
typedef Site_2 argument_type;
inline
Sign operator()(const Site_2& p1, const Site_2& p2,
const Site_2& p3, const Site_2& q) const
{
#ifdef AG2_PROFILE_PREDICATES
ag2_predicate_profiler::incircle_counter++;
#endif
//
Method_tag tag;
Weighted_point_inverter inverter(p1);
Inverted_weighted_point u2 = inverter(p2);
Inverted_weighted_point u3 = inverter(p3);
Voronoi_radius vr_123(u2, u3);
Bounded_side bs = Bounded_side_of_CCW_circle()(vr_123, tag );
if ( bs != ON_UNBOUNDED_SIDE ) { return NEGATIVE; }
Inverted_weighted_point v = inverter(q);
Bitangent_line blinv_23(u2, u3);
Sign s = Sign_of_distance_from_CCW_circle()(blinv_23, v, tag);
return s;
}
inline
Sign operator()(const Site_2& p1, const Site_2& p2,
const Site_2& q) const
{
Method_tag tag;
//
Bitangent_line bl_21(p2, p1);
Sign s = Sign_of_distance_from_bitangent_line()(bl_21, q, tag);
if ( s != ZERO ) { return s; }
Bitangent_line bl1_perp = bl_21.perpendicular(p1.point());
Bitangent_line bl2_perp = bl_21.perpendicular(p2.point());
Orientation o1 = orientation(bl1_perp, q.point(), tag);
Orientation o2 = orientation(bl2_perp, q.point(), tag);
CGAL_assertion( o1 != COLLINEAR || o2 != COLLINEAR );
if ( o1 == o2 ) { return POSITIVE; }
return NEGATIVE;
}
};
//--------------------------------------------------------------------
CGAL_APOLLONIUS_GRAPH_2_END_NAMESPACE
CGAL_END_NAMESPACE
#endif // CGAL_APOLLONIUS_GRAPH_2_INCIRCLE_C2_H
|