def test_quadratic(self):
from bezier import _curve_helpers
nodes = np.asfortranarray([
[0.0, 0.0],
[1.0, 1.0],
[5.0, 6.0],
])
# NOTE: This is hand picked so that
# d Nodes = [1, 1], [4, 5]
# d^2 Nodes = [3, 4]
# so that sqrt(3^2 + 4^2) = 5.0
error_val = self._call_function_under_test(nodes)
expected = 0.125 * 2 * 1 * 5.0
self.assertEqual(error_val, expected)
# For a degree two curve, the 2nd derivative is constant
# so by subdividing, our error should drop by a factor
# of (1/2)^2 = 4.
left_nodes, right_nodes = _curve_helpers.subdivide_nodes(nodes)
error_left = self._call_function_under_test(left_nodes)
error_right = self._call_function_under_test(right_nodes)
self.assertEqual(error_left, 0.25 * expected)
self.assertEqual(error_right, 0.25 * expected)
评论列表
文章目录