def test_centroid_polyhedron(polyhedron, centroid): x, y, z = centroid assert centroid_polyhedron(polyhedron) == [ pytest.approx(x, 0.001), pytest.approx(y, 0.001), pytest.approx(z, 0.001) ]
def center(self): """Compute the center of mass of the block. Returns ------- point The center of mass of the block. """ vertices = [self.vertex_coordinates(key) for key in self.vertices()] faces = [self.face_vertices(fkey) for fkey in self.faces()] return centroid_polyhedron((vertices, faces))
def cell_center(self, cell): """Compute the location of the center of mass of a cell. Parameters ---------- cell : hashable The identifier of the cell. Returns ------- list The coordinates of the center of mass. """ vertices, faces = self.cell_to_vertices_and_faces(cell) return centroid_polyhedron((vertices, faces))
def cell_center(self): vertices = [self.vertex_coordinates(vkey) for vkey in self.vertex] return centroid_polyhedron(vertices, self.face)
def test_centroid_polyhedron(polyhedron, centroid): x, y, z = centroid assert allclose(centroid_polyhedron(polyhedron), (x, y, z))