Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Stub.cc
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/Stub.cc
11 /// @brief Stub class
12 /// @author Phil Bradley
13 
14 
15 // Unit headers
16 #include <core/kinematics/Stub.hh>
17 #include <core/kinematics/RT.hh>
18 
19 #include <utility/vector1.hh>
20 #include <numeric/xyz.functions.hh>
21 
22 
23 
24 namespace core {
25 namespace kinematics {
26 
27 Stub::Stub( RT const & rt ):
28  M( rt.get_rotation() ),
29  v( rt.get_translation() )
30 {}
31 
32 /// @brief output operator, 3x3 matrix followd by an xyzVector
33 std::ostream &
34 operator<<( std::ostream & os, Stub const & a )
35 {
36  os << "STUB";
37  for ( int i=1; i<= 3; ++i ) {
38  for ( int j=1; j<= 3; ++j ) {
39  os << ' ' << a.M(i,j);
40  }
41  }
42  for ( int i=1; i<= 3; ++i ) {
43  os << ' ' << a.v(i);
44  }
45  return os;
46 }
47 
48 /////////////////////////////////////////////////////////////////////////////
49 ///@brief build a stub from a center points and other three points a, b, c
50 ///
51 ///@details orthogonal coord frame M contains three unit vectors by column,
52 ///the first one is the unit vector from b pointing to a, the second one is the
53 ///unit vector which is in the plane defined by vector b->a and b->c and
54 ///perpendicular to b->a, the third one is the cross product of the first two.
55 void
57  Vector const & center,
58  Vector const & a,
59  Vector const & b,
60  Vector const & c
61 )
62 {
63  Vector e1( a - b);
64  e1.normalize();
65 
66  Vector e3( cross( e1, c - b ) );
67  e3.normalize();
68 
69  Vector e2( cross( e3,e1) );
70  M.col_x( e1 ).col_y( e2 ).col_z( e3 );
71  v = center;
72 }
73 
74 
75 Vector
76 Stub::build_fake_xyz( Size const index ) const
77 {
78  Real const length( 1.4 );
79  Real const angle( numeric::conversions::radians( 120.0 ) );
80  Vector const xyz1( v );
81  Vector const xyz2( xyz1 + length * M * Vector( -1, 0, 0 ) );
82  Vector const xyz3( xyz2 + length * M * Vector( std::cos( angle ), std::sin( angle ), 0 ) );
83 
84  switch( index ) {
85  case 1:
86  return xyz1;
87  case 2:
88  return xyz2;
89  case 3:
90  return xyz3;
91  default:
92  utility_exit_with_message( "Stub::build_fake_xyz must be called with 1<= index <= 3" );
93  }
94 
95  return Vector( 0.0 ); // wont get here
96 
97 }
98 
99 
100 /// @brief Globals
101 ///
102 /// @details a stub center at 0.0 with lab frame(identy matrix)
103 Stub /* const */ default_stub( Stub::Matrix::identity(), Stub::Vector( 0.0 ) );
104 
105 
106 } // namespace kinematics
107 } // namespace core