IMP  2.3.1
The Integrative Modeling Platform
randomize_rigid_body.py
1 ## \example core/randomize_rigid_body.py
2 # This fragment shows how to either perturb or set the orientation of a rigid
3 # body randomly.
4 
5 import IMP.core
6 import IMP.algebra
7 import IMP
8 
13  IMP.algebra.get_unit_bounding_box_3d())
14 
15 # we don't yet have python code to generate a nearby rotation
17 transformation = IMP.algebra.Transformation3D(rotation, translation)
18 # Option 1:
19 # note, this overwrites the existing position
20 rbd.set_reference_frame(IMP.algebra.ReferenceFrame3D(transformation))
21 # Option 2:
22 # perturb the existing transformation
23 composed_tr = IMP.algebra.compose \
24  (rbd.get_reference_frame().get_transformation_to(),
25  transformation)
26 rbd.set_reference_frame(IMP.algebra.ReferenceFrame3D(composed_tr))
27 # Alternative to Option 2:
28 IMP.core.transform(rbd, transformation)
Simple 3D transformation class.
static RigidBody setup_particle(kernel::Model *m, ParticleIndex pi, kernel::ParticleIndexesAdaptor ps)
Definition: rigid_bodies.h:168
Rotation3D get_random_rotation_3d(const Rotation3D &center, double distance)
Pick a rotation at random near the provided one.
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
A reference frame in 3D.
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
Class to handle individual model particles.
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73