© 2023 无名玩家X
简介
本文给出 Hermite 与 Bezier 曲线互转的公式及其推导过程。
Bezier 曲线
其中:
矩阵形式:
Hermite 曲线
其中:
矩阵形式:
转换公式
推导
将 hermite 和 bezier 的参数写成矩阵和
,如下:
由于 bezier 和 hermite 是等价的,有:
其中矩阵 M 是 hermite 和 bezier 矩阵形式中间的那个矩阵。
于是:
所以有:
所以,Herimite 控制参数与 Bezier 控制参数的关系是:
Hermite 转 Bezier
由推导的公式,可知:
Bezier 转 Hermite
由推导的公式,可知:
转换效果示例
可以看到,两条曲线完美重合
上图为 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}