12 #ifndef __RD_POINT_H__ 13 #define __RD_POINT_H__ 20 #define M_PI 3.14159265358979323846 26 #include <boost/smart_ptr.hpp> 36 virtual double operator[](
unsigned int i)
const = 0;
37 virtual double&
operator[](
unsigned int i) = 0;
40 virtual double length()
const = 0;
42 virtual unsigned int dimension()
const = 0;
56 Point3D(
double xv,
double yv,
double zv): x(xv),y(yv),z(zv) {};
61 Point(other), x(other.x), y(other.y), z(other.z) {
95 x = other.
x;y=other.
y;z=other.
z;
136 double l = this->
length();
143 double res = x*x+y*y+z*z;
149 double res = x*x+y*y+z*z;
154 double res = x*(other.
x) + y*(other.
y) + z*(other.
z);
172 if(dotProd<-1.0) dotProd = -1.0;
173 else if(dotProd>1.0) dotProd = 1.0;
174 return acos(dotProd);
183 double res=this->angleTo(other);
185 if((this->x*other.
y-this->y*other.
x)<-1e-6) res = 2.0*
M_PI-res;
211 res.
x = y*(other.
z) - z*(other.
y);
212 res.
y = -x*(other.
z) + z*(other.
x);
213 res.
z = x*(other.
y) - y*(other.
x);
303 x = other.
x;y=other.
y;
339 double ln = this->
length();
352 double res = x*x+y*y;
357 double res = x*x+y*y;
362 double res = x*(other.
x) + y*(other.
y);
374 if(dotProd<-1.0) dotProd = -1.0;
375 else if(dotProd>1.0) dotProd = 1.0;
376 return acos(dotProd);
380 double res=this->angleTo(other);
381 if((this->x*other.
y-this->y*other.
x)<-1e-6) res = 2.0*
M_PI-res;
399 typedef boost::shared_ptr<RDNumeric::Vector<double> >
VECT_SH_PTR;
403 dp_storage.reset(nvec);
408 dp_storage.reset(nvec);
416 template <
typename T>
419 dp_storage.reset(nvec);
421 typename T::const_iterator it;
434 return dp_storage.get()->getVal(i);
438 return (*dp_storage.get())[i];
442 dp_storage.get()->normalize();
446 return dp_storage.get()->normL2();
450 return dp_storage.get()->normL2Sq();
454 return dp_storage.get()->size();
459 dp_storage.reset(nvec);
464 (*dp_storage.get()) += (*other.getStorage());
469 (*dp_storage.get()) -= (*other.getStorage());
474 (*dp_storage.get()) *= scale;
479 (*dp_storage.get()) /= scale;
492 return dp_storage.get()->dotProduct(*other.getStorage());
496 double dp = this->dotProduct(other);
497 double n1 = this->
length();
498 double n2 = other.
length();
499 if ((n1 > 1.e-8) && (n2 > 1.e-8)) {
502 if (dp < -1.0) dp = -1.0;
503 else if (dp > 1.0) dp = 1.0;
508 VECT_SH_PTR dp_storage;
510 return dp_storage.get();
double & operator[](unsigned int i)
std::vector< RDGeom::Point3D * > Point3DPtrVect
unsigned int dimension() const
virtual double length() const =0
Point3D crossProduct(const Point3D &other) const
Cross product of this point with the another point.
Point3D & operator/=(double scale)
#define POSTCONDITION(expr, mess)
Point3DPtrVect::iterator Point3DPtrVect_I
Point2D & operator*=(double scale)
unsigned int dimension() const
INT_POINT2D_MAP::iterator INT_POINT2D_MAP_I
std::vector< RDGeom::Point * > PointPtrVect
RDGeom::Point3D operator+(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2)
Point2D directionVector(const Point2D &other) const
std::vector< Point3D >::const_iterator POINT3D_VECT_CI
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...
Point3D(const Point3D &other)
Point3D getPerpendicular() const
Get a unit perpendicular from this point (treating it as a vector):
std::ostream & operator<<(std::ostream &target, const RDGeom::Point &pt)
PointPtrVect::const_iterator PointPtrVect_CI
unsigned int dimension() const
double dotProduct(const Point3D &other) const
double & operator[](unsigned int i)
Point2D & operator=(const Point2D &other)
double signedAngleTo(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)
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
virtual Point * copy() const
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)
Point3D(double xv, double yv, double zv)
virtual void normalize()=0
Point3D & operator+=(const Point3D &other)
virtual Point * copy() const
double dotProduct(const Point2D &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 ...
double angleTo(const PointND &other) const
Point2DPtrVect::const_iterator Point2DPtrVect_CI
PointND & operator=(const PointND &other)
double dotProduct(const PointND &other) const
Point3DPtrVect::const_iterator Point3DPtrVect_CI
double operator[](unsigned int i) const
virtual double lengthSq() const =0
PointND & operator+=(const PointND &other)
Point3D & operator*=(double scale)
virtual Point * copy() const =0
Point3D directionVector(const Point3D &other) const
Returns a normalized direction vector from this point to another.
double computeSignedDihedralAngle(const Point3D &pt1, const Point3D &pt2, const Point3D &pt3, const Point3D &pt4)
Point2D(double xv, double yv)
double angleTo(const Point2D &other) const
Point2D & operator-=(const Point2D &other)
Point3D & operator-=(const Point3D &other)
Point2D & operator+=(const Point2D &other)
PointND(unsigned int dim)
#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 operator-() const
double operator[](unsigned int i) const
virtual Point * copy() const
std::vector< RDGeom::Point2D * > Point2DPtrVect
A class to represent vectors of numbers.
double operator[](unsigned int i) const
Point3DConstPtrVect::iterator Point3DConstPtrVect_I
std::vector< Point3D >::iterator POINT3D_VECT_I
PointND(const PointND &other)
Point2D operator-() const
PointPtrVect::iterator PointPtrVect_I