Ejemplo n.º 1
0
    def from_polyhedron(cls, f):
        """Construct a mesh from a platonic solid.

        Parameters
        ----------
        f : {4, 6, 8, 12, 20}
            The number of faces.

        Returns
        -------
        :class:`compas.datastructures.Mesh`
            A mesh object.

        """
        p = Polyhedron.from_platonicsolid(f)
        return cls.from_vertices_and_faces(p.vertices, p.faces)
Ejemplo n.º 2
0
    def from_polyhedron(cls, f):
        """Construct a mesh from a platonic solid.

        Parameters
        ----------
        f : int
            The number of faces.
            Should be one of ``4, 6, 8, 12, 20``.

        Returns
        -------
        Mesh
            A mesh object.

        Examples
        --------
        >>>
        """
        p = Polyhedron.from_platonicsolid(f)
        return cls.from_vertices_and_faces(p.vertices, p.faces)
Ejemplo n.º 3
0
def test_centroid_points_fails_when_input_is_not_list_of_lists(points):
    with pytest.raises(TypeError):
        centroid_points(points)


@pytest.mark.parametrize(("points"), [
    [[0.0, 0.0, 0.0], [0.0, 0.0]],
    [[0.0, 0.0]],
])
def test_centroid_points_fails_when_input_is_not_complete_points(points):
    with pytest.raises(ValueError):
        centroid_points(points)


@pytest.mark.parametrize(("polyhedron", "centroid"), [
    (Polyhedron.from_platonicsolid(6), [0.0, 0.0, 0.0]),
])
def test_centroid_polyhedron(polyhedron, centroid):
    x, y, z = centroid
    assert allclose(centroid_polyhedron(polyhedron), (x, y, z))


# ==============================================================================
# size
# ==============================================================================


@pytest.mark.parametrize(("polyhedron", "volume"),
                         [(Polyhedron.from_platonicsolid(6), None)])
def test_volume_polyhedron(polyhedron, volume):
    if volume is None: