曲率贝塞尔曲线——改进经典配方
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) 14 分,boxed 发布于 1 小时前 | 隐藏 | 往日 | 收藏 | 讨论 | 帮助 指导方针 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

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