def test_reflection_and_rotation(self):
     transformer = Transformation(Point(1.0, 1.0), angle=90.0, reflect="y")
     old_point = Point(1.0, 0.0)
     transformer._reflect(old_point)
     transformer._rotate(old_point)
     self.assertAlmostEqual(old_point.x, 1.0)
     self.assertAlmostEqual(old_point.y, 0.0)
Exemple #2
0
    def __init__(self, center_of_rotation, **kwargs):
        Component.stats[self.__class__.__name__] += 1

        super(Component, self).__init__(center_of_rotation, **kwargs)
        Transformation.__init__(self, center_of_rotation, **kwargs)

        self.name = process_name(None, kwargs)
        self.label_string = self.name

        self.graph = Graph(name=self.name)
        self._get_nodes()
        self._connect_nodes()

        self.face_color = process_face_color((1.0, 1.0, 1.0), kwargs)
        self.edge_color = process_edge_color((0.0, 0.0, 0.0), kwargs)
        self.line_width = process_line_width(1.5, kwargs)
        self.patch = None

        self._points = []
        self._connections = []
Exemple #3
0
  def __init__(self, center_of_rotation, **kwargs):
    Component.stats[self.__class__.__name__] += 1

    super(Component, self).__init__(center_of_rotation, **kwargs)
    Transformation.__init__(self, center_of_rotation, **kwargs)

    self.name = process_name(None, kwargs)
    self.label_string = self.name

    self.graph = Graph(name = self.name)
    self._get_nodes()
    self._connect_nodes()

    self.face_color = process_face_color((1.0, 1.0, 1.0), kwargs)
    self.edge_color = process_edge_color((0.0, 0.0, 0.0), kwargs)
    self.line_width = process_line_width(1.5, kwargs)
    self.patch = None

    self._points = []
    self._connections = []
    def test_reflection(self):
        transformer = Transformation(Point(), angle=90.0, reflect="x")
        old_point = Point(0.0, 1.0)
        transformer._reflect(old_point)
        self.assertEqual(old_point.x, 0.0)
        self.assertEqual(old_point.y, -1.0)

        transformer = Transformation(Point(), angle=90.0, reflect="y")
        old_point = Point(1.0, 0.0)
        transformer._reflect(old_point)
        self.assertEqual(old_point.x, -1.0)
        self.assertEqual(old_point.y, 0.0)