Computer aided ship design Computer aided ship design
Part 1. Curve & Surface Part 1. Curve & Surface
[2008][02-1][02-2]
Computer aided ship design Computer aided ship design
Part 1. Curve & Surface Part 1. Curve & Surface
September 2008 Prof. Kyu-Yeul Lee
Department of Naval Architecture and Ocean Engineering,
Seoul National University of College of Engineering
2.3.5 B
2.3.5 B--spline curve spline curve Interpolation Interpolation
2.3.5.1 Determine # of curve segments & Knots values 2.3.5.2 Problem definition of B-spline curve interpolation
2.3.5.3 Determine Bezier end control points by end tangent vectors 2.3.5.4 Determine Bezier control points by C
1continuity condition 2.3.5.5 Determine B-spline control points by C
2continuity condition 2.3.5.6 Tridiagonal matrix 해법을 이용한 B-spline 곡선 조정점 결정 2.3.5.7 Bessel end condition
2.3.5.8 Sample code of cubic B-spline curve interpolation 2.3.5.1 Determine # of curve segments & Knots values 2.3.5.2 Problem definition of B-spline curve interpolation
2.3.5.3 Determine Bezier end control points by end tangent vectors 2.3.5.4 Determine Bezier control points by C
1continuity condition 2.3.5.5 Determine B-spline control points by C
2continuity condition 2.3.5.6 Tridiagonal matrix 해법을 이용한 B-spline 곡선 조정점 결정 2.3.5.7 Bessel end condition
2.3.5.8 Sample code of cubic B-spline curve interpolation
Example of B
Example of B--spline spline Interpolation Interpolation
3
2.3.5.1 Determine # of Bezier curve segment & Knot value (1) 2.3.5.1 Determine # of Bezier curve segment & Knot value (1)
¡ Given: fitting points P
iand corresponding parameter t
iwhere, and
¡ First, determine # of Bezier curve segment and its knots m
i = 0 , 1 ,..., t
0= 0 , t
m= 1 ,
Given:
Find:
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
4
P 4
P 0
P 1
0
= 0 t
3 .
1
= 0
t t
4= 0 . 85
P 2
5 .
2
= 0 t
P 3
7 .
3
= 0 t
P 5
0 .
5
= 1 t
¡ 3: degree
¡ 2: # of Bezier curve segments
¡ # of control points
= 4 + (2-1) = 5
2.3.5.1 Determine # of Bezier curve segment & Knot value (2) 2.3.5.1 Determine # of Bezier curve segment & Knot value (2)
¡ Given: fitting points P
iand corresponding parameter t
iwhere, and
¡ First, determine # of Bezier curve segment and its knots m
i = 0 , 1 ,..., t
0= 0 , t
m= 1 ,
Given:
Find:
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
5
P 4
P 0
P 1
0
= 0 t
3 .
1
= 0
t t
4= 0 . 85
P 2
5 .
2
= 0 t
P 3
7 .
3
= 0 t
P 5
0 .
5
= 1 t
¡ 3: degree
¡ 3: # of Bezier curve segments
¡ # of control points
= 4 + (3-1) = 6
¡ How we determine Knots ? (= start / end points of each
cubic Bezier curve)
2.3.5.1 Determine # of Bezier curve segment & Knot value (3) 2.3.5.1 Determine # of Bezier curve segment & Knot value (3)
¡ Given: fitting points P
iand corresponding parameter t
iwhere, and
¡ determine # of Bezier curve segment to be (# of fitting point -1)
¡ ‚ We can determine knots to be the same as the parameters t
i¡ ƒ How about the B-spline control points ? m
i = 0 , 1 ,..., t
0= 0 , t
m= 1 ,
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
6
P 4
P 0
P 1
0
= 0 t
3 .
1
= 0
t t
4= 0 . 85
P 2
5 .
2
= 0 t
P 3
7 .
3
= 0 t
P 5
0 .
5
= 1
¡ 3: degree
t
¡ 5: # of Bezier curve segments
¡ # of control points
= 4 + (5-1) = 8
1
= 0
u
-u
3= 0 . 3 u
7= 1
u
10u
u
2 9u
8u u
105 .
4
= 0
u u
5= 0 . 7 u
6= 0 . 85
2.3.5.2 Problem definition of cubic B
2.3.5.2 Problem definition of cubic B--spline curve interpolation spline curve interpolation
p
1p
4p
3p
2d
2d
3d
4d
5d
6Given:
Find:
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
7
¡ 3: degree
¡ 5: # of Bezier curve segments
¡ # of knot = (5-1) + 2(3+1)
¡ # of control points
= 4 + (5-1) = (3+1) + (5-1)
p
0p
5u
0Δ
2u
1u
2u
-1u
3Δ
3u
4Δ
4u
5Δ
5u
6u
7u
8u
9Δ
6u
10d
0d
1d
6d
7u
가정: 각 곡선 세그먼트는3차Bezier Curve 이다.
연결점에서는C1, C2 연속조건을 만족한다.
2.3.5.3
2.3.5.3 Determine Bezier end
control points by end tangent vectors
p
1p
2p
4d
2d
3d
4d
5p
3 9= b
12
= b b
6=
b
3=
t 1
t 0
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
8
u
-1u
3u
4u
5u
6u
0u
1Δ
2Δ
3Δ
4Δ
5u
7u
8u
9Δ
61 0
t b
b b
t b
t b
b b
t b
, 3 ) (
3
, 3 ) (
3
6 15
14 6
14 15
1
2 0
1 2
0 1
0
- D D =
= -
+ D D =
= -
u
2u
10d
0d
1 6d
d
7= =
b
0= b
151
=
b = b
14p
0= p
5: Given or Known values
2.3.5.4
2.3.5.4 Determine Bezier control points by C 1 continuity condition
Δ
4Δ
5Δ
6Δ
5Δ
4Δ
3Δ
3Δ
23
1
b
p =
6
2
b
p = p
3= b
912
4
b
p = b
2b
4b
5b
7b
8b
10b
11b
1313 6 5
5 11
6 5
6 12
4
10 5 4
4 8
5 4
5 9
3
7 4 3
3 5
4 3
4 6
2
4 3 2
2 2
3 2
3 3
b b
b P
b b
b P
b b
b P
b b
b P
1D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
Given: Find:
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
9
u
-1u
3u
4u
5u
6u
0u
1Δ
2Δ
3Δ
4Δ
5u
7u
8u
9Δ
60
0
b
p =
3
1
b
p =
15
5
b
p = b
1b
2b
146 5 12
13 11
12
5 4 9
10 8
9
4 3 6
7 5
6
3 2 3
4 2
3
: )
( : ) (
: )
( : ) (
: )
( : ) (
: )
( : ) (
D D
= -
-
D D
= -
-
D D
= -
-
D D
= -
-
b b b
b
b b b
b
b b b
b
b b b
b
u
2u
1013 6 5
5 11
6 5
6 12
4
10 5 4
4 8
5 4
5 9
3
7 4 3
3 5
4 3
4 6
2
4 3 2
2 2
3 2
3 3
b b
b P
b b
b P
b b
b P
b b
b P
1D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
2.3.5.5
2.3.5.5 Determine B-spline control points by C 2 continuity condition (1)
Δ
4Δ
5Δ
6Δ
5Δ
4Δ
3Δ
3Δ
2b
10b
113
1
b
p =
6
2
b
p = p
3= b
912
4
b
p = b
2b
4b
5b
7b
8b
13b
14Δ
2Δ
3Δ
4Δ
3Δ
2Δ
4Δ
3Δ
4Δ
5Δ
6Δ
5d
2d
3d
4d
5d
6Δ
5Δ
61 1
0 0 0
d b
P d b
=
=
=
3 4 3 2
2 2
4 3 2
4 3 4
2 3 2
2 1
3 2
3 2
} {
} {
} {
} {
d d
b
d d
b
D + D + D + D D + D + D
D +
= D
D + D + D D + D
= D
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
10 0
0
b
p = p
5= b
15b
1b
2b
14Δ
2d
0d
1d
6d
7u-1
u
3 u4 u5 u6u0 u1
Δ2 Δ3 Δ4 Δ5 u7
u8 u9 Δ6
u2 u10
3 4 3 2
2 2
4 3 2
4 3 4
2 3 2
2 1
3 2
3 2
} {
} {
} {
} {
d d
b
d d
b
D + D + D + D D + D + D
D +
= D
D + D + D D + D
= D
4 5 4 3
3 3
5 4 3
5 4 7
3 4 3 2
3 2 2
4 3 2
4 5
} {
} {
} {
} {
d d
b
d d
b
D + D + D + D D + D + D
D +
= D
D + D + D
D + + D
D + D + D
= D
5 6 5 4
4 4
6 5 4
6 5 10
4 5 4 3
4 3 3
5 4 3
5 8
} {
} {
} {
} {
d d
b
d d
b
D + D + D + D D + D + D
D +
= D
D + D + D
D + + D
D + D + D
= D
6 6 5
5 5
6 5
6 13
5 6 5 4
5 4 4
6 5 4
6 11
} {
} {
} {
} {
d d
b
d d
b
D + D + D D + D
= D
D + D + D
D + + D
D + D + D
= D
5 7 15
6 14
p d b
d b
=
=
=
2.3.5.5
2.3.5.5 Determine B-spline control points by C 2 continuity condition (2)
5 7
15
6 14
6 6 5
5 5
6 5
6 13
5 6 5
4
5 4
4 6 5
4
6 11
5 6 5
4
4 4
6 5
4
6 5
10
4 5 4
3
4 3
3 5 4
3
5 8
4 5 4
3
3 3
5 4
3
5 4
7
3 4 3
2
3 2
2 4 3
2
4 5
} {
} {
} {
} {
} {
} {
} {
} {
} {
} {
} {
} {
p d
b
d b
d d
b
d d
b
d d
b
d d
b
d d
b
d d
b
=
=
=
D + D + D D
+ D
= D
D + D + D
D + + D
D + D + D
= D
D + D + D + D D
+ D + D
D +
= D
D + D + D
D + + D
D + D + D
= D
D + D + D + D D
+ D + D
D +
= D
D + D + D
D + + D
D + D + D
= D
C
1, C
2조건을 이용하여 P
i에 관한 식 유도
13 6 5
5 11
6 5
6 12
4
10 5 4
4 8
5 4
5 9
3
7 4 3
3 5
4 3
4 6
2
4 3 2
2 2
3 2
3 3
b b
b P
b b
b P
b b
b P
b b
b P
1D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
Given:
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
Find:
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
11 5
7 15
6 14
6 6 5
5 5
6 5
6 13
5 6 5
4
5 4
4 6 5
4
6 11
5 6 5
4
4 4
6 5
4
6 5
10
4 5 4
3
4 3
3 5 4
3
5 8
4 5 4
3
3 3
5 4
3
5 4
7
3 4 3
2
3 2
2 4 3
2
4 5
} {
} {
} {
} {
} {
} {
} {
} {
} {
} {
} {
} {
p d
b
d b
d d
b
d d
b
d d
b
d d
b
d d
b
d d
b
=
=
=
D + D + D D
+ D
= D
D + D + D
D + + D
D + D + D
= D
D + D + D + D D
+ D + D
D +
= D
D + D + D
D + + D
D + D + D
= D
D + D + D + D D
+ D + D
D +
= D
D + D + D
D + + D
D + D + D
= D
13 6 5
5 11
6 5
6 12
4
10 5 4
4 8
5 4
5 9
3
7 4 3
3 5
4 3
4 6
2
4 3 2
2 2
3 2
3 3
b b
b P
b b
b P
b b
b P
b b
b P
1D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
D + D + D D
+ D
= D
=
3 4 3
2
2 2
4 3
2
4 3
4
2 3 2
2 1
3 2
3 2
1 1
0 0
0
} {
} {
} {
} {
d d
b
d d
b
d b
P d
b
D + D + D + D D
+ D + D
D +
= D
D + D + D D
+ D
= D
=
=
=
2.3.5.5
2.3.5.5 Determine B-spline control points by C 2 continuity condition (3)
3 1 2 1 1 1
3 2 2 2 3 2 4
3 3 2 2 4 3 2 3 2
1 3 2 4 3 2 2 3 4 3 2 3 2 1
] ) ( ) /(
)}
)(
( ) (
{
) /(
) (
) ) [(
)(
(
1
d d
d
d d
d P
g b
a + +
=
D + D
+ D D
+ D D + D D + D + D + D D D +
D + D D + D + D D D
+ D + D D +
= D
4 2 3 2 2 2 4 2 3 3 5 4 3
3 2 4 2 2 4 5 4 3 4 3 2
] ) ( )}
(
) (
{ )
) [(
)(
(
1
d d
d d
d
d P
g b
a + +
= D
+ D
+ D D
+ D + D D + D D
+ D + D D +
= D
5 3 4 3 3 3 5 6 5 4
5 4 3 2 4 4 6 5 4 5
4 3 6 5 4
6 5 4 4 3 5 3 2 5 5 4 3 5 4 3
] ) /(
) (
) ( ) /(
)}
)(
(
) )(
( { )
) [(
)(
(
1
d d
d d
d
d P
g b
a + +
= D
+ D + D
D + D + D D + D
+ D + D D
+ D + D D + D D +
D + D + D D + D D + D D
+ D + D D +
= D
) )(
(
) (
) /(
)} (
) (
) (
) { (
) )(
(
) (
2 1 3 2 1
2 1
2 1 3
2 1
3 2 1 2
1 1 2
2 1 2 1
2 2
+ + + + +
+
+ + +
+ +
+ + + +
+ + +
+ + + +
+
D + D D + D + D
= D
D + D D
+ D + D
D + D + D
D + D + D
D + D
= D
D + D D + D + D
= D
i i i i i
i i
i i i
i i
i i i i
i i
i i i i
i i i i i
i i
g b a
곡선 상의 점pi, ti 곡선의 놋트uj
양끝단의 접선 벡터t0, t1
곡선 상의 점pi을 지나고 C2 연속 조건을 만족하는 3차B-spline 곡선 r(u) (B-spline 조정점: di)
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
7 12
6 5 4 3 2 1 0
6 6 4 4 4
3 3 3
2 2 2
1 1 1 2 2
5 1 4 3 2 1 0 0
1 0 0 0 0 0 0 0
3 0 3
0 0 0 0 0
0 0
0 0 0
0 0 0
0 0
0 0 0 0
0
0 0 0 0 0
0 0 0 0 0 3 0
3
0 0 0 0 0 0 0 1
d d d d d d d d
p t p p p p t p
D D - D
D -
=
g b a
g b a
g b a
g b a
5 3 4 3 3 3 5 6 5 4
5 4 3 2 4 4 6 5 4 5
4 3 6 5 4
6 5 4 4 3 5 3 2 5 5 4 3 5 4 3
] ) /(
) (
) ( ) /(
)}
)(
(
) )(
( { )
) [(
)(
(
1
d d
d d
d
d P
g b
a + +
= D
+ D + D
D + D + D D + D
+ D + D D
+ D + D D + D D +
D + D + D D + D D + D D
+ D + D D +
= D
6 4 5 4 4 4 6 6 5 4 2 5
5 6 5 4 6 5 5 4 6
4 2 6 6 5 4 6 5 4
] ) (
) (
)}
( )
( {
) ) [(
)(
(
1
d d
d d
d
d P
g b
a + +
= D
+ D + D D +
D + D + D D D + D + D D
+ D D
+ D + D D +
= D
주어진 것 구해야 하는 것
2.3.5.6 Tridiagonal matrix
2.3.5.6 Tridiagonal matrix 해법을 해법을 이용한 이용한 B B--spline spline 곡선 곡선 조정점 조정점 ( ) ( ) 결정
결정 (1) (1)
7 6 5 4 3 2 1 0
6 6
4 4
4
3 3
3 2 2 2
1 1
1 2 2
5 1 4 3 2 1 0 0
1 0
0 0
0 0
0 0
3 0 3
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0 3 0
3
0 0
0 0
0 0
0 1
d d d d d d d d
p t p p p p t p
D D
- D
D -
=
g b
a g b a
g b a
g b a
d i
13 7
6 5 4 3 2 1 0
6 6
4 4
4
3 3
3 2 2 2
1 1
1 2 2
5 1 4 3 2 1 0 0
1 0
0 0
0 0
0 0
3 0 3
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0
0 0
0 0
0 3 0
3
0 0
0 0
0 0
0 1
d d d d d d d d
p t p p p p t p
D D
- D
D -
=
g b
a g b a
g b a
g b a
AX D =
D
= = A = X
주어진 것 계산할 수 있는 것 구해야 하는 것
D A
X = - 1
그런데 행렬 A가 Tri-diagonal matrix이므로 간단하게 A
-1를 계산할 수 있음
2.3.5.6 Tridiagonal matrix
2.3.5.6 Tridiagonal matrix 해법을 해법을 이용한 이용한 B B--spline spline 곡선 곡선 조정점 조정점 ( ) ( ) 결정
결정 (2) (2)
d i
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- -
-
n n
n n
n
b a
c b
a c
b a
c b
a c b
0 0
0 0
0 0
1 1
1 2
2 2
1 1
1 0 0
O O
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- n n
x x
x x x
1 2 1 0
M M
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- n n
d d
d d d
1 2 1 0
M M
d Ax =
대각 성분과 그 위 / 아래 , 좌 / 우 성분만 0 이 아닌 값이고 , 나머지 성분은 0 값인 행렬 즉, 대각 성분을 중심으로 3개의 성분만 0이 아닌 값 Æ Tri + Diagonal
대각 성분과 그 위 / 아래 , 좌 / 우 성분만 0 이 아닌 값이고 , 나머지 성분은 0 값인 행렬 즉, 대각 성분을 중심으로 3개의 성분만 0이 아닌 값 Æ Tri + Diagonal
Tridiagonal matrix
LU A =
①
ü
ü ? ? ü ü ü
ü ü ü ü ü
를 과 의 곱으로 분해
A L U
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
14
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- -
-
n n
n n
n
b a
c b
a c
b a
c b
a c b
0 0
0 0
0 0
1 1
1 2
2 2
1 1
1 0 0
O O
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- n n
x x
x x x
1 2 1 0
M M
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- n n
d d
d d d
1 2 1 0
M M
A x = d
d LUx =
d Ly =
y Ux =
②
③
ü
ü !! ü ü ü
ü ? ? !!
와 를 알고 있을 때 , 구하기
A d x
를 과 의 곱으로 분해
A L U
를 로 치환
Ux y
를 과 의 곱으로 분해
A L U
①
를 만족하는 구하기
d
Ly = y
②
를 만족하는 를 구하면 , 곧 를 만족하는 를 구하는 것임
y
Ux = x Ax = d x
③
2.3.5.6 Tridiagonal matrix
2.3.5.6 Tridiagonal matrix 해법을 해법을 이용한 이용한 B B--spline spline 곡선 곡선 조정점 조정점 ( ) ( ) 결정
결정 (3) (3)
d i
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- -
-
n n
n n
n
b a
c b
a c b a
c b a
c b
0 0
0 0
0 0
1 1
1 2
2 2
1 1 1
0 0
O O
LU A =
① ü ü ü ü ü ü
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- -
n n
n n
b a
b a
b a
b a b
0
0 0
0 0
0 0
1 1
2 2 1 1 0
O O
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
1 0 1 0 0 1
0
0 1
0
0 1
3 2 1
g
ng g g
O O
15
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- -
-
n n
n n
n
b a
c b
a c b a
c b a
c b
0 0
0 0
0 0
1 1
1 2
2 2
1 1 1
0 0
O O
A = L
d Ax =
LU A =
d LUx =
y Ux = d Ly =
①
②
③
ü ü ?? üü
ü
ü üü üü
ü
ü !! üü ü ü
? ?
!!ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- -
n n
n n
b a
b a
b a
b a b
0
0 0
0 0
0 0
1 1
2 2 1 1 0
O O
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
1 0 1 0 0 1
0
0 1
0
0 1
3 2 1
g
ng g g
O O
U
0 0
= b
b c
0= b
0g
11 1
= a
a b
1= a
1g
1+ b
1c
1= b
1g
22 2
= a
a b
2= a
2g
2+ b
2c
2= b
2g
31
1 -
-
=
na
na b
n-1= a
n-1g
n-1+ b
n-1c
n-1= b
n-1g
n na
n= a b
n= a
ng
n+ b
nM M
M
ü
ü üü üü üü üü ü
ü üü üü üü üü üü üü
i i
= a a
1 1 1
1 + + +
+
=
i-
i ii
b a g
b
i i i
c g
+1= b
n i = 1 , L ,
1 , ,
0 -
= n
i L
0
with b
0= b
1 , ,
0 -
= n
i L
2.3.5.6 Tridiagonal matrix
2.3.5.6 Tridiagonal matrix 해법을 해법을 이용한 이용한 B B--spline spline 곡선 곡선 조정점 조정점 ( ) ( ) 결정
결정 (4) (4)
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- -
n n
n n
b a
b a
b a
b a b
0
0 0
0 0
0 0
1 1
2 2 1 1 0
O O
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- n n
y y
y y y
1 2 1 0
M M
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- n n
d d
d d d
1 2 1 0
M M
d Ly =
② ü ü !! ü ü
d i
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
16
L =
d Ax =
LU A =
d LUx =
y Ux = d Ly =
①
②
③
ü ü ?? üü
ü
ü üü üü
ü
ü !! üü ü ü
? ?
!!ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- -
n n
n n
b a
b a
b a
b a b
0
0 0
0 0
0 0
1 1
2 2 1 1 0
O O
d
i i i i i
y y d
b a
-1= -
n i = 1 , L ,
0 0
with
0b y = d ú
ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- n n
y y
y y y
1 2 1 0
M M
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- n n
d d
d d d
1 2 1 0
M M
y
0 0 0
y = d b
1 1 1 0
1
y + b y = d a
2 2 2 1
2
y + b y = d a
M
1 1
1 2
1 - - - -
- n
+
n n=
nn
y b y d
a
n n n n
n
y
-+ b y = d a
1ü ü ü
ü
!!
ü
ü
!!
üü!!
üüForward
substitution
2.3.5.6 Tridiagonal matrix
2.3.5.6 Tridiagonal matrix 해법을 해법을 이용한 이용한 B B--spline spline 곡선 곡선 조정점 조정점 ( ) ( ) 결정
결정 (5) (5)
y Ux =
③ ü ü ? ? !!
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
1 0 1 0 0 1
0
0 1
0
0 1
3 2 1
g
ng g g
O O
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- n n
x x
x x x
1 2 1 0
M M
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- n n
y y
y y y
1 2 1 0
M M
d i
17
=
d Ax =
LU A =
d LUx =
y Ux = d Ly =
①
②
③
ü ü ?? üü
ü
ü üü üü
ü
ü !! üü ü ü
? ?
!!1 1 +
-
+=
i i ii
y x
x g
0 , , 1 L -
= n i
n
n
y
x = with
y
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
1 0 1 0 0 1
0
0 1
0
0 1
3 2 1
g
ng g g
O O
U
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
- n n
x x
x x x
1 2 1 0
M M
x
ú ú ú ú ú ú ú ú ú
û ù
ê ê ê ê ê ê ê ê ê
ë é
=
- n n
y y
y y y
1 2 1 0
M M
0 1 0
0
x y
x + g =
1 2 1
1
x y
x + g =
2 3 2
2
x y
x + g =
1 1
1 - -
-
+
n n=
nn
x y
x g
n
n
y
x = M
? !!
?
? !!
ü
?
?
ü?
Backward
substitution
2.3.5.7 Bessel End Condition (1) 2.3.5.7 Bessel End Condition (1)
¡ B-spline curve interpolation 에서 양끝점에서의 접선벡터 t
0, t
1이 주어지지 않았을 때 , (1) 곡선의 양끝의 연속된 세 점으로부터 2차 곡선(quadratic curve)을 생성하고,
(2) 생성된 2 차 곡선의 양 끝점에서의 1 차 미분값을 우리가 생성하고자 하는 B-spline curve 의 양 끝점에서의 접선 벡터로 가정하는 방법
d
2d
4t
0t
1Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
18
p
0= d
0d
1p
1p
2d
3p
3d
5p
4= d
6u
2u
3u
4u
5u
6u
1u
0u u
87Δ
2Δ
3Δ
4Δ
5t
12.3.5.7 Bessel End Condition(2) 2.3.5.7 Bessel End Condition(2)
p
2p
1p
m-2p
m-1p
0= d
0d
1d
2p
1p
2d
3p
3d
4d
5p
4= d
6u
2u
3u
4u
5u
6u
1u
0u u
87Δ
2Δ
3Δ
4Δ
5t
0t
1곡선의 시작 부분 곡선의 끝 부분
19
p
0u
1u
2u
3D
3D
2u
4u
0p
m2 -
u
K 1 -u
K 5K-
u D
K-5u
K-4D
K-4u
K-3) ) (
) (
) (
( 2
23 2 3
2 1
3 2
3 2 0
3 2 2
3
2
p p p
t D D + D
- D D
D D + + D
D + D D
D + - D
s
=
) ) (
) 2
(
) (
) ( (
4 4
5
5 4
1 4
5
4 5
2 4
5 5
4
m K K
K
K K
m K
K
K K
m K
K K
K e
p
p p
t
- - -
- -
- -
-
- -
- -
- -
-
D D + D
D + + D
D D
D + - D
D + D D
= D
t
0t 1
2.3.5.8 Sample code of
2.3.5.8 Sample code of Cubic B Cubic B--spline spline Curve Curve (1) (1)
#ifndef __CubicBspline_h__
#define __CubicBspline_h__
#include "vector.h“
class CubicBsplineCurve { public:
Vector* m_ControlPoint; int m_nControlPoint;
double* m_Knot; int m_nKnot; int m_nDegree;
………
void SetControlPoint(Vector* pControlPoint, int nControlPoint);
void SetKnot(double* pKnot, int nKnot);
Vector CalcPoint(double u);
double N(int d, int i, double u);
void Interpolate(Vector *pFittingPoint, int nFittingPoint);
void Parameterization(int nType, Vector* FittingPoint, int nPoint, double* t);
};
#endif
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
20
#ifndef __CubicBspline_h__
#define __CubicBspline_h__
#include "vector.h“
class CubicBsplineCurve { public:
Vector* m_ControlPoint; int m_nControlPoint;
double* m_Knot; int m_nKnot; int m_nDegree;
………
void SetControlPoint(Vector* pControlPoint, int nControlPoint);
void SetKnot(double* pKnot, int nKnot);
Vector CalcPoint(double u);
double N(int d, int i, double u);
void Interpolate(Vector *pFittingPoint, int nFittingPoint);
void Parameterization(int nType, Vector* FittingPoint, int nPoint, double* t);
};
#endif
2.3.5.8 Sample code of
2.3.5.8 Sample code of Cubic B Cubic B--spline spline Curve Curve (2) (2)
void CubicBsplineCurve::Interpolate(Vector *pFittingPoint, int nFittingPoint) {
// Generate Knot
if(m_Knot) delete[] m_Knot;
m_nKnot = (m_nFittingPoint - 2) + 2*(3+1);
m_Knot = new double [m_nKnot];
// Use Chord length or Centripetal method
……
//--- // Generate Matrix : (L+1) * (L+1)
int L = m_nFittingPoint + 1; // (L+1)*(L+1) size Matrix
// Fill rhs
Vector* rhs = new Vector[L+1];
for(i = 1; i <= L-1 ; i++) rhs[i] = pFittingPoint[i-1];
// Bessel End condition
rhs[0] = rhs[1]; rhs[L] = rhs[L-1];
rhs[1] = StartTangentByBesselEndCondition; rhs[L-1] = EndTangentByBesselEndCondition;
1.0
0.5
1.5
p
0p
1p
2p
3Set knot using chord length Set knot using chord length
21 void CubicBsplineCurve::Interpolate(Vector *pFittingPoint, int nFittingPoint)
{
// Generate Knot
if(m_Knot) delete[] m_Knot;
m_nKnot = (m_nFittingPoint - 2) + 2*(3+1);
m_Knot = new double [m_nKnot];
// Use Chord length or Centripetal method
……
//--- // Generate Matrix : (L+1) * (L+1)
int L = m_nFittingPoint + 1; // (L+1)*(L+1) size Matrix
// Fill rhs
Vector* rhs = new Vector[L+1];
for(i = 1; i <= L-1 ; i++) rhs[i] = pFittingPoint[i-1];
// Bessel End condition
rhs[0] = rhs[1]; rhs[L] = rhs[L-1];
rhs[1] = StartTangentByBesselEndCondition; rhs[L-1] = EndTangentByBesselEndCondition;
p
0p
30 .
2 0
1 0 1
=
-
u u u
u u3 =1.0 u4 =1.5
0 .
8 4
7 6 5
= u u u u
1.0 0.5 1.5
2.3.5.8 Sample code of
2.3.5.8 Sample code of Cubic B Cubic B--spline spline Curve Curve (2) (2)
void CubicBsplineCurve::Interpolate(Vector *pFittingPoint, int nFittingPoint) {
// Generate Knot
if(m_Knot) delete[] m_Knot;
m_nKnot = (m_nFittingPoint - 2) + 2*(3+1);
m_Knot = new double [m_nKnot];
// Use Chord length or Centripetal method
……
//--- // Generate Matrix : (L+1) * (L+1)
int L = m_nFittingPoint + 1; // (L+1)*(L+1) size Matrix
// Fill rhs
Vector* rhs = new Vector[L+1];
for(i = 1; i <= L-1 ; i++) rhs[i] = pFittingPoint[i-1];
// Bessel End condition
rhs[0] = rhs[1]; rhs[L] = rhs[L-1];
rhs[1] = StartTangentByBesselEndCondition; rhs[L-1] = EndTangentByBesselEndCondition;
2 3 2
3 2
1 3
2 3 2
0 3 2
2
3 2
) (
) (
) (
2
p p
p t
D + D D - D
D D
D + + D
D + D D
D + - D
s
=
Bessel End Condition Bessel End Condition
Computer Aided Ship Design 2008
Computer Aided Ship Design 2008 –– PART I: Curve & SurfacePART I: Curve & Surface
22 void CubicBsplineCurve::Interpolate(Vector *pFittingPoint, int nFittingPoint)
{
// Generate Knot
if(m_Knot) delete[] m_Knot;
m_nKnot = (m_nFittingPoint - 2) + 2*(3+1);
m_Knot = new double [m_nKnot];
// Use Chord length or Centripetal method
……
//--- // Generate Matrix : (L+1) * (L+1)
int L = m_nFittingPoint + 1; // (L+1)*(L+1) size Matrix
// Fill rhs
Vector* rhs = new Vector[L+1];
for(i = 1; i <= L-1 ; i++) rhs[i] =