簡體   English   中英

如果已知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曲線定義的一部分。 因此,實際上您可以定義自己的非均勻結矢量,只要該結矢量遵循基本規則即可:

1)結點數=控制點數+順序

2)所有結值必須不減小。 即,k [i]≤k[i + 1]。

對於具有9個控制點的示例,您可以具有非均勻結矢量,例如[0,0,0,0,a,b,c,d,e,1,1,1,1],其中0.0 <a <對於3度B樣條曲線= b <= c <= d <= e <1.0 當然,為a,b,c,d和e選擇不同的值將導致曲線具有不同的形狀。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM