连接贝塞尔曲线

发布于 2024-12-14 03:10:32 字数 163 浏览 1 评论 0原文

我有一个问题。假设我们有一条由四个控制点定义的三次贝塞尔曲线。现在假设,曲线是从一个点切开的,并且每个线段再次使用三次贝塞尔曲线表示。那么,现在如果我们给定两个这样的贝塞尔曲线 B1 和 B2,有没有办法知道它们是否可以连接起来形成另一个贝塞尔曲线 B?这是为了通过连接两条曲线来简化几何形状并减少控制点的数量。

I have a problem. Suppose we have a single cubic bezier curve defined by four control points. Now suppose, the curve is cut from a point and each segment is again represented using cubic bezier curves. So, now if we are given two such beziers B1 and B2, is there a way to know if they can be joined to form another bezier curve B? This is to simplify the geometry by joining two curves and reduce the number of control points.

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

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

发布评论

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

评论(2

青瓷清茶倾城歌 2024-12-21 03:10:32

关于这个问题的一些想法。
我建议初始贝塞尔曲线 P0-P3 带有控制点 P1P2

在此处输入图像描述

让我们在参数 ta 和 tb 处进行两个细分。
我们现在有两条子曲线(黄色) - P0-PA3PB0-P3
蓝色间隔丢失。
PA1PB2 - 已知控制点。我们必须找到未知的P1P2

一些方程

初始曲线:

C = P0*(1-t)^3+3*P1(1-t)^2*t+3*P2*(1-t)*t^2+P3*t^3

端点:

PA3 = P0*(1-ta)^3+3*P1*(1-ta)^2*ta+3*P2*(1-ta)*ta^2+P3*ta^3

PB0 = P0*(1-tb)^3+3*P1*(1-tb)^2*tb+3*P2*(1-tb)*tb^2+P3*tb^3

小曲线的控制点

PA1 = P0*(1-ta)+P1*ta => P1*ta = PA1 – P0*(1-ta)

PB2 = P2*(1-tb)+P3*tb => P2(1-tb) = PB2 – P3*tb

现在替换 PA3 方程中的未知点:(

**PA3***(1-tb) = **P0***(1-ta)^3*(1-tb)+3*(1-ta)^2*(1-tb)*(**PA1** – **P0***(1-ta))+3*(1-ta)*ta^2*( **PB2** – **P3***tb)+**P3***ta^3*(1-tb)

由于 SO 格式,一些乘法符号已丢失)

这是向量方程,它包含两个未知数的两个标量方程 ta< /code> 和 tb

PA3X*(1-tb) = P0X*(1-ta)^3*(1-tb)+3*(1-ta)^2*(1-tb)*(PA1X – P0X*(1-ta))+3*(1-ta)*ta^2*( PB2X – P3X*tb)+P3X*ta^3*(1-tb)

PA3Y*(1-tb) = P0Y*(1-ta)^3*(1-tb)+3*(1-ta)^2*(1-tb)*(PA1Y – P0Y*(1-ta))+3*(1-ta)*ta^2*( PB2Y – P3Y*tb)+P3Y*ta^3*(1-tb)

这个系统可以通过数值和分析来解决(事实上,Maple 用非常非常大的三次公式来解决它:( )

如果我们有一些错误的点,那么建立某些点(PA3PB0PA2PB1)的超定方程组并进行数值求解以最小化偏差。

Some thoughts about this problem.
I suggest there was initial Bezier curve P0-P3 with control points P1 and P2

enter image description here

Let's make two subdivisions at parameters ta and tb.
We have now two subcurves (in yellow) - P0-PA3 and PB0-P3.
Blue interval is lost.
PA1 and PB2 - known control points. We have to find unknown P1 and P2.

Some equations

Initial curve:

C = P0*(1-t)^3+3*P1(1-t)^2*t+3*P2*(1-t)*t^2+P3*t^3

Endpoints:

PA3 = P0*(1-ta)^3+3*P1*(1-ta)^2*ta+3*P2*(1-ta)*ta^2+P3*ta^3

PB0 = P0*(1-tb)^3+3*P1*(1-tb)^2*tb+3*P2*(1-tb)*tb^2+P3*tb^3

Control points of small curves

PA1 = P0*(1-ta)+P1*ta => P1*ta = PA1 – P0*(1-ta)

PB2 = P2*(1-tb)+P3*tb => P2(1-tb) = PB2 – P3*tb

Now substitute unknown points in PA3 equation:

**PA3***(1-tb) = **P0***(1-ta)^3*(1-tb)+3*(1-ta)^2*(1-tb)*(**PA1** – **P0***(1-ta))+3*(1-ta)*ta^2*( **PB2** – **P3***tb)+**P3***ta^3*(1-tb)

(some multiplication signs have been lost due to SO formatting)

This is vector equation, it contains two scalar equations for two unknowns ta and tb

PA3X*(1-tb) = P0X*(1-ta)^3*(1-tb)+3*(1-ta)^2*(1-tb)*(PA1X – P0X*(1-ta))+3*(1-ta)*ta^2*( PB2X – P3X*tb)+P3X*ta^3*(1-tb)

PA3Y*(1-tb) = P0Y*(1-ta)^3*(1-tb)+3*(1-ta)^2*(1-tb)*(PA1Y – P0Y*(1-ta))+3*(1-ta)*ta^2*( PB2Y – P3Y*tb)+P3Y*ta^3*(1-tb)

This system might be solved both numerically and analytically (indeed Maple solves it with very-very big cubic formula :( )

If we have points with some error, that makes sense to build overdetermined equation system for some points (PA3, PB0, PA2, PB1) and solve it numerically to minimize deviations.

山人契 2024-12-21 03:10:32

您会在这里找到一个非常简单的解决方案:https://math.stackexchange.com/a/879213/65203

分割贝塞尔曲线时,第一部分的最后两个控制点和第二部分的前两个控制点形成的向量是共线的,它们的长度之比决定了分割时的参数值。验证公共控制点是否与参数值匹配是一件容易的事情(以避免意外共线性的情况)。

You will find a quite simple solution here: https://math.stackexchange.com/a/879213/65203.

When you split a Bezier, the vectors formed by the last two control points of the first section and the first two control points of the second section are collinear and the ratio of their lengths leads to the value of the parameter at the split. Verifying that the common control point matches that value of the parameter is an easy matter (to avoid the case of accidental collinearity).

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