曲率贝塞尔曲线——改进经典配方
Curvature Beziers – Improving on a timeless recipe

原始链接: https://acko.net/blog/curvature-beziers/

本文介绍了一种使用非反转曲率半径来确定贝塞尔曲线控制柄的方法,这比曲率梳更自然且稳定。通过这种方式定义控制柄,可以在需要时将其转换为标准的贝塞尔点,从而避免数值漂移,并消除频繁进行数据转换的需求。 为了实现这一点,作者推导出一套二次方程组,根据目标曲率($k_0, k_1$)、起点/终点位置及单位切线,计算出切线长度 $l_0$ 和 $l_1$。数学分析表明,曲率由到切线的垂直距离决定。$l_0$ 和 $l_1$ 之间的耦合关系取决于切线的相对角度;如果切线平行($b=0$),方程将变得独立且易于求解。最终,计算这些控制柄的过程简化为寻找两条双抛物线的交点,从而在保持曲线方向翻转所需的灵活性的同时,实现动态且具备曲率感知能力的曲线编辑。

这篇 Hacker News 帖子讨论了《曲率贝塞尔——对经典配方的改进》(acko.net)一文,该文探讨了对传统贝塞尔曲线的现代改进。 讨论强调了开发者在构建自己的矢量和字体编辑器时,尝试改进曲率和样条连续性的趋势。参与者分享了各自的项目,例如具有独特锚点处理功能的网页编辑器、自定义曲线拟合工具和键驱动界面。 一个反复出现的主题是曲线优化的数学挑战。参与者频繁提及该领域杰出人物 Raph Levien 的工作,引导用户参考他关于简化、拟合和并行化三次贝塞尔曲线的研究。此外,用户还推荐了教育资源(特别是 Freyr 的视频),供那些希望加深对样条连续性和贝塞尔曲线几何图形理解的人参考。此次讨论反映了社区对将矢量图形技术发展到超越标准实现范畴的广泛兴趣。
相关文章

原文

Unlike the curvature comb, the length of the handles is the non-inverted radius of curvature, which is the more natural choice.

These handles are very stable and can be converted just-in-time to classic bezier control points, without needing to round-trip back and forth between the two representations. Helpfully, this also avoids numerical drift.

To actually pull this off, we need to solve for the lengths $l_0$ and $l_1$ of the tangents, given the desired curvatures $k_0$ and $k_1$, the start/end points $A$ and $D$, and the unit-length tangents at the start/end.

Given a curve $\gamma\left(t\right)$, we can express the unit tangent vector $\mathbf{T}\left(t\right)$ as the normalized derivative:

This can be used to find the curvature vector $\mathbf{K}\left(t\right)$ via two vector cross products using the first and second derivative:

The cross products ensure that $\mathbf{K}\left(t\right)$ is perpendicular to $\mathbf{T}\left(t\right)$, i.e. they extract the normal vector component of the middle term. Now we can solve for $\mathbf{K}\left(0\right) = k_0$ and $\mathbf{K}\left(1\right) = k_1$.

After working through the math, we end up with a quadratic system of equations in $l_0$ and $l_1$:

Where:

This captures a few things:

  • The sign of the curvature $k_i$ defines whether the curve turns clockwise or counterclockwise. When moving curve points around, the curve may be forced to flip, hence the $±$ is necessary, and both signs can change independently.

  • The coupling between $l_0$ and $l_1$ is influenced only by $b$. If $b = 0$, then the two equations are independent and the problem is trivial to solve. This corresponds to the situation where the two tangents are parallel.

  • The constant term $c_i$ is influenced only by the perpendicular distance $D - A$ (or $A - D$) to the tangent $\mathbf{T_i}$. This matches the earlier finding that only perpendicular distance affects curvature.

Hence, the problem is reduced to finding the intersection of two double-parabolas, one horizontal and one vertical:

联系我们 contact @ memedata.com