IMP
2.2.0
The Integrative Modeling Platform
IMP Mainpage
All IMP Modules
Related Pages
Modules
Namespaces
Classes
Files
Examples
Indexes
File List
File Members
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
9
m =
IMP.kernel.Model
()
10
p =
IMP.kernel.Particle
(m)
11
rbd =
IMP.core.RigidBody.setup_particle
(p,
IMP.algebra.ReferenceFrame3D
())
12
translation =
IMP.algebra.get_random_vector_in
(
13
IMP.algebra.get_unit_bounding_box_3d())
14
15
# we don't yet have python code to generate a nearby rotation
16
rotation =
IMP.algebra.get_random_rotation_3d
()
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)
IMP::algebra::Transformation3D
Simple 3D transformation class.
Definition:
Transformation3D.h:30
IMP::core::RigidBody::setup_particle
static RigidBody setup_particle(kernel::Model *m, ParticleIndex pi, kernel::ParticleIndexesAdaptor ps)
Definition:
rigid_bodies.h:168
IMP::algebra::get_random_rotation_3d
Rotation3D get_random_rotation_3d(const Rotation3D ¢er, double distance)
Pick a rotation at random near the provided one.
IMP::algebra::get_random_vector_in
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
IMP::algebra::ReferenceFrame3D
A reference frame in 3D.
Definition:
ReferenceFrame3D.h:20
IMP::core::transform
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
IMP::kernel::Particle
Class to handle individual model particles.
Definition:
kernel/Particle.h:34
IMP::core
See IMP.core for more information.
Definition:
AngleRestraint.h:19
IMP::algebra
See IMP.algebra for more information.
Definition:
algebra_config.h:113
IMP::kernel::Model
Class for storing model, its restraints, constraints, and particles.
Definition:
kernel/Model.h:72