12 #ifndef __RD_POINT_H__ 13 #define __RD_POINT_H__ 20 #define M_PI 3.14159265358979323846 25 #include <boost/smart_ptr.hpp> 34 virtual double operator[](
unsigned int i)
const = 0;
35 virtual double &operator[](
unsigned int i) = 0;
38 virtual double length()
const = 0;
39 virtual double lengthSq()
const = 0;
40 virtual unsigned int dimension()
const = 0;
42 virtual Point *copy()
const = 0;
51 Point3D(
double xv,
double yv,
double zv) : x(xv), y(yv), z(zv){};
56 :
Point(other), x(other.x), y(other.y), z(other.z) {}
128 double l = this->length();
135 double res = x * x + y * y + z * z;
141 double res = x * x + y * y + z * z;
146 double res = x * (other.
x) + y * (other.
y) + z * (other.
z);
166 else if (dotProd > 1.0)
168 return acos(dotProd);
177 double res = this->angleTo(other);
179 if ((this->x * other.
y - this->y * other.
x) < -1e-6) res = 2.0 *
M_PI - res;
203 res.
x = y * (other.
z) - z * (other.
y);
204 res.
y = -x * (other.
z) + z * (other.
x);
205 res.
z = x * (other.
y) - y * (other.
x);
260 Point2D(
double xv,
double yv) : x(xv), y(yv){};
326 double ln = this->length();
339 double res = x * x + y * y;
344 double res = x * x + y * y;
349 double res = x * (other.
x) + y * (other.
y);
363 else if (dotProd > 1.0)
365 return acos(dotProd);
369 double res = this->angleTo(other);
370 if ((this->x * other.
y - this->y * other.
x) < -1e-6) res = 2.0 *
M_PI - res;
385 typedef boost::shared_ptr<RDNumeric::Vector<double> >
VECT_SH_PTR;
389 dp_storage.reset(nvec);
395 dp_storage.reset(nvec);
401 template <
typename T>
404 dp_storage.reset(nvec);
406 typename T::const_iterator it;
419 return dp_storage.get()->getVal(i);
422 inline double &
operator[](
unsigned int i) {
return (*dp_storage.get())[i]; }
424 inline void normalize() { dp_storage.get()->normalize(); }
426 inline double length()
const {
return dp_storage.get()->normL2(); }
428 inline double lengthSq()
const {
return dp_storage.get()->normL2Sq(); }
430 unsigned int dimension()
const {
return dp_storage.get()->size(); }
435 dp_storage.reset(nvec);
440 (*dp_storage.get()) += (*other.getStorage());
445 (*dp_storage.get()) -= (*other.getStorage());
450 (*dp_storage.get()) *= scale;
455 (*dp_storage.get()) /= scale;
461 "Point dimensions do not match");
469 return dp_storage.get()->dotProduct(*other.getStorage());
473 double dp = this->dotProduct(other);
474 double n1 = this->length();
475 double n2 = other.
length();
476 if ((n1 > 1.e-8) && (n2 > 1.e-8)) {
487 VECT_SH_PTR dp_storage;
489 return dp_storage.get();
double & operator[](unsigned int i)
std::vector< RDGeom::Point3D * > Point3DPtrVect
Point3D & operator/=(double scale)
#define RDKIT_RDGEOMETRYLIB_EXPORT
#define POSTCONDITION(expr, mess)
Point3DPtrVect::iterator Point3DPtrVect_I
Point2D & operator*=(double scale)
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator-(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2)
INT_POINT2D_MAP::iterator INT_POINT2D_MAP_I
std::vector< RDGeom::Point * > PointPtrVect
std::vector< Point3D >::const_iterator POINT3D_VECT_CI
Point3D(const Point3D &other)
PointPtrVect::const_iterator PointPtrVect_CI
RDKIT_RDGEOMETRYLIB_EXPORT double computeSignedDihedralAngle(const Point3D &pt1, const Point3D &pt2, const Point3D &pt3, const Point3D &pt4)
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
Point2D & operator/=(double scale)
double & operator[](unsigned int i)
PointND directionVector(const PointND &other)
virtual Point * copy() const
RDKIT_MOLSTANDARDIZE_EXPORT RWMol * normalize(const RWMol *mol, const CleanupParameters ¶ms=defaultCleanupParameters)
Works the same as Normalizer().normalize(mol)
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)
std::vector< const RDGeom::Point3D * > Point3DConstPtrVect
RDKIT_RDGEOMETRYLIB_EXPORT std::ostream & operator<<(std::ostream &target, const RDGeom::Point &pt)
PointND & operator*=(double scale)
std::map< int, Point2D > INT_POINT2D_MAP
double angleTo(const PointND &other) const
Point3D(double xv, double yv, double zv)
Point3D operator-() const
double dotProduct(const Point2D &other) const
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
PointND & operator+=(const PointND &other)
Point3D & operator*=(double scale)
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator/(const RDGeom::Point3D &p1, double v)
Point2D(double xv, double yv)
Point2D & operator-=(const Point2D &other)
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator*(const RDGeom::Point3D &p1, double v)
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)
Point3D & operator=(const Point3D &other)
INT_POINT2D_MAP::const_iterator INT_POINT2D_MAP_CI
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator+(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2)
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
RDKIT_RDGEOMETRYLIB_EXPORT double computeDihedralAngle(const Point3D &pt1, const Point3D &pt2, const Point3D &pt3, const Point3D &pt4)