我在实现 3 度 NURBS 的算法时遇到问题。我已经能够从此处描述的方程中编写 2 阶方程,但我无法导出 3 阶有理 B 样条的方程。作者描述了有理结方程,因为它是De的非递归形式从那里的布尔算法我能够将Rational 内部控制点: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 方程一定是错误的。当函数输入Bn和Cn点列表时,我的猜测是我错过了这两个方程与我遇到问题的方程之间的关系。
由于我的问题是数学概念而不是实现,因此这被认为是与语言无关的问题。