IMP
2.4.0
The Integrative Modeling Platform
IMP Mainpage
Modules
Classes
Examples
algebra/geometry.py
IMP.algebra
provides a set of geometric primitives and basic operations on them.
1
## \example algebra/geometry.py
2
# IMP.algebra provides a set of geometric primitives and basic operations
3
# on them.
4
5
from
__future__
import
print_function
6
import
IMP.algebra
7
8
# we can create some spheres
9
s = []
10
for
i
in
range(0, 10):
11
s.append(
IMP.algebra.Sphere3D
(
12
IMP.algebra.get_random_vector_in
(IMP.algebra.get_unit_bounding_box_3d()), .1))
13
14
# we can compute a sphere which contains them all
15
enclosing =
IMP.algebra.get_enclosing_sphere
(s)
16
17
print(enclosing.get_contains(s[0]))
18
19
print(
IMP.algebra.get_distance
(s[0], s[1]))
20
# or between the centers
21
print(
IMP.algebra.get_distance
(s[0].get_center(), s[1].get_center()))
22
23
# create a cylinder
24
c =
IMP.algebra.Cylinder3D
(
25
IMP.algebra.Segment3D
(s[0].get_center(), s[1].get_center()), 1)
26
print(c)
27
28
# manipulate bounding boxes
29
bb =
IMP.algebra.BoundingBox3D
()
30
for
si
in
s:
31
bb +=
IMP.algebra.get_bounding_box
(si)