コード例 #1
0
ファイル: test_basics.py プロジェクト: mpopescu/compas
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)
    ]
コード例 #2
0
    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))
コード例 #3
0
    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))
コード例 #4
0
 def cell_center(self):
     vertices = [self.vertex_coordinates(vkey) for vkey in self.vertex]
     return centroid_polyhedron(vertices, self.face)
コード例 #5
0
ファイル: test_core.py プロジェクト: lidiatanasova/compas
def test_centroid_polyhedron(polyhedron, centroid):
    x, y, z = centroid
    assert allclose(centroid_polyhedron(polyhedron), (x, y, z))