许铮

学习 / 生活 / 工作 / 娱乐

© 2023 无名玩家X

简介

本文给出 Hermite 与 Bezier 曲线互转的公式及其推导过程。

Bezier 曲线

image-20231211180232866

其中:

image-20231212135035728

矩阵形式:

image-20231212135058198

Hermite 曲线

image-20231212135113442

其中:

image-20231212135132863

矩阵形式:

image-20231212135151041

转换公式 推导 将 hermite 和 bezier 的参数写成矩阵image-20231212135218556image-20231212135229016,如下:

image-20231212135243488

由于 bezier 和 hermite 是等价的,有:

image-20231212135255627

其中矩阵 M 是 hermite 和 bezier 矩阵形式中间的那个矩阵。

于是:

image-20231212135311175

所以有:

image-20231212135323926

所以,Herimite 控制参数与 Bezier 控制参数的关系是:

image-20231212135336806

Hermite 转 Bezier

由推导的公式,可知:

image-20231212135348604

Bezier 转 Hermite

由推导的公式,可知:

image-20231212135423959

转换效果示例

可以看到,两条曲线完美重合

img

上图为 Tikz 绘制,绘制代码为:

\begin{tikzpicture}[scale=8]
\draw[help lines,thick,color=gray,step=.5cm,
dashed] (0,0) grid (1,1);
\draw[->] (-0.2,0) -- (1.2,0) node[right] {$x$};
\draw[->] (0,-0.2) -- (0,1.2) node[above] {$y$};
% 0, 1, 0, 1 for bezier
\draw[scale=1,domain=0:1, samples=50, smooth, variable=\x,blue] plot ({\x},{ 0 * (1 - \x) ^ 3 + 3 * 1 * (1 - \x)^2 * \x + 3 * 0 * (1 - \x) * \x ^ 2 + \x ^ 3});
\node[down] at (0, 0.8) {$f(x) = 0 * B_0(x) + 1 * B_1(x) + 0 * B_2 (x) + 1 * B_3 (x)$};

\draw[scale=1,domain=0:1, samples=50, smooth,variable=\x,red] plot ({\x},{
0 + 3 * 1 * \x * (1 - \x) ^ 2 + 1 * \x ^ 2 * (3 - 2 * \x) + 3 * 1 * (-1) * \x ^ 2 * (1 - \x)
});
\node[down] at (1, 0.2) {$f(x) = 0 * H_{00}(x) + 3 * H_{10}(x) + 1 * H_{01}(x) + 3 * H_{11}(x)$};
\end{tikzpicture}

最近的文章

游戏开发-游戏性能优化规则来源:https://vicobill.github.io/2020/12/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91-%E6%B8%B8%E6%88%8F%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E8%A7%84%E5%88%99/ -2020-12-09分为以下几部分: CPU:主要是运算量,频繁分配释放 垃圾回收(少即时的分配释放) 算法:尽量使用引用形式代码 ...…

继续阅读
更早的文章

© 2023 无名玩家XDiffusing / smoothing weight map over a triangular mesh.在三角形网格上扩散/平滑权重分布Diffuse per vertex weights/scalar map/scalar function over an irregular triangle mesh (laplacian diffusion) - 05/2018 - #Geometry在不规则三角形网格上扩散每个顶点权重/标量映射/标量函数(拉普拉斯扩...…

继续阅读