将B样条曲线转换为贝塞尔曲线 [英] Convert a B-Spline into Bezier curves

查看:168
本文介绍了将B样条曲线转换为贝塞尔曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条B样条曲线.我有所有的结,以及控制点的x,y坐标.

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

我需要将B样条曲线转换为贝塞尔曲线.

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

我的最终目标是能够在html5 canvas元素上绘制形状.B样条来自不支持Beziers的dxf文件,而画布仅支持Beziers.

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.

这是我发现的东西:(解释B样条)(转换为贝塞尔曲线)

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.

推荐答案

前一段时间,我为Boehm算法编写了一个简单的Java实现,用于三次B样条曲线.这是一个涉及极值的相当简单的实现,如6.3节所述:计算机辅助几何设计-Sederberg

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

这篇关于将B样条曲线转换为贝塞尔曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