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>
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) {}
75 friend std::ostream& operator<< <dim>(std::ostream& os,
const Ball& b);
76 friend std::istream&
operator>> <dim>(std::istream& is,
Ball& b);
83 Ball& operator=(
const Ball& b) =
default;
87 bool operator==(
const Ball& b)
const {
return isEqualTo(b);}
88 bool operator!=(
const Ball& b)
const {
return !isEqualTo(b);}
90 bool isValid()
const {
return m_center.isValid();}
94 size_t numCorners()
const {
return 0;}
99 Point<dim> getCorner(
size_t)
const {
return m_center;}
100 Point<dim> getCenter()
const {
return m_center;}
114 Ball& moveCornerTo(
const Point<dim>&,
size_t) {
return *
this;}
115 Ball& moveCenterTo(
const Point<dim>& p) {m_center = p;
return *
this;}
117 Ball& rotateCorner(
const RotMatrix<dim>&,
size_t) {
return *
this;}
118 Ball& rotateCenter(
const RotMatrix<dim>&) {
return *
this;}
119 Ball& rotatePoint(
const RotMatrix<dim>& m,
const Point<dim>& p)
120 {m_center.rotate(m, p);
return *
this;}
123 Ball& rotateCorner(
const Quaternion&,
size_t corner);
124 Ball& rotateCenter(
const Quaternion&);
125 Ball& rotatePoint(
const Quaternion& q,
const Point<dim>& p);
129 AxisBox<dim> boundingBox()
const;
130 Ball boundingSphere()
const {
return *
this;}
131 Ball boundingSphereSloppy()
const {
return *
this;}
133 Ball toParentCoords(
const Point<dim>& origin,
134 const RotMatrix<dim>& rotation = RotMatrix<dim>().identity())
const
135 {
return Ball(m_center.toParentCoords(origin, rotation), m_radius);}
136 Ball toParentCoords(
const AxisBox<dim>& coords)
const
137 {
return Ball(m_center.toParentCoords(coords), m_radius);}
138 Ball toParentCoords(
const RotBox<dim>& coords)
const
139 {
return Ball(m_center.toParentCoords(coords), m_radius);}
145 Ball toLocalCoords(
const Point<dim>& origin,
146 const RotMatrix<dim>& rotation = RotMatrix<dim>().identity())
const
147 {
return Ball(m_center.toLocalCoords(origin, rotation), m_radius);}
148 Ball toLocalCoords(
const AxisBox<dim>& coords)
const
149 {
return Ball(m_center.toLocalCoords(coords), m_radius);}
150 Ball toLocalCoords(
const RotBox<dim>& coords)
const
151 {
return Ball(m_center.toLocalCoords(coords), m_radius);}
154 Ball toParentCoords(
const Point<dim>& origin,
const Quaternion& rotation)
const;
155 Ball toLocalCoords(
const Point<dim>& origin,
const Quaternion& rotation)
const;
157 friend bool Intersect<dim>(
const Ball& b,
const Point<dim>& p,
bool proper);
158 friend bool Contains<dim>(
const Point<dim>& p,
const Ball& b,
bool proper);
160 friend bool Intersect<dim>(
const Ball& b,
const AxisBox<dim>& a,
bool proper);
161 friend bool Contains<dim>(
const Ball& b,
const AxisBox<dim>& a,
bool proper);
162 friend bool Contains<dim>(
const AxisBox<dim>& a,
const Ball& b,
bool proper);
164 friend bool Intersect<dim>(
const Ball& b1,
const Ball& b2,
bool proper);
165 friend bool Contains<dim>(
const Ball& outer,
const Ball& inner,
bool proper);
167 friend bool Intersect<dim>(
const Segment<dim>& s,
const Ball& b,
bool proper);
168 friend bool Contains<dim>(
const Segment<dim>& s,
const Ball& b,
bool proper);
170 friend bool Intersect<dim>(
const RotBox<dim>& r,
const Ball& b,
bool proper);
171 friend bool Contains<dim>(
const RotBox<dim>& r,
const Ball& b,
bool proper);
172 friend bool Contains<dim>(
const Ball& b,
const RotBox<dim>& r,
bool proper);
174 friend bool Intersect<dim>(
const Polygon<dim>& p,
const Ball& b,
bool proper);
175 friend bool Contains<dim>(
const Polygon<dim>& p,
const Ball& b,
bool proper);
176 friend bool Contains<dim>(
const Ball& b,
const Polygon<dim>& p,
bool proper);
185 inline bool Ball<dim>::isEqualTo(
const Ball<dim>& b,
CoordType epsilon)
const
187 return Equal(m_center, b.m_center, epsilon)
188 && Equal(m_radius, b.m_radius, epsilon);
193 #endif // WFMATH_BALL_H