22 #include <basic/Tracer.hh>
25 #include <numeric/constants.hh>
28 #include <utility/vector1.fwd.hh>
29 #include <numeric/numeric.functions.hh>
36 #include <utility/vector1.hh>
39 namespace frag_picker {
44 static basic::Tracer
trGunnCost(
"core.fragment.GunnCost");
48 if ( begin == end )
return;
58 id::AtomID CAj( rtj.atom_index (
"CA") , begin );
61 p2 = pose.
xyz ( CAj );
76 cross( x1, p3 - p2, z1 );
88 p2 = pose.
xyz ( CAk );
98 cross( x2, p3 - p2, z2 );
104 R = pose.
xyz( CAk ) - pose.
xyz( CAj );
108 data.
q6 = R.length();
111 data.
q1 = dot_product( x1, R );
112 data.
q2 = dot_product( x2, R );
113 data.
q3 = dot_product( x1, x2) - data.
q1 * data.
q2;
114 data.
q3 /= ( std::sqrt( (1-data.
q1*data.
q1) * (1-data.
q2*data.
q2) ) + .0001 );
115 data.
q3 = std::acos( numeric::sin_cos_range( data.
q3 ) );
116 data.
q4 = std::acos( numeric::sin_cos_range( dot_product( y1, R ) / ( std::sqrt( 1-data.
q1 * data.
q1 ) + .0001 ) ) );
117 data.
q5 = std::acos( numeric::sin_cos_range( dot_product( y2, R ) / ( std::sqrt( 1-data.
q2 * data.
q2 ) + .0001 ) ) );
122 using numeric::constants::d::pi_over_2;
123 using numeric::constants::d::pi;
130 Real d3 ( std::abs( g1.
q3 - g2.
q3 ) );
131 if ( d3 > pi_over_2 ) d3 = pi - d3;
132 Real d4 ( std::abs( g1.
q4 - g2.
q4 ) );
133 if ( d4 > pi_over_2 ) d4 = pi - d4;
134 Real d5 ( std::abs( g1.
q5 - g2.
q5 ) );
135 if ( d5 > pi_over_2 ) d5 = pi - d5;
138 c3 * std::log( 1.0 + ( std::abs( g1.
q1 - g2.
q1 ) + std::abs( g1.
q2 - g2.
q2 ) ) ) +
139 c2 * std::log( 1.0 + std::abs( g1.
q6 - g2.
q6 ) ) +
140 c1 * std::log( 1.0 + d3 ) +
141 c4 * std::log( 1.0 + d4 + d5 );
142 if ( cost < 2.95 ) cost = 100;