From 53d300df2287a43d97420f0f47710f4d5ab2726a Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Tue, 1 Jan 2013 18:50:57 -0600 Subject: 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. --- chroma/geometry.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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): -- cgit