Ejemplo n.º 1
0
    def test_cylinder_volume(self, mock_area):
        """
        Test that we can calculate the volume of a cylinder
        """
        mock_area.return_value = 5

        cylinder = Cylinder(radius=2, height=7)

        self.assertEqual(cylinder.volume(), 35)
Ejemplo n.º 2
0
    def test_cylinder_volume(self, mock_area):
        """
        Test that we can calculate the volume of a cylinder
        """
        mock_area.return_value = 5

        cylinder = Cylinder(radius=2, height=7)

        self.assertEqual(cylinder.volume(), 35)
Ejemplo n.º 3
0
    def test_cylinder_area_of_base(self):
        """
        Test that we can calculate the area of a cylinder's base
        """
        cylinder = Cylinder(radius=2, height=7)

        area = cylinder.area_of_base()

        self.assertAlmostEqual(area, 12.6, places=1)
Ejemplo n.º 4
0
    def test_cylinder_area_of_base(self):
        """
        Test that we can calculate the area of a cylinder's base
        """
        cylinder = Cylinder(radius=2, height=7)

        area = cylinder.area_of_base()

        self.assertAlmostEqual(area, 12.6, places=1)
Ejemplo n.º 5
0
 def testProperties(self):
     """Test cylinder properties"""
     c = Cylinder(D=2.0, L=4.0)
     self.assertAlmostEqual(c.Atop(), 3.142, places=2)
     self.assertAlmostEqual(c.Abottom(), 3.142, places=2)
     self.assertAlmostEqual(c.A(), 31.416, places=2)
     self.assertAlmostEqual(c.Aside(), 25.133, places=2)
     self.assertAlmostEqual(c.V(), 12.566, places=2)
Ejemplo n.º 6
0
    vs, fs = sphere.to_vertices_and_faces(u=12, v=12)
    sphere_mesh = Mesh.from_vertices_and_faces(vs, fs)
    vertex_spheres.append(sphere_mesh)

spheres_mesh = meshes_join(vertex_spheres)
torus_and_spheres = meshes_join([spheres_mesh, torus_mesh])

edge_cylinders = []

for e in torus_mesh.edges():

    e_mid = torus_mesh.edge_midpoint(e[0], e[1])
    e_dir = torus_mesh.edge_direction(e[0], e[1])
    e_len = torus_mesh.edge_length(e[0], e[1])
    circle = Circle((e_mid, e_dir), 0.1)
    cylinder = Cylinder(circle, e_len)
    vs, fs = cylinder.to_vertices_and_faces(u=16)
    cyl_mesh = Mesh.from_vertices_and_faces(vs, fs)
    edge_cylinders.append(cyl_mesh)

all_cylinders = meshes_join(edge_cylinders)

atomium = meshes_join([all_cylinders, spheres_mesh])

point = [35, 0.5, 0]
T = Translation.from_vector(point)
atomium.transform(T)

artist10 = MeshArtist(atomium, layer="10 atomium")
artist10.clear_layer()
artist10.draw_mesh()
Ejemplo n.º 7
0
def step_create_cylinder_c(context):
    context.c = Cylinder()
Ejemplo n.º 8
0
def step_create_cylinder_c_from_yaml(context):
    context.c = Cylinder.from_yaml(context.data)