IMP  2.0.1
The Integrative Modeling Platform
counting.h
Go to the documentation of this file.
1 /**
2  * \file IMP/example/counting.h
3  * \brief A simple unary function.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEXAMPLE_COUNTING_H
10 #define IMPEXAMPLE_COUNTING_H
11 
12 #include <IMP/example/example_config.h>
14 #include <IMP/core/XYZ.h>
15 
16 
17 IMPEXAMPLE_BEGIN_NAMESPACE
18 
19  /** Return the number of times particles from one set are close
20  to those from another set.
21  \note This method uses the distance between the centers of
22  the particles and does not use their radii.
23  */
24 inline unsigned int get_number_of_incidences(const ParticlesTemp &psa,
25  const ParticlesTemp &psb,
26  double point_distance) {
27  algebra::Vector3Ds vsa(psa.size());
28  for (unsigned int i=0; i< vsa.size(); ++i) {
29  vsa[i]= core::XYZ(psa[i]).get_coordinates();
30  }
31  IMP_NEW(algebra::NearestNeighbor3D, nn, (vsa));
32  unsigned int ret=0;
33  for (unsigned int i=0; i< psb.size(); ++i) {
35  if (!nn->get_in_ball(v,point_distance).empty()) {
36  ++ret;
37  }
38  }
39  return ret;
40 }
41 
42 IMPEXAMPLE_END_NAMESPACE
43 
44 #endif /* IMPEXAMPLE_COUNTING_H */