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