IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
5import IMP.algebra
6import sys
7
8IMP.setup_from_argv(sys.argv, "geometry")
9
10# we can create some spheres
11s = []
12for i in range(0, 10):
14 IMP.algebra.get_unit_bounding_box_3d()), .1))
15
16# we can compute a sphere which contains them all
18
19print(enclosing.get_contains(s[0]))
20
21print(IMP.algebra.get_distance(s[0], s[1]))
22# or between the centers
23print(IMP.algebra.get_distance(s[0].get_center(), s[1].get_center()))
24
25# create a cylinder
27 IMP.algebra.Segment3D(s[0].get_center(), s[1].get_center()), 1)
28print(c)
29
30# manipulate bounding boxes
32for si in s:
Represent a cylinder in 3D.
Definition Cylinder3D.h:27
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...
Sphere3D get_enclosing_sphere(const Sphere3Ds &ss)
Return a sphere containing the listed spheres.
BoundingBoxD< D > get_bounding_box(const GridD< D, Storage, Value, Embedding > &g)
Definition GridD.h:406
VectorD< D > get_random_vector_in(const BoundingBoxD< D > &bb)
Generate a random vector in a box with uniform density.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.