如果已知 NURBS 曲线的控制点,如何找到结向量?
How to find knot vector if control points are known for a NURBS curve?
我有一组控制点
pts = [[849, 1181],
[916, 1257],
[993, 1305],
[1082,1270],
[1137,1181],
[1118,1055],
[993,1034],
[873,1061],
[849, 1181]]
我有生成开结向量的逻辑:
/*
Subroutine to generate a B-spline open knot vector with multiplicity
equal to the order at the ends.
c = order of the basis function
n = the number of defining polygon vertices
nplus2 = index of x() for the first occurence of the maximum knot vector value
nplusc = maximum value of the knot vector -- $n + c$
x() = array containing the knot vector
*/
knot(n,c,x)
int n,c;
int x[];
{
int nplusc,nplus2,i;
nplusc = n + c;
nplus2 = n + 2;
x[1] = 0;
for (i = 2; i <= nplusc; i++){
if ( (i > c) && (i < nplus2) )
x[i] = x[i-1] + 1;
else
x[i] = x[i-1];
}
}
还有一个用于生成周期性节点向量:
/* Subroutine to generate a B-spline uniform (periodic) knot vector.
c = order of the basis function
n = the number of defining polygon vertices
nplus2 = index of x() for the first occurence of the maximum knot vector value
nplusc = maximum value of the knot vector -- $n + c$
x[] = array containing the knot vector
*/
#include <stdio.h>
knotu(n,c,x)
int n,c;
int x[];
{
int nplusc,nplus2,i;
nplusc = n + c;
nplus2 = n + 2;
x[1] = 0;
for (i = 2; i <= nplusc; i++){
x[i] = i-1;
}
}
然而,我需要在 [0,1]
范围内生成一个非均匀节点矢量
以上算法产生统一的结向量。
如果有什么办法,请提出建议。如果代码在 python
中会更可取
结向量(均匀或不均匀)是 NURBS 曲线定义的一部分。所以,你实际上可以定义自己的 non-uniform 结向量,只要结向量遵循基本规则:
1) 节点值的数量 = 控制点的数量 + 顺序
2) 所有节点值必须是non-decreasing。即,k[i] <= k[i+1].
对于具有 9 个控制点的示例,您可以使用 non-uniform 节点向量,例如 [0, 0, 0, 0, a, b, c, d, e, 1, 1, 1, 1 ],其中 0.0 < a <= b <= c <=d <=e < 1.0 对于 3 B-spline 曲线。当然,为a、b、c、d和e选择不同的值会导致不同形状的曲线。
我有一组控制点
pts = [[849, 1181],
[916, 1257],
[993, 1305],
[1082,1270],
[1137,1181],
[1118,1055],
[993,1034],
[873,1061],
[849, 1181]]
我有生成开结向量的逻辑:
/*
Subroutine to generate a B-spline open knot vector with multiplicity
equal to the order at the ends.
c = order of the basis function
n = the number of defining polygon vertices
nplus2 = index of x() for the first occurence of the maximum knot vector value
nplusc = maximum value of the knot vector -- $n + c$
x() = array containing the knot vector
*/
knot(n,c,x)
int n,c;
int x[];
{
int nplusc,nplus2,i;
nplusc = n + c;
nplus2 = n + 2;
x[1] = 0;
for (i = 2; i <= nplusc; i++){
if ( (i > c) && (i < nplus2) )
x[i] = x[i-1] + 1;
else
x[i] = x[i-1];
}
}
还有一个用于生成周期性节点向量:
/* Subroutine to generate a B-spline uniform (periodic) knot vector.
c = order of the basis function
n = the number of defining polygon vertices
nplus2 = index of x() for the first occurence of the maximum knot vector value
nplusc = maximum value of the knot vector -- $n + c$
x[] = array containing the knot vector
*/
#include <stdio.h>
knotu(n,c,x)
int n,c;
int x[];
{
int nplusc,nplus2,i;
nplusc = n + c;
nplus2 = n + 2;
x[1] = 0;
for (i = 2; i <= nplusc; i++){
x[i] = i-1;
}
}
然而,我需要在 [0,1]
范围内生成一个非均匀节点矢量以上算法产生统一的结向量。
如果有什么办法,请提出建议。如果代码在 python
中会更可取结向量(均匀或不均匀)是 NURBS 曲线定义的一部分。所以,你实际上可以定义自己的 non-uniform 结向量,只要结向量遵循基本规则:
1) 节点值的数量 = 控制点的数量 + 顺序
2) 所有节点值必须是non-decreasing。即,k[i] <= k[i+1].
对于具有 9 个控制点的示例,您可以使用 non-uniform 节点向量,例如 [0, 0, 0, 0, a, b, c, d, e, 1, 1, 1, 1 ],其中 0.0 < a <= b <= c <=d <=e < 1.0 对于 3 B-spline 曲线。当然,为a、b、c、d和e选择不同的值会导致不同形状的曲线。