IMP  2.4.0
The Integrative Modeling Platform
algebra/geometry.py
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
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
25  IMP.algebra.Segment3D(s[0].get_center(), s[1].get_center()), 1)
26 print(c)
27 
28 # manipulate bounding boxes
30 for si in s:
BoundingBoxD< 3 > get_bounding_box(const Geometry &)
Compute the bounding box of any geometric object.
Represent a cylinder in 3D.
Definition: Cylinder3D.h:26
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
Simple implementation of segments in 3D.
Definition: Segment3D.h:24
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
double get_distance(const VectorD< D > &v1, const VectorD< D > &v2)
Compute the distance between two vectors.
Definition: VectorD.h:209
Sphere3D get_enclosing_sphere(const Vector3Ds &ss)
Return a sphere containing the listed vectors.