IMP
2.3.1
The Integrative Modeling Platform
IMP Mainpage
Modules
Applications
Related Pages
Groups
Classes
Files
Examples
Indexes
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
import
IMP.algebra
6
7
# we can create some spheres
8
s = []
9
for
i
in
range(0, 10):
10
s.append(
IMP.algebra.Sphere3D
(
11
IMP.algebra.get_random_vector_in
(IMP.algebra.get_unit_bounding_box_3d()), .1))
12
13
# we can compute a sphere which contains them all
14
enclosing =
IMP.algebra.get_enclosing_sphere
(s)
15
16
print
enclosing.get_contains(s[0])
17
18
print
IMP.algebra.get_distance
(s[0], s[1])
19
# or between the centers
20
print
IMP.algebra.get_distance
(s[0].get_center(), s[1].get_center())
21
22
# create a cylinder
23
c =
IMP.algebra.Cylinder3D
(
24
IMP.algebra.Segment3D
(s[0].get_center(), s[1].get_center()), 1)
25
print
c
26
27
# manipulate bounding boxes
28
bb =
IMP.algebra.BoundingBox3D
()
29
for
si
in
s:
30
bb +=
IMP.algebra.get_bounding_box
(si)