IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 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
16IMPEXAMPLE_BEGIN_NAMESPACE
17
18/** Return the number of times particles from one set are close
19 to those from another set.
20 \note This method uses the distance between the centers of
21 the particles and does not use their radii.
22*/
23inline unsigned int get_number_of_incidences(const ParticlesTemp &psa,
24 const ParticlesTemp &psb,
25 double point_distance) {
26 algebra::Vector3Ds vsa(psa.size());
27 for (unsigned int i = 0; i < vsa.size(); ++i) {
28 vsa[i] = core::XYZ(psa[i]).get_coordinates();
29 }
30 IMP_NEW(algebra::NearestNeighbor3D, nn, (vsa));
31 unsigned int ret = 0;
32 for (unsigned int i = 0; i < psb.size(); ++i) {
34 if (!nn->get_in_ball(v, point_distance).empty()) {
35 ++ret;
36 }
37 }
38 return ret;
39}
40
41IMPEXAMPLE_END_NAMESPACE
42
43#endif /* IMPEXAMPLE_COUNTING_H */
Simple XYZ decorator.
A decorator for a particle with x,y,z coordinates.
Definition XYZ.h:30
const algebra::Vector3D & get_coordinates() const
Convert it to a vector.
Definition XYZ.h:109
unsigned int get_number_of_incidences(const ParticlesTemp &psa, const ParticlesTemp &psb, double point_distance)
Definition counting.h:23
Vector< VectorD< 3 > > Vector3Ds
Definition VectorD.h:409
VectorD< 3 > Vector3D
Definition VectorD.h:407
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
Functions to search over vectors.