예제 #1
0
파일: test_surface.py 프로젝트: fudp/bezier
 def test_elevate_linear(self):
     nodes = np.asfortranarray([[0.0, 2.0, -1.0], [0.0, 1.0, 2.0]])
     surface = self._make_one(nodes, 1)
     elevated = surface.elevate()
     expected = np.asfortranarray([[0.0, 1.0, 2.0, -0.5, 0.5, -1.0],
                                   [0.0, 0.5, 1.0, 1.0, 1.5, 2.0]])
     self.assertEqual(surface._degree, 1)
     self.assertEqual(elevated._degree, 2)
     self.assertEqual(elevated._nodes, expected)
     main_vals = surface.evaluate_cartesian_multi(self.REF_TRIANGLE3)
     sub_vals = elevated.evaluate_cartesian_multi(self.REF_TRIANGLE3)
     self.assertEqual(main_vals, sub_vals)
예제 #2
0
파일: test_surface.py 프로젝트: fudp/bezier
 def _eval_cartesian_multi_helper(self, **kwargs):
     nodes = np.asfortranarray([[2.0, 0.0, 3.0], [3.0, 2.0, 7.5]])
     surface = self._make_one(nodes, 1, _copy=False)
     param_vals = np.asfortranarray([[1.0, 0.0]])
     patch = unittest.mock.patch(
         "bezier._surface_helpers.evaluate_cartesian_multi",
         return_value=unittest.mock.sentinel.evaluated,
     )
     with patch as mocked:
         result = surface.evaluate_cartesian_multi(param_vals, **kwargs)
         self.assertEqual(result, unittest.mock.sentinel.evaluated)
         mocked.assert_called_once_with(nodes, 1, param_vals, 2)
예제 #3
0
파일: test_surface.py 프로젝트: fudp/bezier
 def test_elevate_quadratic(self):
     klass = self._get_target_class()
     nodes = np.asfortranarray([[0.0, 6.0, 9.0, 0.0, 6.0, -3.0]])
     surface = klass.from_nodes(nodes)
     elevated = surface.elevate()
     expected = np.asfortranarray(
         [[0.0, 4.0, 7.0, 9.0, 0.0, 4.0, 7.0, -1.0, 3.0, -3.0]])
     self.assertEqual(surface._degree, 2)
     self.assertEqual(elevated._degree, 3)
     self.assertEqual(elevated._nodes, expected)
     main_vals = surface.evaluate_cartesian_multi(self.REF_TRIANGLE3)
     sub_vals = elevated.evaluate_cartesian_multi(self.REF_TRIANGLE3)
     self.assertEqual(main_vals, sub_vals)
예제 #4
0
    def _subdivide_points_check(self, surface):
        # Using the exponent means that we will divide by
        # 2**exp, which can be done without roundoff (for small
        # enough exponents).
        sub_surfaces = surface.subdivide()

        ref_triangle = self.REF_TRIANGLE
        quarter_a = 0.5 * ref_triangle
        quarters = [
            quarter_a,
            np.asfortranarray([0.5, 0.5]) - quarter_a,  # B
            quarter_a + np.asfortranarray([0.5, 0.0]),  # C
            quarter_a + np.asfortranarray([0.0, 0.5]),  # D
        ]

        for sub_surface, quarter in zip(sub_surfaces, quarters):
            # Make sure sub_surface(ref_triangle) == surface(quarter)
            main_vals = surface.evaluate_cartesian_multi(quarter)
            sub_vals = sub_surface.evaluate_cartesian_multi(ref_triangle)
            self.assertEqual(main_vals, sub_vals)
예제 #5
0
파일: test_surface.py 프로젝트: fudp/bezier
 def test_evaluate_cartesian_multi_wrong_dimension(self):
     surface = self._make_one(self.ZEROS, 1)
     param_vals_1d = np.zeros((4, ), order="F")
     with self.assertRaises(ValueError):
         surface.evaluate_cartesian_multi(param_vals_1d)