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