Exemplo n.º 1
0
 def degree_reduction(self):
     if len(self.control_points) > 3:
         new_points, new_weights = degree_reduction(self.control_points,
                                                    w=self.weights)
         self.control_points, self.weights = new_points.tolist(
         ), new_weights.tolist()
         self.compute()
Exemplo n.º 2
0
def test_degree_reduction_non_matching():
    control_points = [[0, 0], [1, 1], [1.5, .5], [2, 0]]
    expected_new_control_points = np.array([[0, 0], [7./6, 7./6], [2, 0]])
    expected_new_weights = np.ones((len(control_points) - 1))

    new_points, new_weights = degree_reduction(control_points)
    np.testing.assert_array_almost_equal(expected_new_control_points, new_points, decimal=6)
    np.testing.assert_array_equal(expected_new_weights, new_weights)
Exemplo n.º 3
0
def test_degree_reduction_non_matching_with_weights():
    control_points = [[0, 0], [.75, .75], [1.5, .5], [2, 0]]
    weights = [1, 2, 3, 4]
    expected_new_control_points = np.array([[0, 0], [9./13, 15./13], [2, 0]])
    expected_new_weights = np.array([1, 13./6, 4])

    new_points, new_weights = degree_reduction(control_points, w=weights)
    np.testing.assert_array_almost_equal(expected_new_control_points, new_points, decimal=6)
    np.testing.assert_array_almost_equal(expected_new_weights, new_weights, decimal=6)
Exemplo n.º 4
0
def test_degree_reduction_matching_with_weights():
    control_points = [[0, 0], [6/7., 6/7.], [1.6, .4], [2, 0]]
    weights = [1, 1.75, 2.5, 3]
    expected_new_control_points = np.array([[0, 0], [1, 1], [2, 0]])
    expected_new_weights = np.array([1, 2, 3])

    new_points, new_weights = degree_reduction(control_points, w=weights)
    np.testing.assert_array_equal(expected_new_control_points, new_points)
    np.testing.assert_array_equal(expected_new_weights, new_weights)