KJB
doublecircle.h
Go to the documentation of this file.
1
6 /*
7  * \$Id: doublecircle.h 17559 2014-09-19 00:49:43Z predoehl \$
8  */
9
10 #ifndef DOUBLECIRCLE_H_UOFARIZONAVISION
11 #define DOUBLECIRCLE_H_UOFARIZONAVISION 1
12
13 #include <l/l_sys_sys.h>
14 #include <m_cpp/m_vector_d.h>
15 #include <qd_cpp/pixpoint.h>
16
17 #include <vector>
18
19
20 namespace kjb
21 {
22 namespace qd
23 {
24
29 {
32
42  DoubleCircle( double rad, const Vector2& ctr )
43  : radius( fabs( rad ) ),
44  center( ctr )
45  {}
46
49  const Vector2& p1,
50  const Vector2& p2,
51  const Vector2& p3
52  );
53
55  DoubleCircle( const Vector2& p1, const Vector2& p2 )
56  : radius( ( p1 - p2 ).magnitude() * 0.5 ),
57  center( ( p1 + p2 ) * 0.5 )
58  {}
59
61  void swap( DoubleCircle& that )
62  {
64  center.swap( that.center );
65  }
66
68  bool is_degenerate() const
69  {
70  return ! finite( radius )
71  || radius <= 0
72  || isnand( center.x() )
73  || isnand( center.y() );
74  }
75
77  bool is_not_degenerate() const
78  {
79  return ! is_degenerate();
80  }
81
89  DoubleCircle( const std::vector< Vector2 >& );
90
100  bool outside_me_is( const Vector2& query ) const
101  {
102  return radius < ( query - center ).magnitude();
103  }
104 };
105
106
107
108
109
110 }
111 }
112
113 namespace std
114 {
115
117  template<>
118  inline void swap(
121  )
122  {
123  p1.swap( p2 );
124  }
125
126 }
127
128
129
130 #endif /* DOUBLECIRCLE_H_UOFARIZONAVISION */
void swap(DoubleCircle &that)
swap representations of two circles
Definition: doublecircle.h:61
DoubleCircle(double rad, const Vector2 &ctr)
ctor from a radius and center point
Definition: doublecircle.h:42
bool is_not_degenerate() const
predicate to test for non-degeneracy
Definition: doublecircle.h:77
double y() const
Definition: m_vector_d.impl.h:169
bool outside_me_is(const Vector2 &query) const
test whether a query point is outside this object's disc
Definition: doublecircle.h:100
Parameterized circle in the plane.
Definition: doublecircle.h:28
bool is_degenerate() const
predicate to test for degeneracy
Definition: doublecircle.h:68
distance between center and points of the circle
Definition: doublecircle.h:30
double x() const
Definition: m_vector_d.impl.h:134
Vector2 center
center of the circle
Definition: doublecircle.h:31
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
DoubleCircle(const Vector2 &p1, const Vector2 &p2)
ctor from points; OK if they are equal
Definition: doublecircle.h:55
Contains definition for classes PixPath, PixPathAc, DoubleCircle.