home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.20.1
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
version 2.20.1
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
import
sys
8
9
IMP.setup_from_argv
(sys.argv,
"geometry"
)
10
11
# we can create some spheres
12
s = []
13
for
i
in
range(0, 10):
14
s.append(
IMP.algebra.Sphere3D
(
IMP.algebra.get_random_vector_in
(
15
IMP.algebra.get_unit_bounding_box_3d()), .1))
16
17
# we can compute a sphere which contains them all
18
enclosing =
IMP.algebra.get_enclosing_sphere
(s)
19
20
print(enclosing.get_contains(s[0]))
21
22
print(
IMP.algebra.get_distance
(s[0], s[1]))
23
# or between the centers
24
print(
IMP.algebra.get_distance
(s[0].get_center(), s[1].get_center()))
25
26
# create a cylinder
27
c =
IMP.algebra.Cylinder3D
(
28
IMP.algebra.Segment3D
(s[0].get_center(), s[1].get_center()), 1)
29
print(c)
30
31
# manipulate bounding boxes
32
bb =
IMP.algebra.BoundingBox3D
()
33
for
si
in
s:
34
bb +=
IMP.algebra.get_bounding_box
(si)