OpenGL:如何绘制阶数高于8的贝塞尔曲线?

发布于 2024-08-30 07:10:39 字数 357 浏览 5 评论 0原文

我正在尝试使用 OpenGL 求值器绘制高阶贝塞尔曲线:

glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 30, &points[0][0]);

glMapGrid1f(30, 0, 1);
glEvalMesh1(GL_LINE, 0, 30);

或者

glBegin(GL_LINE_STRIP);
for (int i = 0; i <= 30; i++) 
  glEvalCoord1f((GLfloat) i/30.0);
glEnd();

当点数超过 8 时,曲线消失。如何使用评估器绘制高阶贝塞尔曲线?

I am trying to draw high order Bezier Curve using OpenGL evaluators:

glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 30, &points[0][0]);

glMapGrid1f(30, 0, 1);
glEvalMesh1(GL_LINE, 0, 30);

or

glBegin(GL_LINE_STRIP);
for (int i = 0; i <= 30; i++) 
  glEvalCoord1f((GLfloat) i/30.0);
glEnd();

When number of points exceeds 8, curve disappears. How to draw higher order Bezier curve using evaluators?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

债姬 2024-09-06 07:10:40

参见论文:

Watkins 和 Worsey,贝塞尔曲线的度数缩减。< /a>
计算机辅助设计。 20(7),1988 年 9 月,398-405。


他们所做的是将贝塞尔曲线转换为切比雪夫多项式形式,因此多项式的最后一项对形状的影响最小,删除最后一项,然后将其转换回贝塞尔形式。如果这产生太多错误,则对贝塞尔曲线进行细分并再次运行该过程。

这使得将高阶曲线转换为三次贝塞尔曲线变得非常容易,系统可以有效地本地渲染。我已经在几种不同的情况下使用过这种方法,而且效果很好。但有一点需要注意:论文中的矩阵方程有一些拼写错误。看:

Peterson, J.,致编辑的信,< /a> CAD,23(6),1991 年 8 月,第 460 页


用于修正方程。不幸的是CAD是一本老派的学术期刊,因此论文不方便在线发布。你需要从某个地方的图书馆里找出它们,或者支付罚款才能从爱思唯尔那里得到它们。

See the paper:

Watkins and Worsey, Degree reduction of Bézier curves.
Computer-Aided Design. 20(7), Sept. 1988, 398-405.

What they do is convert the Bézier curve into Chebyshev polynomial form, so the last term of the polynomial has the least effect on the shape, drop the last term, and convert it back to Bézier form. If this produces too much error, the Bézier is subdivided and the process is run again.

This makes it very easy to convert the high order curve down to a cubic Bézier the system can natively render efficiently. I've used this method for a couple different situations, and it works well. One caveat though; the matrix equations in the paper have some typos. See:

Peterson, J., Letter to the Editor, CAD, 23(6), August 1991, p.460

for the corrected equations. Unfortunately CAD is an old-school academic journal, and so the papers aren't conveniently on-line. You'll need to dig them out of a library someplace, or pay the fine to get them from Elsevier.

奢欲 2024-09-06 07:10:40

您是否有机会收到 GL_MAX_EVAL_ORDER 错误?贝塞尔曲线在高度处变得不稳定。如果您的 OpenGL 实现直接放弃,我不会感到惊讶。

您可以将 glGet 与 GL_MAX_EVAL_ORDER 结合使用来查看您的实现的最大值。如果您需要更高的东西,您可以随时推出自己的东西,这还不错。

By any chance are you get a GL_MAX_EVAL_ORDER error? Bezier curves become unstable at high degrees. I wouldn't be surprised if your OpenGL implementation just gave up.

You can use glGet with GL_MAX_EVAL_ORDER to see what your implementation maxes at. If you need something higher, you can always roll your own, which isn't too bad.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文