def test_bspline_basis_vector(): degree = 3 count = 10 knots = list(open_uniform_knot_vector(count, order=degree + 1)) max_t = max(knots) basis_func = Basis(knots=knots, order=degree + 1, count=count) for u in (0, 2., 2.5, 3.5, 4., max_t): basis = bspline_basis_vector(u, count=count, degree=degree, knots=knots) basis2 = basis_func.basis_vector(u) assert len(basis) == len(basis2) for v1, v2 in zip(basis, basis2): assert isclose(v1, v2)
def test_bspline_basis_vector(): degree = 3 count = 10 knots = list(knot_open_uniform(count, order=degree + 1)) max_t = max(knots) basis_func = Basis(knots=knots, order=degree + 1, count=count) for u in (0, 2., 2.5, 3.5, 4., max_t): basis = bspline_basis_vector(u, count=count, degree=degree, knots=knots) basis2 = basis_func.basis(u) assert len(basis) == len(basis2) assert basis == basis2
def test_bspline_basis_vector(basis_cls): degree = 3 count = 10 knots = make_knots(count, degree) max_t = max(knots) basis_func = basis_cls(knots=knots, order=degree + 1, count=count) for u in (0, 2, 2.5, 3.5, 4, max_t): basis = bspline_basis_vector(u, count=count, degree=degree, knots=knots) basis2 = basis_func.basis_vector(u) assert len(basis) == len(basis2) for v1, v2 in zip(basis, basis2): assert v1 == pytest.approx(v2)
def test_basis_vector_N_ip(): degree = 3 fit_points = Vector.list(POINTS2) # data points D n = len(fit_points) - 1 t_vector = list(uniform_t_vector(fit_points)) knots = list(control_frame_knots(n, degree, t_vector)) should_count = len(fit_points) - 2 # target control point count h = should_count - 1 spline = Basis(knots, order=degree + 1, count=len(fit_points)) matrix_N = [spline.basis(t) for t in t_vector] for k in range(1, n): basis_vector = bspline_basis_vector(u=t_vector[k], count=len(fit_points), degree=degree, knots=knots) for i in range(1, h): assert isclose(matrix_N[k][i], basis_vector[i])