Spline Curve (Bezier Curve, B-Spline Curve)
B-Spline Curve를 공부하면서 알아봤던 내용을 정리
SNU open courseware에서 이규열 교수님의 'Computer-Aided Ship Design' 수업자료를 참고하여 Curve 및 Surface에 대해 알아보았다.
Bezier Curves
우선 아래의 자료들이 Bezier Curve에 대해 직관적으로 가장 잘 설명한 것 같다. (모두 같은 blog)
중학생도 알 수 있는 베지에 곡선
프런트엔드 엔지니어를 위한 베지에 곡선(Bezier Curves) - 1편
프런트엔드 엔지니어를 위한 베지에 곡선(Bezier Curves) - 2편
프런트엔드 엔지니어를 위한 베지에 곡선(Bezier Curves) - 3편
Bezier Curve는 매개변수 방정식을 이용하여 곡선을 표현한다.
중학생도 알 수 있는 베지에 곡선
프런트엔드 엔지니어를 위한 베지에 곡선(Bezier Curves) - 1편
프런트엔드 엔지니어를 위한 베지에 곡선(Bezier Curves) - 2편
프런트엔드 엔지니어를 위한 베지에 곡선(Bezier Curves) - 3편
Bezier Curve는 매개변수 방정식을 이용하여 곡선을 표현한다.
Cubic Bezier Curve (3차 Bezier Curve)
Control point가 많은 다차원 곡면을 표현할 때, 한번에 나타내는 것이 아니라 여러개의 spline을 연결하는 방식으로 표현한다. 이 때, Cubic Bezier Curve로 기초삼을 수 있다.
- The cubic Bezier curve of form:
$$
\mathbf{r}(t) = B^3_0(t)\mathbf{b}_0 + B^3_1(t)\mathbf{b}_1 + B^3_2(t)\mathbf{b}_2 + B^3_3(t)\mathbf{b}_3 .
$$
$$
(\text{or }\\\\ \mathbf{r}(t) = (1-t)^3\mathbf{b}_0 + 3(1-t)^2t\mathbf{b}_1 + 3(1-t)t^2\mathbf{b}_2 + t^3\mathbf{b}_3)
$$
All interpolation conditions are:
\begin{equation*}
\mathbf{p}_0 = B^3_0(t_0)\mathbf{b}_0 + B^3_1(t_0)\mathbf{b}_1 + B^3_2(t_0)\mathbf{b}_2 + B^3_3(t_0)\mathbf{b}_3
\end{equation*}
\begin{equation*}
\mathbf{p}_1 = B^3_0(t_1)\mathbf{b}_0 + B^3_1(t_1)\mathbf{b}_1 + B^3_2(t_1)\mathbf{b}_2 + B^3_3(t_1)\mathbf{b}_3
\end{equation*}
\begin{equation*}
\mathbf{p}_2 = B^3_0(t_2)\mathbf{b}_0 + B^3_1(t_2)\mathbf{b}_1 + B^3_2(t_2)\mathbf{b}_2 + B^3_3(t_2)\mathbf{b}_3
\end{equation*}
\begin{equation*}
\mathbf{p}_3 = B^3_0(t_3)\mathbf{b}_0 + B^3_1(t_3)\mathbf{b}_1 + B^3_2(t_3)\mathbf{b}_2 + B^3_3(t_3)\mathbf{b}_3
\end{equation*}
$\mathbf{p}_i$ : Bezier curve가 지나가는 점 $\mathbf{p}_i$
$\mathbf{p}_i = \begin{bmatrix} x_i & y_i \end{bmatrix}^\intercal$ or $\begin{bmatrix} x_i & y_i & z_i \end{bmatrix}^\intercal$
$\mathbf{b}_i$ : Bezier curve의 control points $\Rightarrow$ 구해야할 unknown vectors
4 Unknown Vectors, 4 Vercotr Equations - Write a equations to matrix form:
\begin{equation*}
\begin{bmatrix}
\mathbf{p}_0 \cr \mathbf{p}_1 \cr \mathbf{p}_2 \cr \mathbf{p}_3
\end{bmatrix}
=
\begin{bmatrix}
B^3_0(t_0) & B^3_1(t_0) & B^3_2(t_0) & B^3_3(t_0) \cr
B^3_0(t_1) & B^3_1(t_1) & B^3_2(t_1) & B^3_3(t_1) \cr
B^3_0(t_2) & B^3_1(t_2) & B^3_2(t_2) & B^3_3(t_2) \cr
B^3_0(t_3) & B^3_1(t_3) & B^3_2(t_3) & B^3_3(t_3) \cr
\end{bmatrix}
\begin{bmatrix}
\mathbf{b}_0 \cr \mathbf{b}_1 \cr \mathbf{b}_2 \cr \mathbf{b}_3
\end{bmatrix}
\end{equation*}
$$
\mathbf{P} = \mathbf{M}\mathbf{B}
$$
The solution is $\mathbf{B} = \mathbf{M}^{-1} \mathbf{P}$
- 아래 그림에 나온 예시를 통해 Bezier Curve 상의 point들이 주어졌을 때, control point를 구하는 절차를 알아보자. 우리가 해야 할 것은 어떤 점들을 부드럽게 지나는 spline을 구하는 것인데, 해당 spline을 그리기 위한 control point를 구하는 것이다. 물론 그 반대로 control point가 주어졌을 때 spline위의 점을 알아낼 수도 있다.
그림을 통해 알 수 있듯이 point $i$에서 매개변수 $t_i$의 값들과 point의 위치를 알면 matrix form 연산을 통해 control point의 값을 알 수 있다. (자세한 것은 맨 위의 open courseware 링크의 교육자료 참고)
B-Spline Curve
B-Spline Curve는 Bezier Curve의 일반화된 표현이다. 여러 개의 control point로 이루어진 곡선을 나타낼 때는 Cubic B-spline Curve를 연속되도록 연결한다. 이 때 연결되는 곳을 knot라고 한다. Cubic B-Spline Curve의 식은 아래와 같다.
$$ \mathbf{r}(u) = \mathbf{d}_0 N^3_0(u) + \mathbf{d}_1 N^3_1(u) + \mathbf{d}_2 N^3_2(u) + \mathbf{d}_3 N^3_3(u) + \mathbf{d}_4 N^3_4(u) $$
위 식을 일반화 하면 아래와 같다.
$$ \mathbf{r}(u) = \mathbf{d}_0 N^3_0(u) + \mathbf{d}_1 N^3_1(u) + \mathbf{d}_2 N^3_2(u) + \cdots + \mathbf{d}_{D-1} N^3_{D-1}(u) $$ $\mathbf{d}_i$ : control points(de Boor points ), $\ i = 0, 1, ... , D-1$.
$N^n_i(u)$ : B-spline basis function of degree, $\ (n = 3)$.
$u_j$ : knots, $\ j = 0, 1, \cdot , K-1$
Control point를 여러개 갖는 B-Spline Curve의 경우 또한 knot를 통해 Cubic B-Spline Curve를 연속적으로 연결하는 방식으로 생성할 수 있다.
(B-Spline Curve를 그리는 방법은 위에서 언급한 SUN open courseware의 '3.2 B-spline Basis Function' 부분을 천천히 읽어보는 것이 제일 좋은 것 같다.)
$$ \mathbf{r}(u) = \mathbf{d}_0 N^3_0(u) + \mathbf{d}_1 N^3_1(u) + \mathbf{d}_2 N^3_2(u) + \mathbf{d}_3 N^3_3(u) + \mathbf{d}_4 N^3_4(u) $$
위 식을 일반화 하면 아래와 같다.
$$ \mathbf{r}(u) = \mathbf{d}_0 N^3_0(u) + \mathbf{d}_1 N^3_1(u) + \mathbf{d}_2 N^3_2(u) + \cdots + \mathbf{d}_{D-1} N^3_{D-1}(u) $$ $\mathbf{d}_i$ : control points(de Boor points ), $\ i = 0, 1, ... , D-1$.
$N^n_i(u)$ : B-spline basis function of degree, $\ (n = 3)$.
$u_j$ : knots, $\ j = 0, 1, \cdot , K-1$
- Cox-de Boor recurrence Formula (B-spline function)
Control point를 여러개 갖는 B-Spline Curve의 경우 또한 knot를 통해 Cubic B-Spline Curve를 연속적으로 연결하는 방식으로 생성할 수 있다.
(B-Spline Curve를 그리는 방법은 위에서 언급한 SUN open courseware의 '3.2 B-spline Basis Function' 부분을 천천히 읽어보는 것이 제일 좋은 것 같다.)
Bezier Curve and B-Spline Curve
Bezier Curve와 B-Spline Curve를 비교해보면 아래 그림과 같다. 아래에 있는 일반화된 식을 이용하여 여러개의 control point를 갖는 spline curve를 나타낼 수 있다.
NURBS (Non-Uniform Rational B-Spline)
STEP-file에서 표현되는 B-spline curve들과 surface들은 NURBS라 볼 수 있다.
Curve에서 control point들과 knot들이 어떻게 관계가 있는지, 비균일 유리 B-스플라인의 '매듭과 컨트롤 포인트'에 설명되어 있는 부분이 이해하는데 도움 되었다.
Curve에서 control point들과 knot들이 어떻게 관계가 있는지, 비균일 유리 B-스플라인의 '매듭과 컨트롤 포인트'에 설명되어 있는 부분이 이해하는데 도움 되었다.
댓글
댓글 쓰기