home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.19.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
doc
examples
core
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
import
sys
9
10
IMP.setup_from_argv
(sys.argv,
"randomize rigid body"
)
11
12
m =
IMP.Model
()
13
p =
IMP.Particle
(m)
14
rbd =
IMP.core.RigidBody.setup_particle
(p,
IMP.algebra.ReferenceFrame3D
())
15
translation =
IMP.algebra.get_random_vector_in
(
16
IMP.algebra.get_unit_bounding_box_3d())
17
18
# we don't yet have Python code to generate a nearby rotation
19
rotation =
IMP.algebra.get_random_rotation_3d
()
20
transformation =
IMP.algebra.Transformation3D
(rotation, translation)
21
# Option 1:
22
# note, this overwrites the existing position
23
rbd.set_reference_frame(
IMP.algebra.ReferenceFrame3D
(transformation))
24
# Option 2:
25
# perturb the existing transformation
26
composed_tr =
IMP.algebra.compose
(
27
rbd.get_reference_frame().get_transformation_to(), transformation)
28
rbd.set_reference_frame(
IMP.algebra.ReferenceFrame3D
(composed_tr))
29
# Alternative to Option 2:
30
IMP.core.transform
(rbd, transformation)
IMP::algebra::Transformation3D
Simple 3D transformation class.
Definition:
Transformation3D.h:37
IMP::setup_from_argv
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
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:22
IMP::Model
Class for storing model, its restraints, constraints, and particles.
Definition:
Model.h:86
IMP::core::transform
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
IMP::algebra::compose
Transformation3D compose(const Transformation3D &a, const Transformation3D &b)
Compose two transformations.
Definition:
Transformation3D.h:154
IMP::core
Basic functionality that is expected to be used by a wide variety of IMP users.
IMP::algebra
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
IMP::Particle
Class to handle individual particles of a Model object.
Definition:
Particle.h:43
IMP::core::RigidBody::setup_particle
static RigidBody setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor ps)
Definition:
rigid_bodies.h:180