29#include <wfmath/const.h>
39Point<dim>& operator+=(Point<dim>& p,
const Vector<dim>& v);
41Point<dim>& operator-=(Point<dim>& p,
const Vector<dim>& v);
44Vector<dim> operator-(
const Point<dim>& c1,
const Point<dim>& c2);
46Point<dim> operator+(
const Point<dim>& c,
const Vector<dim>& v);
48Point<dim> operator+(
const Vector<dim>& v,
const Point<dim>& c);
50Point<dim> operator-(
const Point<dim>& c,
const Vector<dim>& v);
53CoordType SquaredDistance(
const Point<dim>& p1,
const Point<dim>& p2);
55CoordType Distance(
const Point<dim>& p1,
const Point<dim>& p2)
56 {
return std::sqrt(SquaredDistance(p1, p2));}
58CoordType SloppyDistance(
const Point<dim>& p1,
const Point<dim>& p2)
59 {
return (p1 - p2).sloppyMag();}
62template<
int dim,
template<
class,
class>
class container>
63Point<dim>
Barycenter(
const container<Point<dim>, std::allocator<Point<dim> > >& c);
71template<
int dim,
template<
class,
class>
class container,
72 template<
class,
class>
class container2>
73Point<dim>
Barycenter(
const container<Point<dim>, std::allocator<Point<dim> > >& c,
74 const container2<
CoordType, std::allocator<CoordType> >& weights);
78Point<dim>
Midpoint(
const Point<dim>& p1,
const Point<dim>& p2,
82std::ostream& operator<<(std::ostream& os,
const Point<dim>& m);
84std::istream& operator>>(std::istream& is, Point<dim>& m);
86template<
typename Shape>
104 explicit Point (
const AtlasInType& a);
113 friend std::ostream& operator<< <dim>(std::ostream& os,
const Point& p);
114 friend std::istream&
operator>> <dim>(std::istream& is,
Point& p);
123 bool isEqualTo(
const Point &p,
CoordType epsilon = numeric_constants<CoordType>::epsilon())
const;
124 bool operator== (
const Point& rhs)
const {
return isEqualTo(rhs);}
125 bool operator!= (
const Point& rhs)
const {
return !isEqualTo(rhs);}
127 bool isValid()
const {
return m_valid;}
129 void setValid(
bool valid =
true) {m_valid = valid;}
147 {
return (*
this = p +
Prod(*
this - p, m));}
151 size_t numCorners()
const {
return 1;}
152 Point<dim> getCorner(
size_t)
const {
return *
this;}
153 Point<dim> getCenter()
const {
return *
this;}
155 Point shift(
const Vector<dim>& v) {
return *
this += v;}
157 {
return operator=(p);}
158 Point moveCenterTo(
const Point& p) {
return operator=(p);}
160 Point& rotateCorner(
const RotMatrix<dim>&,
size_t)
162 Point& rotateCenter(
const RotMatrix<dim>&) {
return *
this;}
163 Point& rotatePoint(
const RotMatrix<dim>& m,
const Point& p) {
return rotate(m, p);}
167 Point& rotateCorner(
const Quaternion&,
size_t)
169 Point& rotateCenter(
const Quaternion&) {
return *
this;}
170 Point& rotatePoint(
const Quaternion& q,
const Point& p);
174 AxisBox<dim> boundingBox()
const;
175 Ball<dim> boundingSphere()
const;
176 Ball<dim> boundingSphereSloppy()
const;
179 const RotMatrix<dim>& rotation = RotMatrix<dim>().identity())
const
180 {
return origin + (*
this -
Point().setToOrigin()) * rotation;}
181 Point toParentCoords(
const AxisBox<dim>& coords)
const;
182 Point toParentCoords(
const RotBox<dim>& coords)
const;
189 const RotMatrix<dim>& rotation = RotMatrix<dim>().identity())
const
190 {
return Point().setToOrigin() + rotation * (*
this - origin);}
191 Point toLocalCoords(
const AxisBox<dim>& coords)
const;
192 Point toLocalCoords(
const RotBox<dim>& coords)
const;
258 const CoordType* elements()
const {
return m_elem;}
A dim dimensional point.
Definition point.h:96
Point & rotate(const RotMatrix< dim > &m, const Point &p)
Rotate about point p.
Definition point.h:146
void asPolar(CoordType &r, CoordType &theta, CoordType &z) const
3D only: convert a vector to polar coordinates
CoordType x() const
access the first component of a point
Definition point.h:232
Point(CoordType x, CoordType y)
2D only: construct a point from its (x, y) coordinates
CoordType & y()
access the second component of a point
Definition point.h:238
friend CoordType SquaredDistance(const Point &p1, const Point &p2)
Get the square of the distance from p1 to p2.
Definition point_funcs.h:145
Point & spherical(CoordType r, CoordType theta, CoordType phi)
3D only: construct a vector from spherical coordinates
void asSpherical(CoordType &r, CoordType &theta, CoordType &phi) const
3D only: convert a vector to spherical coordinates
CoordType y() const
access the second component of a point
Definition point.h:236
void setValid(bool valid=true)
make isValid() return true if you've initialized the point by hand
Definition point.h:129
CoordType & operator[](const int i)
Access the i'th coordinate of the point.
Definition point.h:203
friend Point< dim > Midpoint(const Point &p1, const Point &p2, CoordType dist)
Find a point on the line containing p1 and p2, by default the midpoint.
Definition point_funcs.h:240
CoordType & z()
access the third component of a point
static const Point< dim > & ZERO()
Provides a global instance preset to zero.
Definition point_funcs.h:56
Point & setToOrigin()
Set point to (0,0,...,0)
Definition point_funcs.h:64
Point()
Construct an uninitialized point.
Definition point.h:100
void asPolar(CoordType &r, CoordType &theta) const
2D only: convert a vector to polar coordinates
Point & polar(CoordType r, CoordType theta)
2D only: construct a vector from polar coordinates
Point & polar(CoordType r, CoordType theta, CoordType z)
3D only: construct a vector from polar coordinates
CoordType z() const
access the third component of a point
CoordType & x()
access the first component of a point
Definition point.h:234
CoordType operator[](const int i) const
Access the i'th coordinate of the point.
Definition point.h:201
void fromAtlas(const AtlasInType &a)
Set the point's value to that given by an Atlas object.
Definition atlasconv.h:172
AtlasOutType toAtlas() const
Create an Atlas object from the point.
Definition atlasconv.h:179
Point(CoordType x, CoordType y, CoordType z)
3D only: construct a point from its (x, y, z) coordinates
A normalized quaterion.
Definition quaternion.h:36
A dim dimensional rotation matrix. Technically, a member of the group O(dim).
Definition rotmatrix.h:87
A dim dimensional vector.
Definition vector.h:121
CoordType z() const
Access the third component of a vector.
CoordType x() const
Access the first component of a vector.
Definition vector.h:313
CoordType y() const
Access the second component of a vector.
Definition vector.h:317
Utility class for providing zero primitives. This class will only work with simple structures such as...
Definition zero.h:35
Generic library namespace.
Definition atlasconv.h:45
RotMatrix< dim > Prod(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2
Definition rotmatrix_funcs.h:89
Point< dim > Barycenter(const container< Point< dim >, std::allocator< Point< dim > > > &c)
Find the center of a set of points, all weighted equally.
Definition point_funcs.h:207
float CoordType
Basic floating point type.
Definition const.h:140
Point< dim > Midpoint(const Point< dim > &p1, const Point< dim > &p2, CoordType dist=0.5)
Definition point_funcs.h:240