29 #include <wfmath/point.h>
30 #include <wfmath/intersect_decls.h>
34 template<
int dim>
class Ball;
37 template<
int dim,
template<
class,
class>
class container>
38 Ball<dim>
BoundingSphere(
const container<Point<dim>, std::allocator<Point<dim> > >& c);
40 template<
int dim,
template<
class,
class>
class container>
44 std::ostream& operator<<(std::ostream& os,
const Ball<dim>& m);
46 std::istream& operator>>(std::istream& is, Ball<dim>& m);
64 Ball() : m_center(), m_radius(0.f) {}
69 Ball(
const Ball& b) : m_center(b.m_center), m_radius(b.m_radius) {}
71 explicit Ball(
const AtlasInType& a);
75 friend std::ostream& operator<< <dim>(std::ostream& os,
const Ball& b);
76 friend std::istream&
operator>> <dim>(std::istream& is,
Ball& b);
84 {m_radius = b.m_radius; m_center = b.m_center;
return *
this;}
86 bool isEqualTo(
const Ball& b,
CoordType epsilon = numeric_constants<CoordType>::epsilon())
const;
88 bool operator==(
const Ball& b)
const {
return isEqualTo(b);}
89 bool operator!=(
const Ball& b)
const {
return !isEqualTo(b);}
91 bool isValid()
const {
return m_center.isValid();}
95 size_t numCorners()
const {
return 0;}
100 Point<dim> getCorner(
size_t)
const {
return m_center;}
101 Point<dim> getCenter()
const {
return m_center;}
115 Ball& moveCornerTo(
const Point<dim>&,
size_t) {
return *
this;}
116 Ball& moveCenterTo(
const Point<dim>& p) {m_center = p;
return *
this;}
118 Ball& rotateCorner(
const RotMatrix<dim>&,
size_t) {
return *
this;}
119 Ball& rotateCenter(
const RotMatrix<dim>&) {
return *
this;}
120 Ball& rotatePoint(
const RotMatrix<dim>& m,
const Point<dim>& p)
121 {m_center.
rotate(m, p);
return *
this;}
124 Ball& rotateCorner(
const Quaternion&,
size_t corner);
125 Ball& rotateCenter(
const Quaternion&);
126 Ball& rotatePoint(
const Quaternion& q,
const Point<dim>& p);
130 AxisBox<dim> boundingBox()
const;
131 Ball boundingSphere()
const {
return *
this;}
132 Ball boundingSphereSloppy()
const {
return *
this;}
134 Ball toParentCoords(
const Point<dim>& origin,
135 const RotMatrix<dim>& rotation = RotMatrix<dim>().identity())
const
136 {
return Ball(m_center.toParentCoords(origin, rotation), m_radius);}
137 Ball toParentCoords(
const AxisBox<dim>& coords)
const
138 {
return Ball(m_center.toParentCoords(coords), m_radius);}
139 Ball toParentCoords(
const RotBox<dim>& coords)
const
140 {
return Ball(m_center.toParentCoords(coords), m_radius);}
146 Ball toLocalCoords(
const Point<dim>& origin,
147 const RotMatrix<dim>& rotation = RotMatrix<dim>().identity())
const
148 {
return Ball(m_center.toLocalCoords(origin, rotation), m_radius);}
149 Ball toLocalCoords(
const AxisBox<dim>& coords)
const
150 {
return Ball(m_center.toLocalCoords(coords), m_radius);}
151 Ball toLocalCoords(
const RotBox<dim>& coords)
const
152 {
return Ball(m_center.toLocalCoords(coords), m_radius);}
155 Ball toParentCoords(
const Point<dim>& origin,
const Quaternion& rotation)
const;
156 Ball toLocalCoords(
const Point<dim>& origin,
const Quaternion& rotation)
const;
158 friend bool Intersect<dim>(
const Ball& b,
const Point<dim>& p,
bool proper);
159 friend bool Contains<dim>(
const Point<dim>& p,
const Ball& b,
bool proper);
161 friend bool Intersect<dim>(
const Ball& b,
const AxisBox<dim>& a,
bool proper);
162 friend bool Contains<dim>(
const Ball& b,
const AxisBox<dim>& a,
bool proper);
163 friend bool Contains<dim>(
const AxisBox<dim>& a,
const Ball& b,
bool proper);
165 friend bool Intersect<dim>(
const Ball& b1,
const Ball& b2,
bool proper);
166 friend bool Contains<dim>(
const Ball& outer,
const Ball& inner,
bool proper);
168 friend bool Intersect<dim>(
const Segment<dim>& s,
const Ball& b,
bool proper);
169 friend bool Contains<dim>(
const Segment<dim>& s,
const Ball& b,
bool proper);
171 friend bool Intersect<dim>(
const RotBox<dim>& r,
const Ball& b,
bool proper);
172 friend bool Contains<dim>(
const RotBox<dim>& r,
const Ball& b,
bool proper);
173 friend bool Contains<dim>(
const Ball& b,
const RotBox<dim>& r,
bool proper);
175 friend bool Intersect<dim>(
const Polygon<dim>& p,
const Ball& b,
bool proper);
176 friend bool Contains<dim>(
const Polygon<dim>& p,
const Ball& b,
bool proper);
177 friend bool Contains<dim>(
const Ball& b,
const Polygon<dim>& p,
bool proper);
186 inline bool Ball<dim>::isEqualTo(
const Ball<dim>& b,
CoordType epsilon)
const
188 return Equal(m_center, b.m_center, epsilon)
189 &&
Equal(m_radius, b.m_radius, epsilon);
A dim dimensional ball.
Definition: ball.h:61
const Point< dim > & center() const
get the center of the ball
Definition: ball.h:104
AtlasOutType toAtlas() const
Create an Atlas object from the box.
Definition: atlasconv.h:272
void fromAtlas(const AtlasInType &a)
Set the box's value to that given by an Atlas object.
Definition: atlasconv.h:248
Ball()
construct an uninitialized ball
Definition: ball.h:64
CoordType radius() const
get the radius of the ball
Definition: ball.h:108
CoordType & radius()
get the radius of the ball
Definition: ball.h:110
Ball(const Point< dim > ¢er, CoordType radius)
construct a ball with the given center and radius
Definition: ball.h:66
Ball(const Ball &b)
construct a copy of a ball
Definition: ball.h:69
Point< dim > & center()
get the center of the ball
Definition: ball.h:106
void setValid(bool valid=true)
make isValid() return true if you've initialized the point by hand
Definition: point.h:129
Point & rotate(const RotMatrix< dim > &m, const Point &p)
Rotate about point p.
Definition: point.h:146
Generic library namespace.
Definition: atlasconv.h:45
bool Equal(const C &c1, const C &c2, CoordType epsilon=numeric_constants< CoordType >::epsilon())
Test for equality up to precision epsilon.
Definition: const.h:158
float CoordType
Basic floating point type.
Definition: const.h:140
Ball< dim > BoundingSphere(const container< Point< dim >, std::allocator< Point< dim > > > &c)
get the minimal bounding sphere for a set of points
Definition: ball_funcs.h:57
Ball< dim > BoundingSphereSloppy(const container< Point< dim >, std::allocator< Point< dim > > > &c)
get a bounding sphere for a set of points
Definition: ball_funcs.h:92