Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Jump.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/kinematics/Jump.hh
11 /// @brief Kinematics Jump class
12 /// @author Phil Bradley
13 
14 
15 #ifndef INCLUDED_core_kinematics_Jump_hh
16 #define INCLUDED_core_kinematics_Jump_hh
17 
18 
19 // Unit headers
21 
22 // Package Headers
23 #include <core/kinematics/RT.hh>
25 
26 // Numeric Headers
27 #include <numeric/xyzVector.hh>
28 #include <numeric/xyzMatrix.fwd.hh>
29 
30 // Utility Headers
31 #include <utility/vector1.hh>
32 
33 
34 namespace core {
35 namespace kinematics {
36 
37 static const utility::vector1<Real> ZERO( 6, 0.0 );
38 
39 /// @brief an object which makes rigid-body transformation with translational and rotational perturbation
40 ///
41 /// See @ref atomtree_overview "AtomTree overview and concepts" for details.
42 ///
43 class Jump {
44  public: // Types
45  static const int TRANS_X = 1;
46  static const int TRANS_Y = 2;
47  static const int TRANS_Z = 3;
48  static const int ROT_X = 4;
49  static const int ROT_Y = 5;
50  static const int ROT_Z = 6;
51 
52  typedef numeric::xyzVector< Real > Vector; // DOUBLE!
53  typedef numeric::xyzMatrix< Real > Matrix; // DOUBLE!
54 
55 public:
56  /// @brief construction
57  Jump ():
58  rt_(),
59  rb_delta( 2, ZERO ),
60  rb_center( 2, Vector(0.0) )
61  {}
62 
63  /// @brief constructor with only RT
64  Jump( const RT & src_rt ):
65  rt_( src_rt ),
66  rb_delta ( 2, ZERO ),
67  rb_center( 2, Vector(0.0) )
68  {}
69 
70  /// @brief get RT from two stubs and ZERO rb_delta
71  Jump ( Stub const & stub1, Stub const & stub2 ):
72  rt_( stub1, stub2 ),
73  rb_delta( 6, ZERO ),
74  rb_center( 2, Vector(0.0) )
75  {}
76 
77  /// @brief copy constructor
78  Jump ( const Jump & src ):
79  rt_( src.rt_ ),
80  rb_delta( src.rb_delta ),
81  rb_center( src.rb_center )
82  {}
83 
84  /// @brief copy operator
85  Jump &
86  operator =( Jump const & src ) {
87  rt_ = src.rt_;
88  rb_delta = src.rb_delta;
89  rb_center = src.rb_center;
90  return *this;
91  }
92 
93  /// @brief get a jump from two stubs
94  void
95  from_stubs(
96  Stub const & stub1,
97  Stub const & stub2
98  );
99 
100  /// @brief get a jump from a bond cst definition
101  void
104  utility::vector1< Real > const & csts
105  );
106 
107  /// @brief make a jump from stub1 to stub2
108  void
109  make_jump(
110  Stub const & stub1,
111  Stub & stub2
112  ) const;
113 
114  /// @brief check RT's orthogonality
115  bool ortho_check() const;
116 
117  /// @brief check whether there is rb_delta not being transformed.
118  bool nonzero_deltas() const;
119 
120  /// @brief reset RT, rb_delta and rb_center
121  void reset();
122 
123  /// @brief translate along a randomly chosen vector by dist_in
124  void random_trans( const float dist_in );
125 
126  /// @brief Given the desired magnitude of the translation and rotation
127  /// components, applies Gaussian perturbation to this jump.
128  /// Return the move that was applied
129  utility::vector1<Real> gaussian_move(int const dir, float const trans_mag, float const rot_mag);
130 
131  // @brief make a gaussian move with one selected rb dof
132  void
134  int const dir,
135  float const mag,
136  int rb
137  );
138 
139  /// @brief make a rotation "matrix" about the center "center"
140  void
142  Stub const & stub,
143  Vector const & center, //in xyz frame
144  Matrix const & matrix //in xyz frame
145  );
146 
147  /// @brief make a rotation of alpha degrees around axix and center
148  void
150  Stub const & stub,
151  Vector const & axis,
152  Vector const & center, //in xyz frame
153  float const alpha
154  );
155 
156  /// @brief make a translation along axis by dist
157  void
159  Stub const & stub,
160  Vector const & axis,
161  float const dist
162  );
163 
164  /// @brief reset to identity matrix, 0 translation
165  void
167 
168  /// @brief change the direction of a jump, e.g, upstream stub becomes downstream stub now.
169  void
170  reverse();
171 
172  /// @brief Return a new jump that is the inverse transformation
173  Jump
174  reversed() const;
175 
176  /// @brief get rotation matrix
177  inline
178  Matrix const &
179  get_rotation() const;
180 
181  /// @brief get translation vector
182  inline
183  Vector const &
184  get_translation() const;
185 
186  /// @brief set rotation matrix
187  void
188  set_rotation( Matrix const & R_in );
189 
190  /// @brief set translation vector
191  void
192  set_translation( Vector const & t );
193 
194  /// @brief transform small changes in translation and rotation into jump
195  void
196  fold_in_rb_deltas(); // call after we're done minimizing
197 
198  /// @brief return the RT modeled by this jump --> makes new Jump, calls fold_in_rb_delte and returns RT
199  RT rt() const;
200 
201  /// @brief get rb_delta by direction
202  inline
203  utility::vector1<Real> const &
204  get_rb_delta( int const dir ) const;
205 
206  /// @brief get rb_delta by direction and rb_number
207  inline
208  Real
209  get_rb_delta( int const rb_no, int const dir ) const;
210 
211  /// @brief set rb_delta by direction and rb_number
212  void
213  set_rb_delta( int const rb_no, int const dir, Real const value );
214 
215  /// @brief set rb_deltas by direction
216  void
217  set_rb_deltas( int const dir, utility::vector1<Real> const & );
218 
219  /// @brief get rb_center by direction
220  inline
221  Vector const &
222  get_rb_center( int const dir ) const;
223 
224  /// @brief set rb_center by direction
225  void
227  const int dir,
228  Stub const & stub,
229  Vector const & center
230  );
231 
232  /// @brief stream output operator
233  friend std::ostream & operator <<( std::ostream & os, const Jump & jump );
234  /// @brief stream input operator
235  friend std::istream & operator >>( std::istream & is, Jump & jump );
236  /// @brief RT root squared deviation
237  friend Real distance( Jump const & a_in, Jump const & b_in );
238 
239 private:
240  // private methods
241 
242 
243  /// @brief get the lookup index into rb_delta and rb_center from the direction dir.
244  /** dir should be 1 or -1 */
245 
246  inline
247  int
248  rb_index( int const dir ) const
249  {
250  assert( dir == 1 || dir == -1 );
251  return ( dir == 1 ? 1 : 2 );
252  }
253 
254 
255  /////////////////////////////////////////////////////////////////////////////
256  // data
257  /////////////////////////////////////////////////////////////////////////////
258 
259 private:
260 
261  /// translation and rotation
263  /// changes to translation and rotation
264  /**
265  6x2 table, for each of the two folding directions, the first three are for translations
266  along xyz, and the next three are for rotatation around xyz axes.
267  */
269 
270  /// the center around which the rotation is performed
271  /**
272  3x2 table, for each of the two folding directions, the rotation center is written in the local frame
273  of the downstream stub.
274  */
276 
277 }; // Jump
278 
279 
280 ///////////////////////////////////////////////////////////////////////////////
281 /// inline definitions for Jump class
282 
283 inline
284 Jump::Matrix const &
286 {
287  return rt_.get_rotation();
288 }
289 
290 ///////////////////////////////////////////////////////////////////////////////
291 inline
292 Jump::Vector const &
294 {
295  return rt_.get_translation();
296 }
297 
298 ///////////////////////////////////////////////////////////////////////////////
299 // this one is private
300 
301 ///////////////////////////////////////////////////////////////////////////////
302 //
303 inline
305 Jump::get_rb_delta( int const dir ) const
306 {
307  return rb_delta[ rb_index( dir ) ];
308 }
309 
310 ///////////////////////////////////////////////////////////////////////////////
311 //
312 inline
313 Real
314 Jump::get_rb_delta( int const rb_no, int const dir ) const
315 {
316  assert( dir == 1 || dir == -1 );
317  return rb_delta[ rb_index( dir ) ][ rb_no ] ;
318 }
319 
320 ///////////////////////////////////////////////////////////////////////////////
321 //
322 inline
323 Jump::Vector const &
324 Jump::get_rb_center( int const dir ) const
325 {
326  assert( dir == 1 || dir == -1 );
327  return rb_center[ rb_index( dir ) ];
328 }
329 
330 /// @brief compare the difference of two jumps in term of the translation (dist) and rotational angle(theta)
331 void
333  Jump const & a_in,
334  Jump const & b_in,
335  Real & dist,
336  Real & theta
337 );
338 
339 
340 /// @brief RT root squared deviation
341 Real distance( Jump const & a_in, Jump const & b_in );
342 
343 
344 } // namespace kinematics
345 } // namespace core
346 
347 
348 #endif // INCLUDED_core_kinematics_Jump_HH