Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@caching.cache_decorator
def mass_properties(self):
"""
Returns the mass properties of the current mesh.
Assumes uniform density, and result is probably garbage if mesh
isn't watertight.
Returns
----------
properties : dict
With keys:
'volume' : in global units^3
'mass' : From specified density
'density' : Included again for convenience (same as kwarg density)
'inertia' : Taken at the center of mass and aligned with global
coordinate system
@caching.cache_decorator
def bounds(self):
points = self.points
bounds = np.array([points.min(axis=0), points.max(axis=0)])
bounds.flags.writeable = False
return bounds
@caching.cache_decorator
def extents(self):
bounds = self.bounds
extents = bounds[1] - bounds[0]
extents.flags.writeable = False
return extents
@caching.cache_decorator
def face_angles_sparse(self):
"""
A sparse matrix representation of the face angles.
Returns
----------
sparse : scipy.sparse.coo_matrix
Float sparse matrix with with shape:
(len(self.vertices), len(self.faces))
"""
angles = curvature.face_angles_sparse(self)
return angles
@caching.cache_decorator
def extents(self):
"""
Return the axis aligned box size of the current scene.
Returns
----------
extents: (3,) float, bounding box sides length
"""
return np.diff(self.bounds, axis=0).reshape(-1)
@caching.cache_decorator
def face_adjacency_tree(self):
"""
An R-tree of face adjacencies.
Returns
--------
tree: rtree.index
Where each edge in self.face_adjacency has a
rectangular cell
"""
# the (n,6) interleaved bounding box for every line segment
segment_bounds = np.column_stack((
self.vertices[self.face_adjacency_edges].min(axis=1),
self.vertices[self.face_adjacency_edges].max(axis=1)))
tree = util.bounds_tree(segment_bounds)
return tree
@caching.cache_decorator
def edges_sorted(self):
"""
Edges sorted along axis 1
Returns
----------
edges_sorted : (n, 2)
Same as self.edges but sorted along axis 1
"""
edges_sorted = np.sort(self.edges, axis=1)
return edges_sorted
@caching.cache_decorator
def facets_normal(self):
"""
Return the normal of each facet
Returns
---------
normals: (len(self.facets), 3) float
A unit normal vector for each facet
"""
if len(self.facets) == 0:
return np.array([])
area_faces = self.area_faces
# the face index of the largest face in each facet
index = np.array([i[area_faces[i].argmax()]
@caching.cache_decorator
def symmetry(self):
"""
Check whether a mesh has rotational symmetry.
Returns
-----------
symmetry: None No rotational symmetry
'radial' Symmetric around an axis
'spherical' Symmetric around a point
"""
symmetry, axis, section = inertia.radial_symmetry(self)
self._cache['symmetry_axis'] = axis
self._cache['symmetry_section'] = section
return symmetry
@caching.cache_decorator
def face_angles(self):
"""
Returns the angle at each vertex of a face.
Returns
--------
angles : (len(self.faces), 3) float
Angle at each vertex of a face
"""
angles = triangles.angles(self.triangles)
return angles