23 #include <utility/exit.hh>
31 #include <utility/vector1.hh>
32 #include <ObjexxFCL/Fmath.hh>
37 namespace ObjexxFCL { }
using namespace ObjexxFCL;
51 LeeRichards::LeeRichards(
59 compute( pd->spheres, accum, spacing, probe_radius, csa, plane );
62 LeeRichards::LeeRichards(
79 compute( spheres, accum, spacing, probe_radius, csa, plane );
99 if( xunit == plane ) xunit.y(1);
100 xunit -= plane * xunit.dot(plane);
102 yunit = plane.cross(xunit);
103 assert( abs( 0.0 - xunit.dot(yunit) ) < 1e-9 );
104 assert( abs( 0.0 - xunit.dot(plane) ) < 1e-9 );
105 assert( abs( 0.0 - plane.dot(yunit) ) < 1e-9 );
106 assert( abs( 1.0 - xunit.length() ) < 1e-9 );
107 assert( abs( 1.0 - yunit.length() ) < 1e-9 );
108 assert( abs( 1.0 - plane.length() ) < 1e-9 );
116 for(
SphereIter i = spheres.begin(); i != spheres.end(); ++i ) {
117 Real const d = plane.dot(i->xyz);
118 if( d - i->radius - probe_radius < mn ) mn = d - i->radius-probe_radius;
119 if( d + i->radius + probe_radius > mx ) mx = d + i->radius+probe_radius;
121 int Nslice =
int( (mx-mn) / spacing );
122 Real st = mn + ((mx-mn)-Nslice*spacing)/2.0;
123 for(
core::Real r = st; r <= mx; r += spacing ){
124 slice_coords_.push_back(r);
129 for(
RealCIter i = slice_coords_.begin(); i != slice_coords_.end(); ++i ) {
131 bool internal_allowed =
true;
132 slices_.push_back(
new Slice(accum,spacing,internal_allowed) );
136 for(
Size i = 1; i <= spheres.size(); ++i ) {
139 Real const crd = plane.dot(s.
xyz), x = xunit.dot(s.
xyz), y = yunit.dot(s.
xyz);
141 Size first = find_first_slice(crd-rad);
142 if( 0 == first )
continue;
145 while( first <= slice_coords_.size() && slice_coords_[first] <
stop ) {
147 Real d = crd - slice_coords_[first];
148 if( fabs(d) >= rad )
continue;
149 Real r = sqrt(rad*rad - d*d);
151 Real dada = spacing*rad;
159 slices_[first]->add_circle(
new Circle(x,y,r,drdz,dada,s.
aid) );
172 for(
Size i = 1; i <= slices_.size(); ++i ) {
175 slices_[i]->compute();
184 MultiProbePoseAccumulator::MultiProbePoseAccumulator(
187 ) : pr_idx_(1), pose_(_pose), tag_(tag)
202 out << dat.
area[i] <<
" " << dat.
barea[i] <<
" ";
203 tot[i] += dat.
area[i];
204 btot[i] += dat.
barea[i];
211 out << tot[i] <<
" " << btot[i] <<
" ";
218 if( a->
x==b->
x )
return a->
y > b->
y;
219 else return a->
x > b->
x;
241 Real d = sqrt((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1));
247 if( d >= r0+r1 || d <= fabs(r0-r1) )
return PointPair(0.0,0.0,0.0,0.0);
248 Real _a = (r0*r0 - r1*r1 + d*d ) / (2*d);
249 if( r0*r0 < _a*_a ) {
250 std::cerr <<
"r0*r0 < _a*_a: \n" <<
x <<
" " <<
y <<
" " <<
r <<
" \n" << other->
x <<
" " << other->
y <<
" " << other->
r <<
" " << d << std::endl;
251 std::cerr <<
"abs(r0-r1) " << fabs(r0-r1) << std::endl;
252 utility_exit_with_message(
"Circle::overlap error" );
254 Real h = sqrt(r0*r0 - _a*_a);
255 Real x2 = x0 + _a * ( x1 - x0 ) / d;
256 Real y2 = y0 + _a * ( y1 - y0 ) / d;
257 Real x3 = x2 + h * ( y1 - y0 ) / d;
258 Real y3 = y2 - h * ( x1 - x0 ) / d;
259 Real x4 = x2 - h * ( y1 - y0 ) / d;
260 Real y4 = y2 + h * ( x1 - x0 ) / d;
267 out <<
"Circle( " << circle.
x <<
" " << circle.
y <<
" " << circle.
r <<
" )";
287 if( !nbr.
contains(circle->
x+circle->
r,circle->
y,2,circle) ) {
290 if( !nbr.
contains(circle->
x-circle->
r,circle->
y,2,circle) ) {
294 int I = nbr.
get_i(circle->
x);
295 int J = nbr.
get_j(circle->
y);
296 for(
int i = std::max(I-2,0); i <= std::min(I+2,(
int)nbr.
Xdim_); ++i ) {
297 for(
int j = std::max(J-2,0); j <= std::min(J+2,(
int)nbr.
Ydim_); ++j ) {
300 if( circle <= circle2 )
continue;
304 if( 0.0==pp.
a.
x && 0.0==pp.
a.
y && 0.0==pp.
b.
x && 0.0==pp.
b.
y )
continue;
344 bool have_cw_trace = ( circle->
tcw != NULL && e->
y > circle->
y );
345 bool have_ccw_trace = ( ccwcircle->
tccw != NULL && e->
y < ccwcircle->
y );
346 if( have_cw_trace && have_ccw_trace ) {
349 }
else if( !have_cw_trace && !have_ccw_trace ) {
352 }
else if( have_cw_trace ) {
354 }
else if( have_ccw_trace ) {
357 utility_exit_with_message(
"Slice::compute_surface()" );
378 accum_->accumulate_area(ia->first,ia->second,is_internal);
401 accum_->accumulate_dxdy( e->
circle->
atom, mg*cos(dir), -mg*sin(dir), is_internal );
402 accum_->accumulate_dxdy( e->
ccw ->
atom, -mg*cos(dir), mg*sin(dir), is_internal );
423 using namespace utility;
424 using namespace numeric;
429 for(
size_t is = 1; is <=
pd_->spheres.size(); ++is ) {
430 Sphere const & sphere(
pd_->spheres[is] );
433 for(
size_t id = 1;
id <= Nshells; ++id ) {
435 for(
size_t pr = 1; pr <= Nprobes; ++pr ) {
444 for(
size_t id = 1;
id <= Nshells; ++id ) {
445 for(
size_t pr = 2; pr <= Nprobes; ++pr ) {
446 rtn->msa(
id,pr-1) = psrdOP->msa(
id,pr) - psrdOP->msa(
id,1);
457 Real & buried_area_out,
464 if( plane.length() > 0 ) {
467 LeeRichards lr( pd, accumOP, slicesize, pr, csa, plane );
468 buried_area_out = accum->buried_area;
469 return accum->total_area;
476 buried_area_out += accum->buried_area;
477 area += accum->total_area / 3.0;
483 buried_area_out += accum->buried_area;
484 area += accum->total_area / 3.0;
490 buried_area_out += accum->buried_area;
491 area += accum->total_area / 3.0;
517 XYZs rtn(pd->spheres.size(),
XYZ(0.0,0.0,0.0));
522 for(
Size i = 1; i <= pd->spheres.size(); ++i ) {
523 rtn[i].y() += accum->atom_map_[
AtomID(1,i)].dx / 2.0;
524 rtn[i].z() += accum->atom_map_[
AtomID(1,i)].dy / 2.0;
531 for(
Size i = 1; i <= pd->spheres.size(); ++i ) {
532 rtn[i].x() += accum->atom_map_[
AtomID(1,i)].dx / 2.0;
533 rtn[i].z() -= accum->atom_map_[
AtomID(1,i)].dy / 2.0;
540 for(
Size i = 1; i <= pd->spheres.size(); ++i ) {
541 rtn[i].x() += accum->atom_map_[
AtomID(1,i)].dx / 2.0;
542 rtn[i].y() += accum->atom_map_[
AtomID(1,i)].dy / 2.0;
560 Real new_area1, new_area2;
565 Size N = min((
Size)max_num,pd->spheres.size());
568 for(
Size i = 1; i <=
N; ++i ) {
569 std::cerr <<
"check_surface_area_leerichards_deriv " << i << std::endl;
571 pd->spheres[i].xyz.x() +=
D;
574 rtn[i].x( ((new_area1+new_area2)/2.0-(orig_area_y+orig_area_z)/2.0) / D );
575 pd->spheres[i].xyz.x() -=
D;
577 pd->spheres[i].xyz.y() +=
D;
580 rtn[i].y( ((new_area1+new_area2)/2.0-(orig_area_x+orig_area_z)/2.0) / D );
581 pd->spheres[i].xyz.y() -=
D;
583 pd->spheres[i].xyz.z() +=
D;
586 rtn[i].z( ((new_area1+new_area2)/2.0-(orig_area_x+orig_area_y)/2.0) / D );
587 pd->spheres[i].xyz.z() -=
D;
602 for(
Size pri = 1; pri <= 31; pri++ ) {
605 accum->set_pr_idx(pri);
606 LeeRichards lr( pd, accumOP, slicesize, pr,
true, plane );
609 for(
Size i = 1; i <= pd->centers.size(); ++i ) {
612 psrds.push_back(psrd);
616 return ps_discrim.
score( psrds );