11 #ifndef __RD_POINT_H__ 12 #define __RD_POINT_H__ 19 #define M_PI 3.14159265358979323846 24 #include <boost/smart_ptr.hpp> 33 virtual double operator[](
unsigned int i)
const = 0;
34 virtual double &
operator[](
unsigned int i) = 0;
37 virtual double length()
const = 0;
39 virtual unsigned int dimension()
const = 0;
50 Point3D(
double xv,
double yv,
double zv) : x(xv), y(yv), z(zv){};
55 :
Point(other), x(other.x), y(other.y), z(other.z) {}
127 double l = this->
length();
134 double res = x * x + y * y + z * z;
140 double res = x * x + y * y + z * z;
145 double res = x * (other.
x) + y * (other.
y) + z * (other.
z);
165 else if (dotProd > 1.0)
167 return acos(dotProd);
176 double res = this->angleTo(other);
178 if ((this->x * other.
y - this->y * other.
x) < -1e-6) res = 2.0 *
M_PI - res;
202 res.
x = y * (other.
z) - z * (other.
y);
203 res.
y = -x * (other.
z) + z * (other.
x);
204 res.
z = x * (other.
y) - y * (other.
x);
259 Point2D(
double xv,
double yv) : x(xv), y(yv){};
325 double ln = this->
length();
338 double res = x * x + y * y;
343 double res = x * x + y * y;
348 double res = x * (other.
x) + y * (other.
y);
362 else if (dotProd > 1.0)
364 return acos(dotProd);
368 double res = this->angleTo(other);
369 if ((this->x * other.
y - this->y * other.
x) < -1e-6) res = 2.0 *
M_PI - res;
384 typedef boost::shared_ptr<RDNumeric::Vector<double> >
VECT_SH_PTR;
388 dp_storage.reset(nvec);
394 dp_storage.reset(nvec);
400 template <
typename T>
403 dp_storage.reset(nvec);
405 typename T::const_iterator it;
418 return dp_storage.get()->getVal(i);
421 inline double &
operator[](
unsigned int i) {
return (*dp_storage.get())[i]; }
423 inline void normalize() { dp_storage.get()->normalize(); }
425 inline double length()
const {
return dp_storage.get()->normL2(); }
427 inline double lengthSq()
const {
return dp_storage.get()->normL2Sq(); }
429 unsigned int dimension()
const {
return dp_storage.get()->size(); }
434 dp_storage.reset(nvec);
439 (*dp_storage.get()) += (*other.getStorage());
444 (*dp_storage.get()) -= (*other.getStorage());
449 (*dp_storage.get()) *= scale;
454 (*dp_storage.get()) /= scale;
460 "Point dimensions do not match");
468 return dp_storage.get()->dotProduct(*other.getStorage());
472 double dp = this->dotProduct(other);
473 double n1 = this->
length();
474 double n2 = other.
length();
475 if ((n1 > 1.e-8) && (n2 > 1.e-8)) {
486 VECT_SH_PTR dp_storage;
488 return dp_storage.get();
double & operator[](unsigned int i)
std::vector< RDGeom::Point3D * > Point3DPtrVect
virtual double length() const =0
Point3D & operator/=(double scale)
#define POSTCONDITION(expr, mess)
Point3DPtrVect::iterator Point3DPtrVect_I
Point2D & operator*=(double scale)
INT_POINT2D_MAP::iterator INT_POINT2D_MAP_I
std::vector< RDGeom::Point * > PointPtrVect
RDGeom::Point3D operator+(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2)
std::vector< Point3D >::const_iterator POINT3D_VECT_CI
Point3D(const Point3D &other)
std::ostream & operator<<(std::ostream &target, const RDGeom::Point &pt)
PointPtrVect::const_iterator PointPtrVect_CI
double & operator[](unsigned int i)
Point2D & operator=(const Point2D &other)
double angleTo(const Point2D &other) const
boost::shared_ptr< RDNumeric::Vector< double > > VECT_SH_PTR
virtual double operator[](unsigned int i) const =0
Point2D & operator/=(double scale)
double & operator[](unsigned int i)
PointND directionVector(const PointND &other)
virtual Point * copy() const
Point3DConstPtrVect::const_iterator Point3DConstPtrVect_CI
std::vector< Point3D > POINT3D_VECT
Point2D(const Point2D &other)
Point2DPtrVect::iterator Point2DPtrVect_I
void setVal(unsigned int i, TYPE val)
sets the index at a particular value
PointND & operator-=(const PointND &other)
RDGeom::Point3D operator-(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2)
double computeDihedralAngle(const Point3D &pt1, const Point3D &pt2, const Point3D &pt3, const Point3D &pt4)
std::vector< const RDGeom::Point3D * > Point3DConstPtrVect
PointND & operator*=(double scale)
std::map< int, Point2D > INT_POINT2D_MAP
RDGeom::Point3D operator*(const RDGeom::Point3D &p1, double v)
double angleTo(const PointND &other) const
Point3D(double xv, double yv, double zv)
Point3D operator-() const
double dotProduct(const Point2D &other) const
virtual void normalize()=0
Point3D & operator+=(const Point3D &other)
Point2DPtrVect::const_iterator Point2DPtrVect_CI
double dotProduct(const PointND &other) const
double signedAngleTo(const Point3D &other) const
determines the signed angle between a vector to this point from the origin and a vector to the other ...
PointND & operator=(const PointND &other)
unsigned int dimension() const
Point3DPtrVect::const_iterator Point3DPtrVect_CI
virtual Point * copy() const
virtual double lengthSq() const =0
PointND & operator+=(const PointND &other)
Point3D & operator*=(double scale)
virtual Point * copy() const =0
double computeSignedDihedralAngle(const Point3D &pt1, const Point3D &pt2, const Point3D &pt3, const Point3D &pt4)
Point2D(double xv, double yv)
Point2D & operator-=(const Point2D &other)
double operator[](unsigned int i) const
virtual Point * copy() const
Point3D & operator-=(const Point3D &other)
unsigned int dimension() const
Point2D & operator+=(const Point2D &other)
Point2D directionVector(const Point2D &other) const
double operator[](unsigned int i) const
Point2D operator-() const
PointND(unsigned int dim)
Point3D getPerpendicular() const
Get a unit perpendicular from this point (treating it as a vector):
#define PRECONDITION(expr, mess)
PointND & operator/=(double scale)
RDGeom::Point3D operator/(const RDGeom::Point3D &p1, double v)
virtual unsigned int dimension() const =0
Point3D & operator=(const Point3D &other)
INT_POINT2D_MAP::const_iterator INT_POINT2D_MAP_CI
Point3D crossProduct(const Point3D &other) const
Cross product of this point with the another point.
std::vector< RDGeom::Point2D * > Point2DPtrVect
A class to represent vectors of numbers.
unsigned int dimension() const
double operator[](unsigned int i) const
double signedAngleTo(const Point2D &other) const
Point3DConstPtrVect::iterator Point3DConstPtrVect_I
double dotProduct(const Point3D &other) const
std::vector< Point3D >::iterator POINT3D_VECT_I
double angleTo(const Point3D &other) const
determines the angle between a vector to this point from the origin and a vector to the other point...
PointND(const PointND &other)
Point3D directionVector(const Point3D &other) const
Returns a normalized direction vector from this point to another.
PointPtrVect::iterator PointPtrVect_I