diff options
author | Anthony LaTorre <devnull@localhost> | 2013-01-01 18:50:57 -0600 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:39 -0700 |
commit | 53d300df2287a43d97420f0f47710f4d5ab2726a (patch) | |
tree | 480d8fc8938dfd4117b591b1726319cec86dbc47 | |
parent | f38ca570ff5959c5f5e9a6d6a4c31c61fc8f0a44 (diff) | |
download | chroma-53d300df2287a43d97420f0f47710f4d5ab2726a.tar.gz chroma-53d300df2287a43d97420f0f47710f4d5ab2726a.tar.bz2 chroma-53d300df2287a43d97420f0f47710f4d5ab2726a.zip |
add get_triangle_centers() method to mesh; this method is useful for selecting certain sections of a mesh to apply surfaces to. solids are by default partially transparent.
-rw-r--r-- | chroma/geometry.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/chroma/geometry.py b/chroma/geometry.py index 238a701..3dc253e 100644 --- a/chroma/geometry.py +++ b/chroma/geometry.py @@ -41,6 +41,10 @@ class Mesh(object): if remove_duplicate_vertices: self.remove_duplicate_vertices() + def get_triangle_centers(self): + "Returns the x,y,z coordinate of the center of each triangle." + return np.mean(self.assemble(),axis=1) + def get_bounds(self): "Return the lower and upper bounds for the mesh as a tuple." return np.min(self.vertices, axis=0), np.max(self.vertices, axis=0) @@ -99,7 +103,7 @@ class Mesh(object): class Solid(object): """Solid object attaches materials, surfaces, and colors to each triangle in a Mesh object.""" - def __init__(self, mesh, material1=None, material2=None, surface=None, color=0xffffff): + def __init__(self, mesh, material1=None, material2=None, surface=None, color=0x33ffffff): self.mesh = mesh if np.iterable(material1): |