绘制 NURBS 曲线时节点的含义?
我正在使用 gluNurbsCurve 绘制一些带有一些控制点的曲线。我已经按照红皮书中描述的方式正确运行了基本设置,并且正在尝试对其进行扩展。
该示例如下所示:
float knots[8] = {0,0,0,0,1,1,1,1};
float pnts[4][3] = { {...},{...},{...},{...} };
GLUnurbsObj *m = gluNewNurbsRenderer();
gluBeginCurve(n);
gluNurbsCurve(n, 8, knots, 3, pnts, 4, GL_MAP1_VERTEX_3)
gluEndCurve(n);
我想知道的一件事是结数据的含义。它如何影响结果?我还可以在那里尝试哪些其他选项?
由于某种原因,我找不到任何正确解释这一点的教程。
I'm using gluNurbsCurve
to draw some curves with some control points. I've got the basic setup as described in the red book working correctly and I'm trying to expand on it.
This sample looks like this:
float knots[8] = {0,0,0,0,1,1,1,1};
float pnts[4][3] = { {...},{...},{...},{...} };
GLUnurbsObj *m = gluNewNurbsRenderer();
gluBeginCurve(n);
gluNurbsCurve(n, 8, knots, 3, pnts, 4, GL_MAP1_VERTEX_3)
gluEndCurve(n);
One thing I was wondering about is the meaning of the knots data. How does it affect the result? What other options can I experiment there?
For some reason I could not find any tutorial which properly explains this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,网上有很多网站可以解释结向量。它不是 GL 特有的东西,而是 NURBS 的固有属性。因此,在谷歌中输入“NURBS 结向量”将为您提供详细的解释。
我只是想说,结向量的长度通常为knot_vector_length = number_of_points + Degree_of_curve + 1,唯一重要的是比率而不是绝对值。所以
{0,1,2,3}
与{0,2,4,6}
相同,在我看来,最重要的结向量是这些:
1)
{0,1,2,3,4,5,6,...}
如果重复最后一个,您可以轻松地以曲率连续性延伸曲线(或第一个)
Degree_of_curve-1 点,但这意味着曲线实际上并未穿过其起点和终点,因此您必须重复最后一个(或第一个)
Degree_of_curve-1 < /code> 点创建连续的闭合曲线。
另一个重要的形式是
2)
{0,0,0,1,2,3,...,n,n,n}
而
0开头的
和结尾的n
重复level_of_curve + 1
次。这也是您使用的形式。这将为您提供一条 NURBS 曲线,该曲线从您指定的第一个点开始,到您指定的最后一个点结束。但它只提供位置连续性。因此,如果你用它制作一条闭合曲线,那么你很可能会得到切向不连续性。顺便提一句。如果您只有
level_of_curve + 1
点并使用第二种形式,那么您只有0
和1
。生成的样条线将与贝塞尔曲线相同。如果没有图像或数学背景(伯恩斯坦多项式),这真的很难解释
Actually there are ample sites online that explain the knot vector. It's not a GL specific thing but an inherent property of NURBS. So entering "NURBS knot vector" in google is gonna get you detailed explanations.
I'm just gonna say that usually the knot vector has a length of
knot_vector_length = number_of_points + degree_of_curve + 1
and the only thing that matters is the ratio and not the absolute values. So{0,1,2,3}
is the same as{0,2,4,6}
in my opinion the most important knot vectors are these:
1)
{0,1,2,3,4,5,6,...}
which will allow you to easily extend the curve with curvature continuity if you repeat the last (or first)
degree_of_curve-1
points but this means that that the curve doesn't actually run through its start and end points so you must repeat the last (or first)degree_of_curve-1
points to create a closed curve that is continuous.The other important form is
2)
{0,0,0,1,2,3,...,n,n,n}
whereas the
0
at the beginning and then
at the end repeatdegree_of_curve + 1
times. This is also the form that you used. This will give you a NURBS curve that begins at the first point and ends at the last point you specified. But it only gives positional continuity. So if you make a closed curve with this then you are highly likely to get a tangential discontinuity.Btw. if you only have
degree_of_curve + 1
points and use the second form then you only have0
s and1
s. The resulting spline will be identical to a Bézier curve.This is really hard to explain without images or the mathematical background (Bernstein polynomials)
了解“贝塞尔”曲线是如何书写的。我们要创建一条阶数为 num_control_points - 1 的曲线。因此,对于具有 4 个控制点的贝塞尔曲线。我们会得到一条阶数为 3 的曲线(阶数 = 4)。所以在这条曲线上的任何地方。连续性将为 C2,这意味着存在曲率连续性。该曲线的结向量为 (0, 0, 0, 0, 1, 1, 1, 1)。这是来自您上面给出的代码片段。您已经提供了结向量和曲线的控制点。
因此,我们可以看出,在参数 0 处,存在 C0 连续性。与参数 1 相同。
参数的结值越多。这意味着该参数的连续性是
减少。希望你明白我所说的。由于曲线的阶数为 3。
连续性从(C3→C2→C1→C0)下降。这就是 ( 0 -> 0 -> 0 -> 0) 的意思
为了。
我仍在研究(研究:P)在均匀结向量的情况下,曲线如何从中间的某个地方开始。现在,假设结向量为 (0, 1, 2, 3..7) 的情况。这表明参数 0 - 1 之间存在一条曲线。在1-2之间,还有另一个。所以基本上我们把整个曲线分成了7部分(当然,程度取决于你)。如果我将其视为 3 次曲线。这意味着我有 7 条不同的曲线,每条曲线均为 3 次。
希望您遵循我所说的。第 1 步尝试理解结向量的含义,第 2 步将介绍如何在 Cox De-Boor 递归方程(有点复杂)中使用它们。最后你会明白权重的含义。这就是首字母缩略词 NURBS(非均匀有理化 B 样条)中的“R”的原因。您提供的代码片段适用于统一 B 样条曲线。所以基本上,NURBS 只是任何可能的曲线的组合。 :)
understand how "Bezier" curves are written. We get to create a curve whose degree is num_control_points - 1. So for a Bezier curve with 4 control points. We'd get a curve with degree 3 (order = 4). So anywhere on this curve. The continuity will be C2, meaning there is curvature continuity. A knot vector for this curve will be (0, 0, 0, 0, 1, 1, 1, 1). This is from the code snippet you gave above. You have provided the knot vector and the control points of the curve.
So, one can tell that at parameter 0. There is C0 continuity. The same at parameter 1.
The more knot values for a paramter. It means that the continuity at that parameter is
reducing. Hope you understand what I'm telling. Since the degree of the curve is 3. The
continuity drops from ( C3 -> C2 -> C1 -> C0 ). That's what the ( 0 -> 0 -> 0 -> 0) stands
for.
I am still researching(studying :P ) how in an uniform knot vector case, the curve begins somewhere midway. As for now, assume a case where the knot vector is (0, 1, 2, 3..7). This tells that between paramters 0 - 1. There is one curve. Between 1 - 2, there is another. So basically we broke the entire curve into 7 pieces(of course, the degree is dependent on you). If I take this as a curve with degree 3. It means I have 7 different curves each with degree 3.
Hope you followed what I said. As step 1. try to understand the meaning of knot vectors, step 2 will be how these are used in the Cox De-Boor recursive equation(which gets a tad complex). Finally you'll see what weights mean. That's the reason for the "R" in the acronym NURBS(Non Uniform Rationalized B splines). The snippet you gave was for a Uniform B spline curve. So basically, NURBS is just a conglomeration of any curve possible. :)