Пример #1
0
    def test_rotate(self):
        eq = self.almostEqual

        solid = Solid()
        solid.createSphere((0.0, 0.0, 0.0), 1.0)
        solid.rotate(-pi / 2.0, (0.0, 1.0, 0.0), (1.0, 1.0, 0.0))
        eq(solid.centreOfMass(), (1.0, 0.0, -1.0))
Пример #2
0
    def test_scale(self):
        eq = self.assertAlmostEqual

        scale = 0.5
        solid = Solid()
        solid.createSphere((0.0, 0.0, 0.0), 1.0)
        solid.scale((0.0, 0.0, 0.0), scale)
Пример #3
0
    def test_centreOfMass(self):
        eq = self.almostEqual

        solid = Solid()
        solid.createSphere((0.0, 0.0, 0.0), 1.0)

        eq(solid.centreOfMass(), (0.0, 0.0, 0.0))
Пример #4
0
    def test_translate(self):
        eq = self.almostEqual

        solid = Solid()
        solid.createSphere((0.0, 0.0, 0.0), 1.0)
        solid.translate((1.0, 2.0, 3.0))
        eq(solid.centreOfMass(), (1.0, 2.0, 3.0))
Пример #5
0
    def test_scale(self):
        eq = self.assertAlmostEqual

        scale = .5
        solid = Solid()
        solid.createSphere((0., 0., 0.), 1.)
        solid.scale((0., 0., 0.), scale)
Пример #6
0
    def test_rotate(self):
        eq = self.almostEqual

        solid = Solid()
        solid.createSphere((0., 0., 0.), 1.)
        solid.rotate(-pi / 2., (0., 1., 0.), (1., 1., 0.))
        eq(solid.centreOfMass(), (1., 0., -1.))
Пример #7
0
    def test_translate(self):
        eq = self.almostEqual

        solid = Solid()
        solid.createSphere((0., 0., 0.), 1.)
        solid.translate((1., 2., 3.))
        eq(solid.centreOfMass(), (1., 2., 3.))
Пример #8
0
    def test_centreOfMass(self):
        eq = self.almostEqual

        solid = Solid()
        solid.createSphere((0., 0., 0.), 1.)

        eq(solid.centreOfMass(), (0., 0., 0.))
Пример #9
0
    def test_createSphere(self):
        eq = self.assertAlmostEqual

        self.assertRaises(OCCError, Solid().createSphere, (0.0, 0.0, 0.0), 0.0)
        self.assertRaises(OCCError, Solid().createSphere, (0.0, 0.0, 0.0), -1.0)

        solid = Solid()
        solid.createSphere((0.0, 0.0, 0.0), 1.0)

        eq(solid.area(), 4.0 * pi, places=3)
        eq(solid.volume(), 4.0 / 3.0 * pi, places=3)
Пример #10
0
    def test_createSphere(self):
        eq = self.assertAlmostEqual

        self.assertRaises(OCCError, Solid().createSphere, (0., 0., 0.), 0.)
        self.assertRaises(OCCError, Solid().createSphere, (0., 0., 0.), -1.)

        solid = Solid()
        solid.createSphere((0., 0., 0.), 1.)

        eq(solid.area(), 4. * pi, places=3)
        eq(solid.volume(), 4. / 3. * pi, places=3)