26 #ifndef WFMATH_ROT_BOX_H 27 #define WFMATH_ROT_BOX_H 29 #include <wfmath/point.h> 30 #include <wfmath/rotmatrix.h> 31 #include <wfmath/intersect_decls.h> 36 std::ostream& operator<<(std::ostream& os, const RotBox<dim>& r);
38 std::istream& operator>>(std::istream& is, RotBox<dim>& r);
50 RotBox() : m_corner0{}, m_size{}, m_orient{} {}
59 m_orient(orientation) {}
72 friend std::ostream& operator<< <dim>(std::ostream& os,
const RotBox& r);
73 friend std::istream&
operator>> <dim>(std::istream& is,
RotBox& r);
79 bool operator==(
const RotBox& b)
const {
return isEqualTo(b);}
80 bool operator!=(
const RotBox& b)
const {
return !isEqualTo(b);}
82 bool isValid()
const {
return m_corner0.isValid() && m_size.isValid()
83 && m_orient.isValid();}
87 size_t numCorners()
const {
return 1 << dim;}
89 Point<dim> getCenter()
const {
return m_corner0 +
Prod(m_size / 2, m_orient);}
107 {m_corner0 += v;
return *
this;}
109 {
return shift(p - getCorner(corner));}
111 {
return shift(p - getCenter());}
114 {rotatePoint(m, getCorner(corner));
return *
this;}
116 {rotatePoint(m, getCenter());
return *
this;}
118 {m_orient =
Prod(m_orient, m); m_corner0.rotate(m, p);
return *
this;}
129 {
return Ball<dim>(getCenter(), m_size.mag() / 2);}
131 {
return Ball<dim>(getCenter(), m_size.sqrMag() / 2);}
135 {
return RotBox(m_corner0.toParentCoords(origin, rotation), m_size,
136 m_orient * rotation);}
138 {
return RotBox(m_corner0.toParentCoords(coords), m_size, m_orient);}
140 {
return RotBox(m_corner0.toParentCoords(coords), m_size,
141 m_orient * coords.m_orient);}
149 {
return RotBox(m_corner0.toLocalCoords(origin, rotation), m_size,
150 rotation * m_orient);}
152 {
return RotBox(m_corner0.toLocalCoords(coords), m_size, m_orient);}
154 {
return RotBox(m_corner0.toLocalCoords(coords), m_size,
155 coords.m_orient * m_orient);}
161 friend bool Intersect<dim>(
const RotBox& r,
const Point<dim>& p,
bool proper);
162 friend bool Contains<dim>(
const Point<dim>& p,
const RotBox& r,
bool proper);
168 friend bool Intersect<dim>(
const RotBox& r,
const Ball<dim>& b,
bool proper);
169 friend bool Contains<dim>(
const RotBox& r,
const Ball<dim>& b,
bool proper);
170 friend bool Contains<dim>(
const Ball<dim>& b,
const RotBox& r,
bool proper);
176 friend bool Intersect<dim>(
const RotBox& r1,
const RotBox& r2,
bool proper);
177 friend bool Contains<dim>(
const RotBox& outer,
const RotBox& inner,
bool proper);
193 return Equal(m_corner0, b.m_corner0, epsilon)
194 && Equal(m_size, b.m_size, epsilon)
195 && Equal(m_orient, b.m_orient, epsilon);
200 #endif // WFMATH_ROT_BOX_H Generic library namespace.
const Vector< dim > & size() const
returns the size of the box
A dim dimensional axis-aligned box.
const Point< dim > & corner0() const
returns the base corner of the box
RotBox()
construct an uninitialized box
void fromAtlas(const AtlasInType &a)
Set the box's value to that given by an Atlas object.
RotMatrix< dim > & orientation()
returns the orientation of the box
A dim dimensional rotation matrix. Technically, a member of the group O(dim).
double CoordType
Basic floating point type.
A dim dimensional box, lying at an arbitrary angle.
Vector< dim > & size()
returns the size of the box
A polygon, all of whose points lie in a plane, embedded in dim dimensions.
RotBox(const Point< dim > &p, const Vector< dim > &size, const RotMatrix< dim > &orientation)
construct a box from the given parameters
A dim dimensional vector.
const RotMatrix< dim > & orientation() const
returns the orientation of the box
A line segment embedded in dim dimensions.
AtlasOutType toAtlas() const
Create an Atlas object from the box.
Point< dim > & corner0()
returns the base corner of the box
RotMatrix< dim > Prod(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2