Convert a B-Spline into Bezier curves

て烟熏妆下的殇ゞ 提交于 2021-02-07 08:27:22

问题


I have a B-Spline curve. I have all the knots, and the x,y coordinates of the Control Points.

I need to convert the B-Spline curve into Bezier curves.

My end goal is to be able to draw the shape on an html5 canvas element. The B-Spline is coming from a dxf file which doesn't support Beziers, while a canvas only supports Beziers.

I've found several articles which attempt to explain the process, however they are quite a bit over my head and really seem to be very theory intensive. I really need an example or step by step help.

Here's what I've found: (Explains B-Splines),(Converting to Beziers),(Javascript Example)

The last link is nice because it contains actual code, however it doesn't seem to take into account the weight assigned by the nodes. I think this is kind of important as it seems to influence whether the curve passes through a control point.

I can share my Nodes or Control Points if that would be useful. If someone would point me to a step-by-step procedure or help me with some psuedo(or actual)code, I would be so grateful.


回答1:


I wrote a simple Javascript implementation of Boehm's algorithm for cubic B-Splines a while back. It's a fairly straightforward implementation involving polar values, described here in section 6.3: Computer Aided Geometric Design- Sederberg

If you're just interested in the implementation, I've linked the classes I wrote here: bsplines.js




回答2:


This could be helpful - https://github.com/Tagussan/BSpline

My project has moved on and I no longer need it, but this seems to be a pretty useful way to feed control points and have a curve drawn.



来源:https://stackoverflow.com/questions/17053735/convert-a-b-spline-into-bezier-curves

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!