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))
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)
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))
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))
def test_scale(self): eq = self.assertAlmostEqual scale = .5 solid = Solid() solid.createSphere((0., 0., 0.), 1.) solid.scale((0., 0., 0.), scale)
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.))
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.))
def test_centreOfMass(self): eq = self.almostEqual solid = Solid() solid.createSphere((0., 0., 0.), 1.) eq(solid.centreOfMass(), (0., 0., 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)
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)