예제 #1
0
    def test_draw_vector_rotate_around_point(self):
        """Test rotate_around_point in the Vector class in utility.py."""
        vector = Vector()

        expected = [(2.130314698073308, -0.6795287243176937),
                    (-1.1764850602505073, 1.9015475021695778),
                    (1.5611824021515244, 6.655591972503418),
                    (4.125841082615048, 0.3966454487621853)]

        actual = []
        actual.append(vector.rotate_around_point([1, 2], radians=30))
        actual.append(vector.rotate_around_point([1, 2], radians=45))
        actual.append(
            vector.rotate_around_point([1, 2], radians=30, origin=(4, 4)))
        actual.append(
            vector.rotate_around_point([1, 2], radians=45, origin=(4, 4)))

        for i in range(4):
            for j in range(2):
                self.assertAlmostEqualRel(actual[i][j],
                                          expected[i][j],
                                          rel_tol=1e-3)
예제 #2
0
    def test_draw_vector_rotate(self):
        """Test rotate in the Vector class in utility.py."""
        vector = Vector()

        expected = [(2.130314698073308, -0.6795287243176937),
                    (-1.1764850602505073, 1.9015475021695778)]

        actual = []
        actual.append(vector.rotate_around_point([1, 2], radians=30))
        actual.append(vector.rotate_around_point([1, 2], radians=45))

        for i in range(2):
            for j in range(2):
                self.assertAlmostEqualRel(actual[i][j],
                                          expected[i][j],
                                          rel_tol=1e-3)