Exemplo n.º 1
0
 def testCircleContainsCircleInstanceMethod(self):
     c = Circle(radius=2)
     a = Circle(center=[1, 0])
     b = Circle(center=[3, 3], radius=3)
     self.assertTrue(c in c, '{!r} in {!r}'.format(c, c))
     self.assertTrue(a in c, '{!r} in {!r}'.format(a, c))
     self.assertFalse(b in c, '{!r} in {!r}'.format(b, c))
Exemplo n.º 2
0
 def testCircleSettingRadiusAttributeWithNonNumbers(self):
     for fail in [[], {}, ()]:
         c = Circle()
         with self.assertRaises(TypeError):
             c.radius = fail
     with self.assertRaises(ValueError):
         c.radius = 'fail'
Exemplo n.º 3
0
    def testCircleDoesIntersectLineInstanceMethod(self):
        c = Circle()

        l = Line(c.a, c.a_neg)

        with self.assertRaises(NotImplementedError):
            c.doesIntersect(l)
Exemplo n.º 4
0
    def testCircleDoesIntersectLineInstanceMethod(self):
        c = Circle()

        l = Line(c.a, c.a_neg)

        with self.assertRaises(NotImplementedError):
            c.doesIntersect(l)
Exemplo n.º 5
0
 def testCircleSettingRadiusAttributeWithNonNumbers(self):
     for fail in [[], {}, ()]:
         c = Circle()
         with self.assertRaises(TypeError):
             c.radius = fail
     with self.assertRaises(ValueError):
         c.radius = 'fail'
Exemplo n.º 6
0
    def testCircleDoesIntersectCircleInstanceMethod(self):
        c = Circle()
        a = Circle(center=[c.radius, 0])
        b = Circle(center=[2, 2])

        self.assertTrue(c.doesIntersect(c))
        self.assertTrue(c.doesIntersect(a))
        self.assertFalse(c.doesIntersect(b))
Exemplo n.º 7
0
    def testCircleSettingCenterAttribute(self):
        p = Point.gaussian()
        c = Circle()
        c.center = p
        self.assertListEqual(c.center.xyz, p.xyz)

        c = Circle(p)
        c.center = None
        self.assertListEqual(c.center.xyz, [0] * 3)
Exemplo n.º 8
0
    def testCircleContainsSegmentInstanceMethod(self):
        c = Circle(radius=2)
        s = Segment([-1, 0], [1, 0])
        self.assertTrue(s in c, '{!r} in {!r}'.format(s, c))

        s = Segment(c.a, c.a_neg)
        self.assertTrue(s in c, '{!r} in {!r}'.format(s, c))
Exemplo n.º 9
0
 def testCircleContainsPointInstanceMethod(self):
     c = Circle(radius=2)
     self.assertTrue(c.center in c)
     for v in c.vertices.values():
         self.assertTrue(v in c, '{!r} in {!r}'.format(v, c))
     for v in c.vertices.values():
         v *= 2
         self.assertFalse(v in c, '{!r} in {!r}'.format(v, c))
Exemplo n.º 10
0
    def testCircleDoesIntersectCircleInstanceMethod(self):
        c = Circle()
        a = Circle(center=[c.radius, 0])
        b = Circle(center=[2, 2])

        self.assertTrue(c.doesIntersect(c))
        self.assertTrue(c.doesIntersect(a))
        self.assertFalse(c.doesIntersect(b))
Exemplo n.º 11
0
    def testCircleSettingCenterAttribute(self):
        p = Point.gaussian()
        c = Circle()
        c.center = p
        self.assertListEqual(c.center.xyz, p.xyz)

        c = Circle(p)
        c.center = None
        self.assertListEqual(c.center.xyz, [0] * 3)
Exemplo n.º 12
0
    def _update_joystick_head_position_on_canvas(self):
        """
        This function draws joystick with new position, on canvas.
        :return: None
        """
        draw_obj_in_new_position = self.coords
        joystick_head_circle = Circle(self._actual_joystick_position,
                                      self._joystick_head_radius)
        joystick_bottom_circle = Circle(self._start_joystick_position,
                                        self._joystick_bottom_radius)

        draw_obj_in_new_position(self._joystick_head,
                                 joystick_head_circle.get_spanning_points())
        draw_obj_in_new_position(self._joystick_bottom,
                                 joystick_bottom_circle.get_spanning_points())
