Utils.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2004-2006 Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved  @@
00005 //
00006 #ifndef __RD_DIST_UTILS_H__
00007 #define __RD_DIST_UTILS_H__
00008 
00009 #include <math.h>
00010 #include "point.h"
00011 #include "Transform3D.h"
00012 #include "Transform.h"
00013 
00014 namespace RDGeom {
00015 
00016   /*! \brief Compute the 13 distance between points give the 12 distances
00017    *  and the angle between the axes.
00018    */
00019   inline double compute13Dist(double d1, double d2, double angle) {
00020     double res = d1*d1 + d2*d2 - 2*d1*d2*cos(angle);
00021     return sqrt(res);
00022   }
00023 
00024   /*! \brief Compute the 14 distances give the 12 distance and the angles
00025    *
00026    *   This is computed by aligning the d2 axis with the x-axis (with atom 2 at 
00027    *   the origin. Atom 1 is made to lie int he xy-plane with a +ve y-coordinate
00028    *   and finally the coordinates for atom 4 are computed. 
00029    *
00030    * ARGUMENTS:
00031    *   d1 - distance between atoms 1 and 2
00032    *   d2 - distance between atoms 2 and 3
00033    *   d3 - distance between atoms 3 and 4
00034    *   ang12 - angle between the axes d1 and d2
00035    *   ang23 - angle between the axes d2 and d3
00036    *   torAng - torsional agnle of the axis d2
00037    *
00038    * NOTE:
00039    *   we are specifically calling this function compute14Dist3D because
00040    *   we assume the torsional angle can take any value including 0 and 180 deg.
00041    *   However, if using either 0 or 180 as the torsional angle (which is often 
00042    *   the case) the user is recommended to use the specialized functions below
00043    *   instead of this function; they will be speedier.
00044    */
00045   inline double compute14Dist3D(double d1, double d2, double d3, 
00046                                 double ang12, double ang23, double torAng) {
00047     // location of atom1
00048     Point3D p1(d1*cos(ang12), d1*sin(ang12), 0.0);
00049 
00050     // location of atom 4 if the rosion angle was 0
00051     Point3D p4(d2-d3*cos(ang23), d3*sin(ang23), 0.0);
00052     
00053     // now we will rotate p4 about the x-axis by the desired torsion angle
00054     Transform3D trans;
00055     trans.SetRotation(torAng, X_Axis);
00056     trans.TransformPoint(p4);
00057 
00058     // find the distance
00059     p4 -= p1;
00060     return p4.length();
00061   }
00062 
00063   /*! \brief Compute the 14 distances give the 12 distance and bond angle
00064    *  for cis configuration
00065    *
00066    *  This is simply a special case of the above function compute14Dist3D;
00067    *  with torsion angle set to 0. However, this function should be speedier
00068    */
00069   inline double compute14DistCis(double d1, double d2, double d3, 
00070                                 double ang12, double ang23) {
00071     double dx = d2 - d3*cos(ang23) - d1*cos(ang12);
00072     double dy = d3*sin(ang23) - d1*sin(ang12);
00073     double res = dx*dx + dy*dy;
00074     return sqrt(res);
00075   }
00076 
00077   
00078    /*! \brief Compute the 14 distances give the 12 distance and bond angle
00079    *  for trans configuration
00080    *
00081    *  This is simply a special case of the above function compute14Dist3D;
00082    *  with torsion angle set to 180. However, this function should be speedier
00083    */
00084   inline double compute14DistTrans(double d1, double d2, double d3, 
00085                                 double ang12, double ang23) {
00086     double dx = d2 - d3*cos(ang23) - d1*cos(ang12);
00087     double dy = d3*sin(ang23) + d1*sin(ang12);
00088     double res = dx*dx + dy*dy;
00089     return sqrt(res);
00090   } 
00091 }
00092 
00093 #endif

Generated on Tue Oct 7 06:10:11 2008 for RDCode by  doxygen 1.5.5