IMP  2.2.0
The Integrative Modeling Platform
core/randomize_rigid_body.py

This fragment shows how to either perturb or set the orientation of a rigid body randomly.

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)