I have a problem with modifying my code based on Bézier curve (which works) to B-spline. This is how it draws:
Basic formula:
void MainWindow::rysujKrzywa(int koniec){
double x, y;
tm = m - 3;
for( double t = 0; t <= m-2; t += 0.01){
x = ((((-1 * pow(t-tm,3)) + (3 * pow(t-tm,2)) - (3 * (t-tm)) + 1) / 6) * punkty[koniec - 2]) +
((((3 * pow(t-tm,3)) - (6* pow(t-tm,2)) + 4) / 6) * punkty[koniec - 4]) +
((((-3 * pow(t-tm,3)) +(3 * pow(t-tm,2)) + 3*(t-tm) +1) / 6) * punkty[koniec - 6]) +
(((pow(t-tm,3))/6) * punkty[koniec - 8]);
y = ((((-1 * pow(t-tm,3)) + (3 * pow(t-tm,2)) - (3 * (t-tm)) + 1) / 6) * punkty[koniec - 1]) +
((((3 * pow(t-tm,3)) - (6* pow(t-tm,2)) + 4) / 6) * punkty[koniec - 3]) +
((((-3 * pow(t-tm,3)) +(3 * pow(t-tm,2)) + 3*(t-tm) +1) / 6) * punkty[koniec - 5]) +
(((pow(t-tm,3))/6) * punkty[koniec - 7]);
drawPixel( int(x), int(y), 255, 0, 0);
}
update();
}
a small dictionary:
punkty - saved points
koniec - end
Full code at the repository: https://gitlab.com/Sempron/b-spline