如何简化三次贝塞尔曲线? [英] How to simplify cubic bezier curve?

查看:261
本文介绍了如何简化三次贝塞尔曲线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个立方贝塞尔曲线包括多个段(左图)。它有一些粗糙的曲率,我需要使它更平滑,像正确的图像。这个问题有点像降噪,我该如何实现?

I have a Cubic Bezier curve comprises of a number of segments (left image). It has some rough curvature and I need to make it smoother like the right image. This problem is somewhat like "noise reduction", how do I achieve this?

有类似的线程这里,但输入是一组点并使用最小二乘拟合贝赛尔曲线,但在我的问题中输入已经是三次bezier。

There's similar thread here, but the input is a set of point and fitting a bezier curve on it using least square, but in my problem the input is already cubic bezier.

>

在上面的图片上我不绘制段和控制点,但我希望你能得到想法。

推荐答案

你想保持相同数量的段吗?你需要保持Bezier段之间的连续性吗?你试图击中一定数量的细分,或只是保持在原曲线的一定公差内?

Do you want to keep the same number of segments? Do you need to keep continuity between Bezier segments? Are you trying to hit a certain number of segments, or just keep things within a certain tolerance of the original curve?

现在我假设你想减少贝塞尔曲线段的数量,您需要保持线段之间的G1连续性,并且您尝试在公差范围内平滑(仅从您的图像猜出)。

For now I'll assume that you want to reduce the number of Bezier segments, any you need to keep G1 continuity between the segments, and you're trying to smooth within a tolerance (just guessing from your image).

对于顶级算法,您将通过每个相邻的曲线对,并尝试将它们组合。重复此操作,直到两个相邻的曲线合并在公差范围之外。

For the top-level algorithm, you go through every adjacent pair of curves, and try to combine them. Repeat this until combining two adjacent curves would fall outside of your tolerance.

如何组合两个相邻的贝塞尔曲线?让我们假设它们是曲线P和Q,并且由于它们都是立方的,所以它们具有4个CV,每个具有P0,P1,P2,P3和Q0,Q1,Q2,Q3。我们还假设P3 == Q0。此外,我们会说输出曲线是R,由R0,R1,R2,R3组成。

How do you combine two adjacent Bezier curves? Let's assume that they are curves P and Q, and since they're both cubic they have 4 CVs each, P0, P1, P2, P3 and Q0, Q1, Q2, Q3. We'll also assume that P3 == Q0. Also, we'll say that the output curve is R, composed of R0, R1, R2, R3.

另一个非常重要的步骤 - 你需要分配t值对于您正在简化的较大曲线内的每个贝塞尔曲线段。因此,段0将从0..1开始,段1从1..2开始,段2从2..3开始等。

One other very important step - you need to assign t values for each Bezier curve segment within the larger curve that you're simplifying. So, segment 0 would go from 0..1, segment 1 goes from 1..2, segment 2 goes from 2..3, etc.

为了保持P与其邻居的连续性,以及Q与其邻居的连续性,您不能移动P0或Q3,由(P1-P0)和(Q2-Q3)形成的切向量必须保持在相同的方向。

If you want to maintain P's continuity with its neighbor, and Q's continuity with its neighbor, you can't move P0 or Q3, and the tangent vectors formed by (P1-P0) and (Q2-Q3) must stay in the same direction.. they can only be scaled.

由于你在R中只有4个CV,所以这两个比例因子是你唯一的自由度。我们称它们为kp和kq。

Since you only have 4 CVs in R, those two scale factors are the only degree of freedom that you have. We'll call them kp and kq.

R0=P0
R1=P0+kp*(P1-P0)
R2=Q3+kq*(Q2-Q3)
R3=Q3

如果两条曲线的结长度相等,则kp = 2和kq = 2。

If the knot length of the two curves are equal, than kp = 2 and kq = 2.

这篇关于如何简化三次贝塞尔曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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