 |
RDKit
Open-source cheminformatics and machine learning.
|
Go to the documentation of this file.
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);
255 const Point3D &pt1,
const Point3D &pt2,
const Point3D &pt3,
263 Point2D(
double xv,
double yv) : x(xv), y(yv){};
330 double ln = this->length();
343 double res = x * x + y * y;
348 double res = x * x + y * y;
353 double res = x * (other.
x) + y * (other.
y);
367 else if (dotProd > 1.0)
369 return acos(dotProd);
373 double res = this->angleTo(other);
374 if ((this->x * other.
y - this->y * other.
x) < -1e-6) res = 2.0 *
M_PI - res;
393 dp_storage.reset(nvec);
399 dp_storage.reset(nvec);
405 template <
typename T>
408 dp_storage.reset(nvec);
410 typename T::const_iterator it;
423 return dp_storage.get()->getVal(i);
426 inline double &
operator[](
unsigned int i) {
return (*dp_storage.get())[i]; }
428 inline void normalize() { dp_storage.get()->normalize(); }
430 inline double length()
const {
return dp_storage.get()->normL2(); }
432 inline double lengthSq()
const {
return dp_storage.get()->normL2Sq(); }
434 unsigned int dimension()
const {
return dp_storage.get()->size(); }
437 if (
this == &other)
return *
this;
441 dp_storage.reset(nvec);
446 (*dp_storage.get()) += (*other.getStorage());
451 (*dp_storage.get()) -= (*other.getStorage());
456 (*dp_storage.get()) *= scale;
461 (*dp_storage.get()) /= scale;
467 "Point dimensions do not match");
475 return dp_storage.get()->dotProduct(*other.getStorage());
479 double dp = this->dotProduct(other);
480 double n1 = this->length();
481 double n2 = other.
length();
482 if ((n1 > 1.e-8) && (n2 > 1.e-8)) {
493 VECT_SH_PTR dp_storage;
495 return dp_storage.get();
Point2D & operator*=(double scale)
RDKIT_RDGEOMETRYLIB_EXPORT double computeDihedralAngle(const Point3D &pt1, const Point3D &pt2, const Point3D &pt3, const Point3D &pt4)
#define POSTCONDITION(expr, mess)
double & operator[](unsigned int i)
std::vector< RDGeom::Point3D * > Point3DPtrVect
std::vector< const RDGeom::Point3D * > Point3DConstPtrVect
unsigned int dimension() const
boost::shared_ptr< RDNumeric::Vector< double > > VECT_SH_PTR
INT_POINT2D_MAP::iterator INT_POINT2D_MAP_I
Point2D & operator=(const Point2D &other)
Point3DConstPtrVect::const_iterator Point3DConstPtrVect_CI
Point3D & operator/=(double scale)
Point3D(const Point3D &other)
PointPtrVect::const_iterator PointPtrVect_CI
Point2D & operator/=(double scale)
PointND directionVector(const PointND &other)
virtual Point * copy() const
Point2DPtrVect::iterator Point2DPtrVect_I
Point2DPtrVect::const_iterator Point2DPtrVect_CI
std::vector< Point3D >::const_iterator POINT3D_VECT_CI
double angleTo(const Point2D &other) const
PointND & operator*=(double scale)
Point2D(const Point2D &other)
RDKIT_RDGEOMETRYLIB_EXPORT double computeSignedDihedralAngle(const Point3D &pt1, const Point3D &pt2, const Point3D &pt3, const Point3D &pt4)
RDKIT_RDGEOMETRYLIB_EXPORT std::ostream & operator<<(std::ostream &target, const RDGeom::Point &pt)
Point2D(const Point3D &p3d)
construct from a Point3D (ignoring the z coordinate)
double angleTo(const PointND &other) const
#define RDKIT_RDGEOMETRYLIB_EXPORT
A class to represent vectors of numbers.
double dotProduct(const Point2D &other) const
double & operator[](unsigned int i)
virtual Point * copy() const
Point3D & operator*=(double scale)
std::vector< Point3D > POINT3D_VECT
Point2D & operator-=(const Point2D &other)
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 ...
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator/(const RDGeom::Point3D &p1, double v)
PointND & operator=(const PointND &other)
unsigned int dimension() const
Point3D operator-() const
std::vector< RDGeom::Point2D * > Point2DPtrVect
Point3D & operator+=(const Point3D &other)
PointND & operator-=(const PointND &other)
Point3DPtrVect::const_iterator Point3DPtrVect_CI
Point2D & operator+=(const Point2D &other)
double operator[](unsigned int i) const
Point2D operator-() const
std::map< int, Point2D > INT_POINT2D_MAP
double dotProduct(const PointND &other) const
PointND(unsigned int dim)
void setVal(unsigned int i, TYPE val)
sets the index at a particular value
Point3D(double xv, double yv, double zv)
PointND & operator/=(double scale)
RDKIT_MOLSTANDARDIZE_EXPORT RWMol * normalize(const RWMol *mol, const CleanupParameters ¶ms=defaultCleanupParameters)
Works the same as Normalizer().normalize(mol)
Point2D directionVector(const Point2D &other) const
Point3D & operator=(const Point3D &other)
Point3D crossProduct(const Point3D &other) const
Cross product of this point with the another point.
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator-(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2)
PointND & operator+=(const PointND &other)
Point3D & operator-=(const Point3D &other)
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator*(const RDGeom::Point3D &p1, double v)
unsigned int dimension() const
double operator[](unsigned int i) const
Point2D(double xv, double yv)
Point3DPtrVect::iterator Point3DPtrVect_I
#define PRECONDITION(expr, mess)
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Point3D operator+(const RDGeom::Point3D &p1, const RDGeom::Point3D &p2)
std::vector< Point3D >::iterator POINT3D_VECT_I
double operator[](unsigned int i) const
virtual Point * copy() const
double & operator[](unsigned int i)
INT_POINT2D_MAP::const_iterator INT_POINT2D_MAP_CI
double dotProduct(const Point3D &other) const
PointND(const PointND &other)
Point3D directionVector(const Point3D &other) const
Returns a normalized direction vector from this point to another.
Point3D getPerpendicular() const
Get a unit perpendicular from this point (treating it as a vector):
PointPtrVect::iterator PointPtrVect_I
Point3DConstPtrVect::iterator Point3DConstPtrVect_I
double signedAngleTo(const Point2D &other) const
std::vector< RDGeom::Point * > PointPtrVect
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.