IMP  2.3.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-2014 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 IMPEXAMPLE_BEGIN_NAMESPACE
17 
18 template <class RigidBody, class BoundingVolume>
19 void randomize_rigid_body(RigidBody rbi, const BoundingVolume &bv) {
20  core::RigidBody rb(rbi);
21  algebra::Rotation3D rot = algebra::get_random_rotation_3d();
23  algebra::Transformation3D tr(rot, trans);
24  algebra::ReferenceFrame3D rf(tr);
25  rb.set_reference_frame(rf);
26 }
27 
28 /** Randomize the positions of a set of particles within a bounding
29  volume. Rigid bodies have their orientation randomized too.
30 */
31 template <class ParticlesList, class BoundingVolume>
32 void randomize_particles(const ParticlesList &ps, const BoundingVolume &bv) {
33  for (unsigned int i = 0; i < ps.size(); ++i) {
34  core::XYZ d(ps[i]);
36  if (core::RigidBody::get_is_setup(ps[i])) {
37  randomize_rigid_body(ps[i], bv);
38  } else {
40  }
41  } else if (core::RigidMember::get_is_setup(ps[i])) {
42  /* since this is unlikely to be speed critical, don't bother
43  to check if we have randomized it already.*/
44  randomize_rigid_body(core::RigidMember(ps[i]).get_rigid_body(), bv);
45  }
46  }
47 }
48 
49 IMPEXAMPLE_END_NAMESPACE
50 
51 #endif /* IMPEXAMPLE_RANDOMIZING_H */
bool get_coordinates_are_optimized() const
Get whether the coordinates are optimized.
Definition: XYZ.h:86
Rotation3D get_random_rotation_3d()
Pick a rotation at random from all possible rotations.
void set_coordinates(const algebra::Vector3D &v)
set all coordinates from a vector
Definition: XYZ.h:62
functionality for defining rigid bodies
Functions to generate vectors.
VectorD< D > get_random_vector_in(const BoundingBoxD< D > &bb)
Generate a random vector in a box with uniform density.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
void randomize_particles(const ParticlesList &ps, const BoundingVolume &bv)
Definition: randomizing.h:32
VectorD< 3 > Vector3D
Definition: VectorD.h:395