IMP  2.0.1
The Integrative Modeling Platform
randomizing.h
Go to the documentation of this file.
1 /**
2  * \file IMP/example/randomizing.h
3  * \brief A simple unary function.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEXAMPLE_RANDOMIZING_H
10 #define IMPEXAMPLE_RANDOMIZING_H
11 
12 #include <IMP/example/example_config.h>
13 #include <IMP/core/rigid_bodies.h>
15 
16 
17 IMPEXAMPLE_BEGIN_NAMESPACE
18 
19 
20 template <class RigidBody, class BoundingVolume>
21 void randomize_rigid_body(RigidBody rbi,
22  const BoundingVolume &bv) {
23  core::RigidBody rb(rbi);
24  algebra::Rotation3D rot= algebra::get_random_rotation_3d();
26  algebra::Transformation3D tr(rot, trans);
27  algebra::ReferenceFrame3D rf(tr);
28  rb.set_reference_frame(rf);
29 }
30 
31 /** Randomize the positions of a set of particles within a bounding
32  volume. Rigid bodies have their orientation randomized too.
33 */
34 template <class ParticlesList, class BoundingVolume>
35 void randomize_particles(const ParticlesList &ps,
36  const BoundingVolume &bv) {
37  for (unsigned int i=0; i< ps.size(); ++i) {
38  core::XYZ d(ps[i]);
40  if (core::RigidBody::particle_is_instance(ps[i])) {
41  randomize_rigid_body(ps[i], bv);
42  } else {
44  }
45  } else if (core::RigidMember::particle_is_instance(ps[i])) {
46  /* since this is unlikely to be speed critical, don't bother
47  to check if we have randomized it already.*/
48  randomize_rigid_body(core::RigidMember(ps[i]).get_rigid_body(),
49  bv);
50  }
51  }
52 }
53 
54 
55 IMPEXAMPLE_END_NAMESPACE
56 
57 #endif /* IMPEXAMPLE_RANDOMIZING_H */