IMP
2.1.0
The Integrative Modeling Platform
IMP Mainpage
All IMP Modules
Related Pages
Modules
Namespaces
Classes
Files
Examples
Indexes
File List
File Members
IMP
All IMP Modules
All IMP Modules and Applications
Argument Index
Class Examples
Factory Index
Function Examples
Design example
Developer Guide
Installation
Introduction
Mailing lists
ChangeLog
Tools
Dependencies
EMageFit protocol
EMageFit scripts and tools
Integrative docking utility programs
Deprecated List
Modules
Namespaces
Classes
Files
File List
File Members
Examples
Indexes
Class Usage
Class Examples
Class Factories
Function Examples
randomize_rigid_body.py
1
## \example core/randomize_rigid_body.py
2
# This fragments 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
from
IMP.algebra
import
ReferenceFrame3D
9
from
IMP.algebra
import
Transformation3D
10
11
m =
IMP.kernel.Model
()
12
p =
IMP.kernel.Particle
(m)
13
rbd =
IMP.core.RigidBody.setup_particle
(p, ReferenceFrame3D())
14
translation =
IMP.algebra.get_random_vector_in
(
15
IMP.algebra.get_unit_bounding_box_3d())
16
17
# we don't yet have python code to generate a nearby rotation
18
rotation =
IMP.algebra.get_random_rotation_3d
()
19
transformation = Transformation3D(rotation, translation)
20
# Option 1:
21
# note, this overwrites the existing position
22
# The True is to transform the members now rather than wait for a
23
# score state
24
rbd.set_reference_frame(ReferenceFrame3D(transformation))
25
# Option 2:
26
# perturb the existing transformation
27
composed_tr = IMP.algebra.compose \
28
(rbd.get_reference_frame().get_transformation_to(),
29
transformation)
30
rbd.set_reference_frame(ReferenceFrame3D(composed_tr))
31
# Alternative to Option 2:
32
IMP.core.transform
(rbd, transformation)
IMP::core::RigidBody::setup_particle
static RigidBody setup_particle(kernel::Model *m, ParticleIndex pi, kernel::ParticleIndexesAdaptor ps)
Definition:
rigid_bodies.h:125
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::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/declare_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/declare_Model.h:72