20 #include <basic/Tracer.hh>
22 #include <numeric/xyz.functions.hh>
23 #include <numeric/trig.functions.hh>
24 #include <numeric/deriv/dihedral_deriv.hh>
26 #include <utility/exit.hh>
33 #include <utility/vector1.hh>
37 namespace constraints {
39 static basic::Tracer
TR(
"core.io.constraints");
65 Vector const f2 = cross(v,w);
91 Vector v12( cross( v1, v2 ));
92 Vector v23( cross( v2, v3 ));
94 Real const n12( v12.length() );
95 Real const n23( v23.length() );
97 if ( n12 < 1e-9 || n23 < 1e-9 )
return;
99 x = dot( v12, v23) / ( n12 * n23 );
103 Real const f( 1.0f/ ( n12 * n23 ) );
104 helper( p1, f * v2, v23 , F1, F2);
109 Real const f( -1.0f * x / ( n12 * n12 ) );
110 helper( p1, f * v2, v12, F1, F2 );
119 assert( std::abs( dot( F2, v1 ) ) < 1e-3 );
120 assert( std::abs( dot( F2, v2 ) ) < 1e-3 );
121 assert( std::abs( dot( F1, cross( v1, v2 ) ) ) < 1e-3 );
148 Vector v12( cross( v1, v2 ));
149 Vector v23( cross( v2, v3 ));
151 Real const n12( v12.length() );
152 Real const n23( v23.length() );
154 if ( n12 < 1e-9 || n23 < 1e-9 )
return;
156 x = dot( v12, v23) / ( n12 * n23 );
171 Real const f( -1.0f/ ( n12 * n23 ) );
172 helper( p2, f * v2, v23 , F1, F2);
176 Real const f( -1.0f/ ( n12 * n23 ) );
177 helper( p2, f * v1, v23 , F1, F2);
181 Real const f( 1.0f/ ( n12 * n23 ) );
182 helper( p2, f * v3, v12 , F1, F2);
190 Real const f( x/ ( n12 * n12 ) );
191 helper( p2, f * v2, v12, F1, F2 );
195 Real const f( x/ ( n12 * n12 ) );
196 helper( p2, f * v1, v12, F1, F2 );
200 Real const f( -1.0f * x/ ( n23 * n23 ) );
201 helper( p2, f * v3, v23, F1, F2 );
207 assert( std::abs( dot( F2, v2 ) ) < 1e-3 );
287 using namespace numeric::deriv;
294 }
else if ( atom ==
atom2_ ) {
296 }
else if ( atom ==
atom3_ ) {
298 }
else if ( atom ==
atom4_ ) {
306 F1 += dE_dtheta * weights[ this->
score_type() ] * f1;
307 F2 += dE_dtheta * weights[ this->
score_type() ] * f2;
369 utility_exit_with_message(
"DihedralConstraint::atom() bad argument" );
384 Size res1, res2, res3, res4;
385 std::string tempres1, tempres2, tempres3, tempres4;
402 TR.Debug <<
"read: " << name1 <<
" " << name2 <<
" " << name3 <<
" " << name4 <<
" "
403 << res1 <<
" " << res2 <<
" " << res3 <<
" " << res4 <<
" func: " << func_type
406 TR.Warning <<
"ignored constraint (no such atom in pose!)"
407 << name1 <<
" " << name2 <<
" " << name3 <<
" " << name4 <<
" "
408 << res1 <<
" " << res2 <<
" " << res3 <<
" " << res4 <<
" func: " << func_type
410 in.setstate( std::ios_base::failbit );
420 TR.Warning <<
"Error reading atoms: read in atom names("
421 << name1 <<
"," << name2 <<
"," << name3 <<
"," << name4 <<
"), "
424 in.setstate( std::ios_base::failbit );
429 func_->read_data( in );
432 while( in.good() && (in.get() !=
'\n') ) {}
434 if (
TR.Debug.visible() ) {
435 func_->show_definition( std::cout );
436 std::cout << std::endl;
451 return func( dihedral_radians( p1, p2, p3, p4 ) );
458 if( !dynamic_cast< DihedralConstraint const * > ( &other_cst ) )
return false;
460 DihedralConstraint const & other( static_cast< DihedralConstraint const & > (other_cst) );
484 out <<
"DihedralConstraint";
487 out <<
' ' <<
id.rsd() <<
' ' <<
id.atomno();
490 func_->show_definition(out);
499 func_->show_definition( out );
510 if ( verbose_level > 80 ) {
517 if ( verbose_level > 120 ) {
519 Vector const & xyz1( conformation.xyz(
atom1_ ) ), xyz2( conformation.xyz(
atom2_ ) );
520 out <<
"\ncoords1: " << xyz1[ 1 ] <<
" " << xyz1[ 2 ] <<
" " << xyz1[ 3 ] <<
" --- ";
521 out <<
"coords1: " << xyz2[ 1 ] <<
" " << xyz2[ 2 ] <<
" " << xyz2[ 3 ] <<
"\n";
524 return func_->show_violations( out, 0.0, verbose_level, threshold );
530 return func_->func( theta );
535 return func_->dfunc( theta );