Esempio n. 1
0
    def test_cylinder_length(self):
        from lepton.domain import Cylinder
        cyl = Cylinder((0, 0, 0), (2, 0, 0), 1)
        self.assertEqual(cyl.length, 2)
        self.assertVector(cyl.end_point0, (0, 0, 0))
        self.assertVector(cyl.end_point1, (2, 0, 0))
        cyl = Cylinder((1, 0, -1), (3, 2, 1), 1)
        self.assertAlmostEqual(cyl.length, math.sqrt(12), 5)
        self.assertVector(cyl.end_point0, (1, 0, -1))
        self.assertVector(cyl.end_point1, (3, 2, 1))

        # Changing end points shoud adjust length
        cyl.end_point0 = (3, 0, -1)
        self.assertAlmostEqual(cyl.length, math.sqrt(8), 5)
        cyl.end_point1 = (5, 0, -1)
        self.assertAlmostEqual(cyl.length, 2, 5)
Esempio n. 2
0
	def test_cylinder_length(self):
		from lepton.domain import Cylinder
		cyl = Cylinder((0,0,0), (2,0,0), 1)
		self.assertEqual(cyl.length, 2)
		self.assertVector(cyl.end_point0, (0,0,0))
		self.assertVector(cyl.end_point1, (2,0,0))
		cyl = Cylinder((1,0,-1), (3,2,1), 1)
		self.assertAlmostEqual(cyl.length, math.sqrt(12), 5)
		self.assertVector(cyl.end_point0, (1,0,-1))
		self.assertVector(cyl.end_point1, (3,2,1))

		# Changing end points shoud adjust length
		cyl.end_point0 = (3, 0, -1)
		self.assertAlmostEqual(cyl.length, math.sqrt(8), 5)
		cyl.end_point1 = (5, 0, -1)
		self.assertAlmostEqual(cyl.length, 2, 5)