This example shows how to create and use a custom hierarchy of particles.
tr= IMP.core.HierarchyTraits("my hierarchy")
pd= IMP.core.Hierarchy.setup_particle(parent_particle, tr)
for p in children_particles:
cd= IMP.core.Hierarchy.setup_particle(p, tr)
pd.add_child(cd)
pd.show()
|
This fragments shows how to either perturb or set the orientation of a rigid body randomly.
# Assume p is a RigidBody Particle
rbd= IMP.core.RigidBody(p)
translation=IMP.algebra.get_random_vector_in(IMP.algebra.Vector3D(0,0,0),
10.0)
# we don't yet have python code to generate a nearby rotation
rotation= IMP.algebra.get_random_rotation_3d()
transformation= IMP.algebra.Transformation3D(rotation, translation)
# note, this overwrites the existing position
# The True is to transform the members now rather than wait for a
# score state
rbd.set_transformation(transformation)
# to instead perturb the existing transformation instead do
rbd.set_transformation(IMP.algebra.compose(rbd.get_transformation(),
transformation))
|