def test_shell_Sphere_generate_contains(self): from lepton.domain import Sphere sphere = Sphere((1, -2, 4), 3, 2) for i in range(20): x, y, z = sphere.generate() mag = (x - 1)**2 + (y + 2)**2 + (z - 4)**2 self.failUnless(4 <= mag <= 9, ((x, y, z), mag)) self.failUnless((x, y, z) in sphere, (x, y, z)) self.failUnless((3, -2, 4) in sphere) self.failUnless((1, 1, 4) in sphere) self.failUnless((1, -2, 1.5) in sphere) self.failIf((1, -2, 4) in sphere) self.failIf((5, 1, 7) in sphere)
def test_shell_Sphere_generate_contains(self): from lepton.domain import Sphere sphere = Sphere((1, -2, 4), 3, 2) for i in range(20): x, y, z = sphere.generate() mag = (x - 1)**2 + (y + 2)**2 + (z - 4)**2 self.failUnless(4 <= mag <= 9, ((x, y, z), mag)) self.failUnless((x, y, z) in sphere, (x, y ,z)) self.failUnless((3, -2, 4) in sphere) self.failUnless((1, 1, 4) in sphere) self.failUnless((1, -2, 1.5) in sphere) self.failIf((1, -2, 4) in sphere) self.failIf((5, 1, 7) in sphere)
def test_solid_Sphere_generate_contains(self): from lepton.domain import Sphere sphere = Sphere((0, 1, 2), 2) for i in range(20): x, y, z = sphere.generate() mag = x**2 + (y - 1)**2 + (z - 2)**2 self.failUnless(mag <= 4, ((x, y, z), mag)) self.failUnless((x, y, z) in sphere, (x, y, z)) self.failUnless((0, 1, 2) in sphere) self.failUnless((1, 2, 3) in sphere) self.failUnless((2, 1, 2) in sphere) self.failUnless((-2, 1, 2) in sphere) self.failIf((2.1, 1, 2) in sphere) self.failIf((-2.1, 1, 2) in sphere)
def test_solid_Sphere_generate_contains(self): from lepton.domain import Sphere sphere = Sphere((0, 1, 2), 2) for i in range(20): x, y, z = sphere.generate() mag = x**2 + (y - 1)**2 + (z - 2)**2 self.failUnless(mag <= 4, ((x, y, z), mag)) self.failUnless((x, y, z) in sphere, (x, y ,z)) self.failUnless((0, 1, 2) in sphere) self.failUnless((1, 2, 3) in sphere) self.failUnless((2, 1, 2) in sphere) self.failUnless((-2, 1, 2) in sphere) self.failIf((2.1, 1, 2) in sphere) self.failIf((-2.1, 1, 2) in sphere)