Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SurfaceParameters.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;
2 // rm-trailing-spaces:t -*-
3 // vi: set ts=2 noet:
4 // :noTabs=false:tabSize=4:indentSize=4:
5 //
6 // (c) Copyright Rosetta Commons Member Institutions.
7 // (c) This file is part of the Rosetta software suite and is made available
8 // under license.
9 // (c) The Rosetta software is developed by the contributing members of the
10 // Rosetta Commons.
11 // (c) For more information, see http://www.rosettacommons.org. Questions
12 // about this can be
13 // (c) addressed to University of Washington UW TechTransfer,
14 // email: license@u.washington.edu.
15 
16 /// @file SurfaceParameters.hh
17 /// @brief
18 /// @author Robin A Thottungal (raugust1@jhu.edu)
19 
20 // Package Headers
23 #include <basic/datacache/BasicDataCache.hh>
24 
25 // Numeric Headers
26 #include <numeric/xyz.functions.hh>
27 #include <numeric/xyz.io.hh>
28 #include <numeric/xyzVector.hh>
29 
30 // Utility Headers
31 #include <utility/vector1.hh>
32 #include <utility/exit.hh>
33 #include <basic/Tracer.hh>
34 
35 // C++ headers
36 #include <iostream>
37 #include <stdio.h>
38 #include <stdlib.h>
39 
40 static basic::Tracer TR("protocols.surfaceDocking.SurfaceParameters");
41 
42 namespace protocols {
43 namespace surface_docking {
44 
45 using namespace numeric;
46 
48  //These values are used to check for the status of surfaceParameters object
49  SURFA0=0;
50  SURFA1=0;
51  SURFA2=0;
52 
53  vecAB=0;
54  vecAB=0;
55 }
56 
58  std::string strSURFA1, std::string strSURFA2 ) {
59  SURFA0=SplitSurfaceVectorString(strSURFA0);
60  SURFA1=SplitSurfaceVectorString(strSURFA1);
61  SURFA2=SplitSurfaceVectorString(strSURFA2);
62  TR<<"Surface Vectors value inside constructor:"<<std::endl;
63  TR<<"SURFA0:"<<SURFA0<<std::endl;
64  TR<<"SURFA1:"<<SURFA1<<std::endl;
65  TR<<"SURFA2:"<<SURFA2<<std::endl;
66  vecAB=0;
67  vecAB=0;
68 }
69 
71  CacheableData() {
72  // Setting up the values for caching data
73 
74  SURFA0=src.SURFA0;
75  SURFA1=src.SURFA1;
76  SURFA2=src.SURFA2;
77 
78  strSURFA0=src.strSURFA0;
79  strSURFA1=src.strSURFA1;
80  strSURFA2=src.strSURFA2;
81  A=src.A;
82  B=src.B;
83  C=src.C;
84  vecAB=src.vecAB;
85  vecAC=src.vecAB;
86  SurfaceCG=src.SurfaceCG;
90  surfacePlane=src.surfacePlane; // ax+by+cz+d=0
91  slideaxis=src.slideaxis;
92 }
93 
94 // removed for making class child of CacheableData
95 //SurfaceParameters::~SurfaceParameters(){}
96 
98  SurfaceCG=SurfCG;
99  // Generating the 2 basis vectors of the surface crystal system
100  Vector vecAB0 = SURFA1-SURFA0;
101  Vector vecAC0 = SURFA2-SURFA0;
102  // Translating the basic vectors to the centroid of the surface
103  A=SurfaceCG;
104  B=SurfaceCG+vecAB0;
105  C=SurfaceCG+vecAC0;
106  TR<<"Translated Surface Vectors CoOrdinates"<<std::endl;
107  TR<<"SURFA0:"<<A<<std::endl;
108  TR<<"SURFA1:"<<B<<std::endl;
109  TR<<"SURFA2:"<<C<<std::endl;
110  // Generating the 2 basis vectors of the surface crystal system
111  // based on new coordinates
112  vecAB = B-A;
113  vecAC = C-A;
114  // Calculate the normal vector to the surface
118  TR<<" Surface Normal Vectors:"<<surfaceNormalVec<<std::endl;
119  // Calculate the anti-normal vector to the surface
121  TR<<" Surface Anti Normal Vectors:"<<surfaceAntiNormalVec<<std::endl;
122  // Generate the equation of the plane ax+by+cz+d=0
124 
125 }
126 
128  Vector Bvector , Vector Cvector ){
129 
130  core::Real t,DD,w ;
131  Vector crossBC,cross1C,CB,CB_C,intersection,inv_crossBC;
132  CB = point2 - point1 ;
133  cross1C = cross ( CB, Cvector );
134  crossBC = cross ( Bvector, Cvector );
135  w = inner_product ( cross1C, crossBC);
136  DD = inner_product ( crossBC, crossBC);
137  t = w / DD;
138  return (point1 + t * Bvector); //intersection
139 }
140 
141 // Calculate the normal to a plane given three point on the plane
142 // AB x BC --> normal vector
144  Vector Apoint , Vector Bpoint ,Vector Cpoint ){
145  Vector AB,AC;
146  AB = Bpoint - Apoint;
147  AC = Cpoint - Apoint;
148  return cross(AB,AC); //normal
149 
150 }
151 
152 // Generate an equation of plane given 3 points that lie on the plane
153 // ax+by+cz+d=0
155  ( Vector Apoint , Vector Bpoint , Vector Cpoint ){
156  Plane plane123;
157  Vector normalto3 ;
158  normalto3 = CalcNormalVector( Apoint, Bpoint, Cpoint );
159  plane123.push_back(normalto3.x());
160  plane123.push_back(normalto3.y());
161  plane123.push_back(normalto3.z());
162  plane123.push_back
163  (- normalto3.x()* Apoint.x() -
164  normalto3.y()* Apoint.y() - normalto3.z() * Apoint.z());
165 
166  return plane123;
167 }
168 
171 }
172 
174  ( Plane plane_abcd , Vector point_outofplane , Vector normal_plane ){
175  core::Real t;
176  Vector point_intersection;
177  t=
178  -( plane_abcd [1] * point_outofplane.x() +
179  plane_abcd [2] * point_outofplane.y() +
180  plane_abcd [3] * point_outofplane.z() + plane_abcd [3] )
181  /
182  ( plane_abcd [1] * plane_abcd [1] + plane_abcd [2] * plane_abcd [2]
183  + plane_abcd [3] * plane_abcd [3] );
184  point_intersection = point_outofplane - t * normal_plane;
185  return point_intersection;
186 }
187 
189  //std::istringstream oss (str);
190  //std::string word;
191  //std::string tmp[4];
192  //Size i=0;
193  //while(oss >> word) {
194  /// tmp[i]=word;
195  /// i=i+1;
196  // }
197  if ( str.size() >= 52 ) {
199  tmp[1] = str.substr( 30, 7 );
200  tmp[2] = str.substr( 38, 7 );
201  tmp[3] = str.substr( 46, 7 );
202  Vector coords( atof( tmp[1].c_str() ), atof( tmp[2].c_str() ), atof( tmp[3].c_str() ));
203  return coords;
204  } else {
205  utility_exit_with_message("Unable to convert remark '" + str + "' into surface vector" );
206  }
207  return Vector(0.0); // appease compiler
208 }
209 
210 }// namespace surface_docking
211 }// namespace protocols