GLYLIB
0.3.0b
|
00001 /* \file geometries.h 00002 \brief Purpose: structures related to geometries of molecules, 00003 residues, atoms, etc. Loaded when molecules.h is included. 00004 00005 begun by BLFoley on 20080606 00006 This file is loaded with the molecules.h header file by default. 00007 It should only be loaded explicitly in a program if, for some reason, 00008 you are using it separately. */ 00009 #if !defined(GLYLIB_GEOMETRIES) 00010 #define GLYLIB_GEOMETRIES 00011 00012 /** \addtogroup GEOMETRY 00013 * @{ 00014 */ 00015 #if !defined(PI) 00016 #define PI 3.1415926535897932384626433832795028 00017 #endif 00018 00019 #define get_vector_from_coords(a,b) coord_to_vec(subtract_coord(b,a)) 00020 00021 /**************************************************************//** 00022 Coordinates 00023 ******************************************************************/ 00024 // Fixed Dimension 00025 typedef struct { 00026 double i,j,k; ///< Values assigned to the three coordinates. 00027 } coord_3D; ///< Any 3D coordinate: cartesian, polar, direction cosines, etc. 00028 typedef struct { 00029 double i,j,k,d; ///< i,j,k vector with magnitude d 00030 } vectormag_3D; ///< Vector manipulations often require magnitudes, so this struct contains that information. 00031 00032 // Multi-Dimensional 00033 typedef struct { 00034 int nD; ///< Number of dimensions. 00035 double *D;///< Values in each of the nD dimensions 00036 } coord_nD; ///< An n-dimensional coordinate 00037 typedef struct { 00038 int nDi; ///< Number of dimensions. 00039 int *Di;///< Indicies for values in each of the nD dimensions 00040 } nD_index; ///< Set of indices to n-dimensional coordinate 00041 typedef struct { 00042 int nDp; ///< Number of dimensions. 00043 double **Dp;///< Pointers to values in each of the nD dimensions 00044 } nD_ptrs; ///< Set of pointers to n-dimensional coordinate 00045 typedef struct { 00046 int nD; ///< Number of dimensions. 00047 double *D;///< Values in each of the nD dimensions 00048 int *Di;///< Indicies for values in each of the nD dimensions 00049 } coord_nDi; ///< An n-dimensional coordinate 00050 00051 00052 00053 /**************************************************************//** 00054 Geometrical Objects 00055 ******************************************************************/ 00056 typedef struct { 00057 double A,B,C,D; 00058 } plane; ///< Standard cartesian plane with equation Ax+By+Cz+D=0 00059 00060 /**************************************************************//** 00061 Special Objects 00062 ******************************************************************/ 00063 typedef struct { 00064 char *STYPE,*GTYPE; ///< Types relevant to simulations (e.g., periodic) and to basic geometry (e.g., cubic) 00065 int nC; ///< Number of coordinates defined 00066 coord_nD *C; ///< nC coordinates (the dimensions are defined inside the structures, and might all be different) 00067 int nCD; ///< Number of descriptions defined 00068 char **CD; ///< nCD descriptions of the coordinate relevances (e.g, "lower corner" or "A in z=f(A)"). 00069 } boxinfo; ///< structure for holding (periodic or not) box information 00070 00071 00072 /**************************************************************//** 00073 Functions 00074 ******************************************************************/ 00075 //void rotate_vector_to_Y_list(coord_3D*,int,vectormag_3D); // int is n 00076 //void rotate_vector_to_X_list(coord_3D*,int,vectormag_3D); // int is n 00077 //void rotate_vector_to_V_list(coord_3D*,int,vectormag_3D,vectormag_3D); // int is n 00078 void rotate_vector_to_Z_list(coord_3D*,int,vectormag_3D); // int is n 00079 coord_3D get_geometric_center(coord_3D *c,int nc); // int is n 00080 coord_3D get_geometric_center_dp(coord_3D **c,int nc); // int is n 00081 plane get_plane(coord_3D,coord_3D,coord_3D); 00082 plane get_plane_for_ring(int n,coord_3D **r); // gets the C-P average plane, atoms must be in order 00083 double get_signed_distance_from_point_to_plane(plane p, coord_3D pt); 00084 vectormag_3D normalize_vec(vectormag_3D); 00085 vectormag_3D scalarmult_vec(vectormag_3D,double); 00086 vectormag_3D add_vec(vectormag_3D,vectormag_3D); // add two vectors 00087 vectormag_3D subtract_vec(vectormag_3D,vectormag_3D); // subtract second vector from first 00088 coord_3D scalarmult_coord(coord_3D,double); // add two vectors 00089 coord_3D add_coord(coord_3D,coord_3D); // add two vectors 00090 coord_3D subtract_coord(coord_3D,coord_3D); // subtract second vector from first 00091 vectormag_3D get_crossprod(vectormag_3D, vectormag_3D); // returns the cross product 00092 double get_dotprod(vectormag_3D, vectormag_3D); // returns dot product of two vectors 00093 /* the following essentially returns the cosine of the angle between two vectors */ 00094 //double get_dotprodN(vectormag_3D, vectormag_3D); // returns dot prod, but normalizes vecs first 00095 double get_magnitude(vectormag_3D); // calculates vector magnitude for "d" in structure 00096 vectormag_3D zero_vec(); // zeros a vector 00097 coord_3D zero_coord(); // zeros a coordinate set 00098 coord_3D vec_to_coord(vectormag_3D); // turns a vector into a coordinate set 00099 vectormag_3D coord_to_vec(coord_3D); // turns a coordinate set into a vector 00100 void initialize_coord_3D(coord_3D *c); 00101 void initialize_vectormag_3D(vectormag_3D *v); 00102 void initialize_plane(plane *p); 00103 00104 /** Get angle between two vectors 00105 */ 00106 double get_angle_between_vectors(vectormag_3D a, vectormag_3D b); 00107 00108 /** Get angle abc 00109 */ 00110 double get_angle_ABC_points(coord_3D a, coord_3D b, coord_3D c); 00111 00112 /** Get the dihedral angle between planes abc and bcd 00113 */ 00114 double get_dihedral_ABCD_points(coord_3D a, coord_3D b, coord_3D c, coord_3D d); 00115 00116 /** Euclidean distance from x to y 00117 */ 00118 double get_distance_AB_points(coord_3D a, coord_3D b); 00119 00120 /** Translate a list of coordinates 00121 */ 00122 void translate_coords_dp_list(coord_3D **coords, int num_coords, coord_3D shift); 00123 00124 /** Create a rotation matrix for a rotation of theta degrees 00125 * about an axis through the given point in the given direction 00126 */ 00127 double *create_rotation_matrix(coord_3D point, vectormag_3D direction, 00128 double theta); 00129 /** Deallocate the rotation matrix 00130 */ 00131 void destroy_rotation_matrix(double *matrix); 00132 00133 /** Apply the rotation matrix to the given coordinate 00134 */ 00135 void apply_rotation_matrix_to_coord_p(coord_3D *c, double *matrix); 00136 00137 /** Rotate a list of coordinates theta degrees about an axis through 00138 * the given coordinate in the given direction 00139 */ 00140 void rotate_coords_about_axis_dp_list(coord_3D **coords, int num_coords, coord_3D point, 00141 vectormag_3D direction, double theta); 00142 00143 /** Calculate coordinate d, where 00144 * (1) d is distance units from c 00145 * (2) angle bcd is theta 00146 * (3) dihedral between planes abc and bcd is phi 00147 * 00148 * Link to derivation: 00149 * 00150 * Note: should probably change the name of this 00151 */ 00152 coord_3D get_cartesian_point_from_internal_coords(coord_3D a, coord_3D b, coord_3D c, 00153 double theta, double phi, double distance); 00154 00155 /** Note: change name/parameter names 00156 */ 00157 void orient_coords2_to_coords1_dp_list(coord_3D **coords, int num_coords, 00158 const coord_3D *bond_atom_a, coord_3D *bond_atom_b, double distance, 00159 const coord_3D *angle_atom_a, double theta, 00160 coord_3D *angle_atom_b, double rho, 00161 const coord_3D *dih_atom_a, coord_3D *dih_atom_b, double tau, 00162 const coord_3D *tor_atom_a, const coord_3D *ref_angle_a, double phi, 00163 coord_3D *tor_atom_b, coord_3D *ref_atom_b, double omega); 00164 /** @}*/ 00165 00166 #endif