NURBS Взвешивает алгоритм де Бур - PullRequest
1 голос
/ 06 апреля 2019

У меня проблемы с реализацией алгоритма для NURBS 3-й степени. Мне удалось запрограммировать уравнения второй степени из уравнений, описанных здесь , но я не могу вывести уравнение для рациональных B-сплайнов степени 3. Автор описывает уравнение рационального узла как NURBS это нерекурсивная форма алгоритма Де Боора , от которого я смог запрограммировать Рациональные точки внутреннего контроля: Bn и Cn как:

/* Note that I had to modify the equations to work from the first point on the list as the ones described in the article only took into account points from the second index **Pn+1**. I though that could have been the problem and rewrote them as they where originally written but that did not solve the issue, so I am posting the ones that work from **Pn** */

// Point B. 
/* Iterate over the points(3d vector), knots(double) and weights(double) lists to get the Internal Control Points(3d vector) for the 3rd degree Bézier curves. */

 // Precompute:
double knotE = ( knots[i + 4] - knots[i + 2] ) / ( knots[i + 4] - knots[i + 1] );
double knotEO = ( knots[i + 2] - knots[i + 1] ) / ( knots[i + 4] - knots[i + 1] );

double rationalWeight = (  weights[i] * knotE ) + ( weights[i + 1] * knotEO );
double w1 = weights[i] / rationalWeight;
double w2 = weights[i + 1] / rationalWeight;

/* Our Point3d class lets us multiply a vector by a scalar. */
Point3d b = new Point3d( ( knotE * points[i] * w1 ) + ( knotEO * points[i + 1] * w2 ) );

// Point C. 
/* Iterate over the points, knots and weights lists to get the Internal Control Points for the 3rd degree Bézier curves. */

 // Precompute:
double knotE = ( knots[i + 4] - knots[i + 3] ) / ( knots[i + 4] - knots[i + 1] );
double knotEO = ( knots[i + 3] - knots[i + 1] ) / ( knots[i + 4] - knots[i + 1] );

double rationalWeight = (  weights[i] * knotE ) + ( weights[i + 1] * knotEO );
double w1 = weights[i] / rationalWeight;
double w2 = weights[i + 1] / rationalWeight;

/* Our Point3d class lets us multiply a vector by a scalar. */
Point3d c = new Point3d( ( knotE * points[i] * w1 ) + ( knotEO * points[i + 1] * w2 ) );

Но когда я применяю тот же процесс для точки Vn , я получаю результаты, которых я не ищу:

// Point V. 
/* Iterate over the c, b, knots and weights lists to get the Internal Control Points for the 3rd degree Bézier curves. */

 // Precompute:
double knotE = ( knots[i + 4] - knots[i + 3] ) / ( knots[i + 4] - knots[i + 2] );
double knotEO = ( knots[i + 3] - knots[i + 2] ) / ( knots[i + 4] - knots[i + 2] );

double rationalWeight = (  weights[i] * knotE ) + ( weights[i + 1] * knotEO );
double w1 = weights[i] / rationalWeight;
double w2 = weights[i + 1] / rationalWeight;

/* Our Point3d class lets us multiply a vector by a scalar. */
Point3d v = new Point3d( ( knotE * c[i] * w1 ) + ( knotEO * b[i + 1] * w2 ) );

Когда все веса одинаковы, точки реагируют, как и ожидалось, когда веса не совпадают, точки Bn и Cn работают так, как должны, но Vn отвечает неправильно. Так что мое Vn Equation должно быть ошибочным. Поскольку функция вводит списки точек Bn и Cn , я предполагаю, что мне не хватает связи между этими двумя уравнениями с тем, с которым у меня возникли проблемы.

Поскольку моя проблема связана с математическим понятием, а не с дополнением, это считается вопросом, не зависящим от языка.

Вот изображение 3-й степени UniformBSpline UBS, которое я уже успешно запрограммировал, но это может помочь, если ссылка на ресурс прекратится.

...