surface: Triangulated surface calculations

Routines for calculating surface triangulations and properties of triangulated surfaces.

Surfaces are represented using numpy arrays of vertices (N by 3 array, xyz coodinates, float32), and a numpy array of triangles which are triples of indices into the vertex list (M by 3 array, vertex indices, int32). For surface lighting, normal vectors at each vertex are used (N by 3 array, unit vectors, float32). The vertex, triangle and normal arrays are sometimes called varray, tarray, narray, and sometimes vertices, triangles, normals.

spheres_surface_area(centers, radii, npoints=1000)

Experimental API . Return the exposed surface area of a set of possibly intersecting set of spheres. An array giving the exposed area for each input sphere is returned. The area is computed by an exact method except for round-off errors. The calculation can fail in rare cases where 4 spheres intersect at a point and area values of -1 are returned for spheres where the calculation fails. TODO: The code also computes the areas using numerical approximation, and the results compared with the maximum and average discrepancy printed for debugging. This code is not needed except for debugging.

box_geometry(llb, urf)

Experimental API . Return vertex, normal vector and triangle arrays for box with corners llb and urf (lower-left-back, upper-right-front)

cone_geometry(radius=1, height=1, nc=20, caps=True, points_up=True)

Experimental API . Return vertex, normal vector and triangle arrays for cone geometry with specified radius and height with middle of cone at origin

cylinder_geometry(radius=1, height=1, nz=2, nc=10, caps=True, hexagonal_lattice=False)

Experimental API . Return vertex, normal vector and triangle arrays for cylinder geometry with specified radius and height centered at the origin.

dashed_cylinder_geometry(segments=5, radius=1, height=1, nz=2, nc=10, caps=True)

Experimental API . Return vertex, normal vector and triangle arrays for a sequence of colinear cylinders.

octahedron_geometry()

Experimental API . Return vertex, normal vector and triangle arrays for a radius 1 octahedron.

sphere_geometry(ntri)

Experimental API . Return vertex, normal vector and triangle arrays for unit sphere geometry. Only produces 20, 80, 320, … (multiples of 4) triangle count.

sphere_geometry2(ntri)

Experimental API . Return vertex, normal vector and triangle arrays for unit sphere geometry. Alternate techinque that produces any even number of triangles >= 4. Use in place of sphere_geometry() in new code.

tetrahedron_geometry()

Experimental API . Return vertex, normal vector and triangle arrays for a radius 1 tetrahedron.

enclosed_volume(varray, tarray)

Experimental API . Return the enclosed volume of a surface triangulation specified by vertex and triangle arrays. Also returns the number of holes in the surface, defined as the number of boundary curves.

surface_area(varray, tarray)

Experimental API . Return the surface area of a triangulation specified by vertex and triangle arrays.

surface_volume_and_area(model)

Experimental API . Return the surface area, enclosed volume and number of holes (i.e. boundary curves) of surface triangulations specified by vertex and triangle arrays. All triangles are used even if the surface is masked or clipped. All child models are included. Only Surface models are included.

ses_surface_geometry(xyz, radii, probe_radius=1.4, grid_spacing=0.5, sas=False)

Experimental API . Calculate a solvent excluded molecular surface using a distance grid contouring method. Vertex, normal and triangle arrays are returned. If sas is true then the solvent accessible surface is returned instead.