GLYLIB
0.3.0b
|
00001 #include <mylib.h> 00002 #include <molecules.h> 00003 #include <geometries.h> 00004 00005 /** Euclidean distance from x to y 00006 */ 00007 double 00008 get_distance_AB_points(coord_3D a, coord_3D b) 00009 { return sqrt(pow(b.i-a.i,2) + pow(b.j-a.j,2) + pow(b.k-a.k,2)); } 00010 00011 00012 double get_angle_between_vectors(vectormag_3D a, vectormag_3D b) 00013 { 00014 return acos(get_dotprod(normalize_vec(a),normalize_vec(b))); 00015 00016 } 00017 double get_angle_ABC_points(coord_3D a, coord_3D b, coord_3D c) 00018 { 00019 vectormag_3D ab = coord_to_vec(subtract_coord(a,b)); 00020 vectormag_3D cb = coord_to_vec(subtract_coord(c,b)); 00021 return get_angle_between_vectors(ab,cb); 00022 } 00023 00024 /** This assumes that the bonding goes as: A-B-C-D or that the input vectors 00025 follow an equivalent direction convention. When A and D are eclipsed, 00026 the angle is zero. */ 00027 double get_dihedral_ABCD_points(coord_3D a, coord_3D b, coord_3D c, coord_3D d) 00028 { 00029 vectormag_3D b1 = coord_to_vec(subtract_coord(b, a)); 00030 vectormag_3D b2 = coord_to_vec(subtract_coord(c, b)); 00031 vectormag_3D b3 = coord_to_vec(subtract_coord(d, c)); 00032 00033 return atan2( get_dotprod(scalarmult_vec(b1, b2.d), get_crossprod(b2,b3)), 00034 get_dotprod(get_crossprod(b1,b2), get_crossprod(b2,b3)) ) ; 00035 } 00036 00037 00038 void 00039 translate_coords_dp_list(coord_3D **coords, int num_coords, coord_3D shift) 00040 { 00041 int i; 00042 00043 for(i=0; i!=num_coords; i++){ 00044 coords[i]->i += shift.i; 00045 coords[i]->j += shift.j; 00046 coords[i]->k += shift.k; 00047 } 00048 } 00049 00050 00051 void 00052 orient_coords2_to_coords1_dp_list(coord_3D **coords, int num_coords, 00053 const coord_3D *bond_atom_a, coord_3D *bond_atom_b, double distance, 00054 const coord_3D *angle_atom_a, double theta, 00055 coord_3D *angle_atom_b, double rho, 00056 const coord_3D *dih_atom_a, coord_3D *dih_atom_b, double tau, 00057 const coord_3D *tor_atom_a, const coord_3D *ref_angle_a, double phi, 00058 coord_3D *tor_atom_b, coord_3D *ref_atom_b, double omega) 00059 { 00060 coord_3D d = get_cartesian_point_from_internal_coords(*ref_angle_a, *tor_atom_a, *bond_atom_a, 00061 theta, PI - phi, distance); 00062 00063 translate_coords_dp_list(coords, num_coords, subtract_coord(d,*bond_atom_b)); 00064 00065 double cur_dihedral = get_dihedral_ABCD_points(*dih_atom_a, *bond_atom_a, 00066 *bond_atom_b, *dih_atom_b); 00067 double cur_bond_angle = get_angle_ABC_points(*bond_atom_a, *bond_atom_b, *angle_atom_b); 00068 00069 rotate_coords_about_axis_dp_list(coords, num_coords, *bond_atom_b, 00070 get_crossprod( 00071 get_vector_from_coords(*bond_atom_a, *bond_atom_b), 00072 get_vector_from_coords(*angle_atom_b, *bond_atom_b) 00073 ), 00074 rho-cur_bond_angle); 00075 00076 /*rotate_coords_about_axis_dp_list(coords, num_coords, *bond_atom_a, 00077 subtract(*bond_atom_a, *bond_atom_b), cur_dihedral-tau);*/ 00078 rotate_coords_about_axis_dp_list(coords, num_coords, *bond_atom_a, 00079 get_vector_from_coords(*bond_atom_b, *bond_atom_a), cur_dihedral-tau); 00080 00081 double cur_omega = get_dihedral_ABCD_points(*bond_atom_a, *bond_atom_b, 00082 *tor_atom_b, *ref_atom_b); 00083 00084 /*rotate_coords_about_axis_dp_list(coords, num_coords, *bond_atom_b, 00085 subtract(*bond_atom_b, *tor_atom_b), 00086 cur_omega-omega);*/ 00087 rotate_coords_about_axis_dp_list(coords, num_coords, *bond_atom_b, 00088 get_vector_from_coords(*bond_atom_a, *tor_atom_b), 00089 cur_omega-omega); 00090 } 00091