RDKit: Utils.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

Utils.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef __RD_DIST_UTILS_H__
11 #define __RD_DIST_UTILS_H__
12
13 #include <math.h>
14 #include "point.h"
15 #include "Transform3D.h"
16 #include "Transform.h"
17
18 namespace RDGeom {
19
20 /*! \brief Compute the 13 distance between points give the 12 distances
21 * and the angle between the axes.
22 */
23 inline double compute13Dist(double d1, double d2, double angle) {
24 double res = d1 * d1 + d2 * d2 - 2 * d1 * d2 * cos(angle);
25 return sqrt(res);
26 }
27
28 /*! \brief Compute the 14 distances give the 12 distance and the angles
29 *
30 * This is computed by aligning the d2 axis with the x-axis (with atom 2 at
31 * the origin. Atom 1 is made to lie int he xy-plane with a +ve y-coordinate
32 * and finally the coordinates for atom 4 are computed.
33 *
34 * ARGUMENTS:
35 * d1 - distance between atoms 1 and 2
36 * d2 - distance between atoms 2 and 3
37 * d3 - distance between atoms 3 and 4
38 * ang12 - angle between the axes d1 and d2
39 * ang23 - angle between the axes d2 and d3
40 * torAng - torsional agnle of the axis d2
41 *
42 * NOTE:
43 * we are specifically calling this function compute14Dist3D because
44 * we assume the torsional angle can take any value including 0 and 180 deg.
45 * However, if using either 0 or 180 as the torsional angle (which is often
46 * the case) the user is recommended to use the specialized functions below
47 * instead of this function; they will be speedier.
48 */
49 inline double compute14Dist3D(double d1, double d2, double d3, double ang12,
50 double ang23, double torAng) {
51 // location of atom1
52 Point3D p1(d1 * cos(ang12), d1 * sin(ang12), 0.0);
53
54 // location of atom 4 if the rosion angle was 0
55 Point3D p4(d2 - d3 * cos(ang23), d3 * sin(ang23), 0.0);
56
57 // now we will rotate p4 about the x-axis by the desired torsion angle
58 Transform3D trans;
59 trans.SetRotation(torAng, X_Axis);
60 trans.TransformPoint(p4);
61
62 // find the distance
63 p4 -= p1;
64 return p4.length();
65 }
66
67 /*! \brief Compute the 14 distances give the 12 distance and bond angle
68 * for cis configuration
69 *
70 * This is simply a special case of the above function compute14Dist3D;
71 * with torsion angle set to 0. However, this function should be speedier
72 */
73 inline double compute14DistCis(double d1, double d2, double d3, double ang12,
74 double ang23) {
75 double dx = d2 - d3 * cos(ang23) - d1 * cos(ang12);
76 double dy = d3 * sin(ang23) - d1 * sin(ang12);
77 double res = dx * dx + dy * dy;
78 return sqrt(res);
79 }
80
81 /*! \brief Compute the 14 distances give the 12 distance and bond angle
82 * for trans configuration
83 *
84 * This is simply a special case of the above function compute14Dist3D;
85 * with torsion angle set to 180. However, this function should be speedier
86 */
87 inline double compute14DistTrans(double d1, double d2, double d3, double ang12,
88 double ang23) {
89 double dx = d2 - d3 * cos(ang23) - d1 * cos(ang12);
90 double dy = d3 * sin(ang23) + d1 * sin(ang12);
91 double res = dx * dx + dy * dy;
92 return sqrt(res);
93 }
94 }
95
96 #endif
RDGeom::compute14DistTrans
double compute14DistTrans(double d1, double d2, double d3, double ang12, double ang23)
Compute the 14 distances give the 12 distance and bond angle for trans configuration.
Definition: Utils.h:87
point.h
RDGeom::Transform3D::TransformPoint
void TransformPoint(Point3D &pt) const
Transform.h
RDGeom::Transform3D::SetRotation
void SetRotation(double angle, AxisType axis)
set the rotation matrix
RDGeom::compute14Dist3D
double compute14Dist3D(double d1, double d2, double d3, double ang12, double ang23, double torAng)
Compute the 14 distances give the 12 distance and the angles.
Definition: Utils.h:49
RDGeom::X_Axis
Definition: Transform.h:15
RDGeom::compute13Dist
double compute13Dist(double d1, double d2, double angle)
Compute the 13 distance between points give the 12 distances and the angle between the axes...
Definition: Utils.h:23
Transform3D.h
RDGeom::Point3D
Definition: point.h:45
RDGeom::Transform3D
Definition: Transform3D.h:21
RDGeom::Point3D::length
double length() const
Definition: point.h:133
RDGeom
Definition: TorsionAngleM6.h:19
RDGeom::compute14DistCis
double compute14DistCis(double d1, double d2, double d3, double ang12, double ang23)
Compute the 14 distances give the 12 distance and bond angle for cis configuration.
Definition: Utils.h:73