Exemplo n.º 13
0
 def testCircleCreationWithNoArgumentsOrKeywords(self):
     c = Circle()
     self.assertIsInstance(c, Circle)
     self.assertListEqual(c.center.xyz, [0] * 3)
     self.assertEqual(c.radius, 1)
Exemplo n.º 14
0
 def testCircleSettingRadiusAttributeWithNumbers(self):
     for number in [2, 3.4, '5.6']:
         c = Circle()
         c.radius = number
         self.assertEqual(c.radius, float(number))
Exemplo n.º 15
0
 def testCircleDoesIntersectGarbageInstanceMethod(self):
     c = Circle()
     for fail in [None, [], {}, (), 'fail', 1]:
         with self.assertRaises(TypeError):
             c.doesIntersect(fail)
Exemplo n.º 16
0
 def testCircleCreationWithCenterAndRadiusArguments(self):
     p = Point.gaussian()
     c = Circle(p, 2)
     self.assertIsInstance(c, Circle)
     self.assertListEqual(c.center.xyz, p.xyz)
     self.assertEqual(c.radius, 2)
Exemplo n.º 17
0
 def testCircleSettingRadiusAttributeWithNumbers(self):
     for number in [2, 3.4, '5.6']:
         c = Circle()
         c.radius = number
         self.assertEqual(c.radius, float(number))
Exemplo n.º 18
0
 def testCircleAreaAttributeGetter(self):
     c = Circle()
     self.assertEqual(c.area, math.pi)
Exemplo n.º 19
0
 def testCircleCreationWithKeywordsReversed(self):
     p = Point.gaussian()
     c = Circle(radius=3, center=p)
     self.assertIsInstance(c, Circle)
     self.assertListEqual(c.center.xyz, p.xyz)
     self.assertEqual(c.radius, 3)
Exemplo n.º 20
0
 def testCircleCreationWithOnlyCenterKeyword(self):
     p = Point.gaussian()
     c = Circle(center=p)
     self.assertIsInstance(c, Circle)
     self.assertListEqual(c.center.xyz, p.xyz)
     self.assertEqual(c.radius, 1)
Exemplo n.º 21
0
 def testCircleCreationWithOnlyRadiusKeyword(self):
     c = Circle(radius=2)
     self.assertIsInstance(c, Circle)
     self.assertListEqual(c.center.xyz, [0] * 3)
     self.assertEqual(c.radius, 2)
Exemplo n.º 22
0
 def testCircleDiameterAttributeGetter(self):
     c = Circle()
     self.assertEqual(c.diameter, 2)
Exemplo n.º 23
0
 def testCircleCreationWithEmptyContainersAsCenterArgument(self):
     for thing in [None, [], (), {}]:
         c = Circle(thing)
         self.assertIsInstance(c, Circle)
         self.assertListEqual(c.center.xyz, [0] * 3)
         self.assertEqual(c.radius, 1)
Exemplo n.º 24
0
 def testCircleDoesIntersectGarbageInstanceMethod(self):
     c = Circle()
     for fail in [None, [], {}, (), 'fail', 1]:
         with self.assertRaises(TypeError):
             c.doesIntersect(fail)
Exemplo n.º 25
0
 def testCircleInscribedInTriangle(self):
     with self.assertRaises(NotImplementedError):
         Circle.inscribedInTriangle(Triangle())
Exemplo n.º 26
0
 def testCircleCircumfrenceAttributeGetter(self):
     c = Circle()
     self.assertEqual(c.circumfrence, math.pi * 2)
Exemplo n.º 27
0
 def testCircleCenterAttributeGetter(self):
     c = Circle()
     self.assertIsInstance(c.center, Point)
     self.assertListEqual(c.center.xyz, [0] * 3)
Exemplo n.º 28
0
 def testCircleCreationWithAllKeywords(self):
     p = Point.gaussian()
     c = Circle(center=p, radius=2)
     self.assertIsInstance(c, Circle)
     self.assertListEqual(c.center.xyz, p.xyz)
     self.assertEqual(c.radius, 2)
Exemplo n.º 29
0
 def testCircleRadiusAttributeGetter(self):
     c = Circle()
     self.assertIsInstance(c.radius, float)
     self.assertEqual(c.radius, 1)
Exemplo n.º 30
0
 def testCircleInscribedInTriangle(self):
     with self.assertRaises(NotImplementedError):
         Circle.inscribedInTriangle(Triangle())