Lecture - 3
Lecture - 3
Lecture - 3
Vector Graphics
M. I. Jubair 1
Outline
• Vector Image
• Curves
• Polynomial Curves
• Bézier Curves
2
Vector Image (1/3)
Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner 3
Vector Image (2/3)
4
Vector Image (3/3)
5
Curves (1/2)
6
Curves (2/2)
How many dimensions in the curve?
- It lies on 2D plane, but actually it’s 1D
Credit: https://umd.instructure.com/courses/1286262/modules 7
Polynomial Curve (1/1)
• A polynomial is a sum of variables raised to powers and multiplied by
coefficients
∑(aᵢxⁱ) = a₀ + a₁x + a₂x² + . . . + aₙxⁿ
9
Bézier Curves (2/3)
Parametric Equation
• Bézier Curves are expressed as parametric equations
• A parameter t is used to determine the value
𝑥(𝑡) = (1 − 𝑡)𝑥₀ + 𝑡𝑥₁
𝑦(𝑡) = (1 − 𝑡)𝑦₀ + 𝑡𝑦₁
10
Bézier Curves (3/3)
Control Points
• A Bézier curve is defined by a set of control points
• An N degree Bézier curve is define by (N+1) control points
• For N control points, degree 𝑑 = 𝑁 − 1
11
Bézier Curves Derivation (1/13)
Derivation of a quadratic Bézier curve
• A quadratic (d=2) Bézier curve has 3 control points (P0, P1, P2)
• Assume Q0 and Q1 lies on the line P0 P1 and P1 P2
𝑄0 = 𝑃₀ + 𝑢(𝑃₁ − 𝑃₀)
𝑄1 = 𝑃1 + 𝑢(𝑃2 − 𝑃1)
• Point on the Bezier curve lies on the line Q0 Q1
𝑄 𝑢 = 𝑄₀ + 𝑢(𝑄₁ − 𝑄₀)
Where u is a parameter ranges between 0 to 1
12
Bézier Curves Derivation (2/13)
P1 Control Point
P0 P2
13
Bézier Curves Derivation (3/13)
at u = 0,
Q0 = P0 P1
Q1 = P1 Q1
Q0
P0 P2
14
Bézier Curves Derivation (4/13)
at u = 0,
Q = P0 P1
Q1
Q0
P0 P2
15
Bézier Curves Derivation (5/13)
at u = 0.1,
P1
Q1
Q0
P0 P2
16
Bézier Curves Derivation (6/13)
at u = 0.2,
P1
Q1
Q0
P0 P2
17
Bézier Curves Derivation (7/13)
at u = 0.5,
P1
Q0 Q1
P0 P2
18
Bézier Curves Derivation (8/13)
at u = 1,
P1
Q0
Q1
P0 P2
19
Bézier Curves Derivation (9/13)
P1
P0 P2
20
Bézier Curves Derivation (10/13)
• Assume Q0 and Q1 lies on the line P0 P1 and P1 P2
𝑄0 = 𝑃₀ + 𝑢(𝑃₁ − 𝑃₀)
𝑄1 = 𝑃1 + 𝑢(𝑃2 − 𝑃1)
• 𝑄 𝑢 is the point on the Bezier curve on the line Q0 Q1
𝑄 𝑢 = 𝑄₀ + 𝑢(𝑄₁ − 𝑄₀)
• Combining them gives
𝑄 𝑢 = 1−𝑢 2 𝑃0 + 2𝑢 1 − 𝑢 𝑃1 + 𝑢2 𝑃2
21
Bézier Curves Derivation (11/13)
de Casteljau’s Algorithm
• This derivation is known is de Casteljau’s Algorithm
• Let Pi,j denote the control points
• where Pi,0 are the original control points P0 to P2
Pi,1 are the points Q1 to Q2
P0,2 is the Q(u) then,
Pi, j = (1 - u) Pi, j−1 + u Pi+1, j−1
22
Bézier Curves Derivation (12/13)
de Casteljau’s Algorithm P1,0
P0,1 P0,2
P1,1
P0,0 P2,0
P0, 2 = (1− u) P0,1 + u P1,1
P0, 2 = (1 − u) [(1−u) P0,0 + u P1,0] + u [(1−u) P1,0 + u P2,0]
P0, 2 = (1 − u)2 P0,0 + 2u (1−u) P1,0 + u2 P2,0 23
Bézier Curves Derivation (13/13)
For cubic Bézier Curves with 4 control points
P0, 3 = (1−u)3 P0,0 + 3u (1−u)2 P1,0 + 3u2 (1−u) P2,0 + u3 P3,0
P1,0 P1,1
P2,0
P0,2 P1,2
P0,3
P0,1 P2,1
P0,0 P3,0 24
General form of Bézier Curves
General form of Bézier Curves:
d
Q(u ) Bi ,d (u )Pi 0 u 1
i 0
….. Do calculations ….
… Do calculations …
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach 35
B-Spline Curve (2/4)
P3
P4
P1 – P4 P2 – P5
P2
P0 – P3 P5
P1
P0
Cubic B-Spline Curve with 6 control Points 36
B-Spline Curve (3/4)
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
B-Spline Curve (4/4)
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Cox-de Bour formula (1/1)
• The blending function Ni,k(t) is defined by Cox-de Bour recursion
formula,
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Uniform Quadratic B-spline (2/4)
• Equation of a quadratic B-spline curve is
n
P(t ) N i ,k (t )Pi
i 0
• when t2 ≤ t ≤ t3
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Uniform Quadratic B-spline (3/4)
• which can be written in matrix form as:
where i = 0, 1,...,n − k + 1
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Uniform Quadratic B-spline (4/4)
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Open Uniform B-spline curves (2/3)
• Matrix form of an open uniform B-spline curve is
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Open Uniform B-spline curves (3/3)
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Practice Problem 2
An uniform quadratic B-Spline curve is defined by 5 control points P0(1, 2),
P1(3, 8), P2(5, 2), P3(7, 1) and P4(8, 0). Find the points on the curve
segments for t = 0
solution:
k = 2, n = 4
Number of curve segments = n – k + 1 = 4 – 2 + 1 = 3
1 2 1 t
2
1
Si (0) Pi Pi 1 Pi 2 2 2 1 t
2
1 0 0 1
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Practice Problem 2
1 2 1 t
2 1 2 1 0
1 1 3 5 1 2
S 0(0) P0 P1 P2 2 2 1 t 2 2 2 1 0 5
2 8 2 2
1 0 0 1 1 0 0 1
1 2 1 t
2
P3 2 2 1 t
1
S 1(0) P1 P2 ?
2
1 0 0 1
1 2 1 t
2
S 2(0) P2 P3
P4 2 2 1 t
1 ?
2
1 0 0 1
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Practice Problem 3
An open uniform quadratic B-Spline curve is defined by 5 control points
P0(1, 2), P1(3, 8), P2(5, 2), P3(7, 1) and P4(8, 0). Find the points on the curve
segments for t = 0
solution:
k = 2, n = 4
Number of curve segments = n – k + 1 = 4 – 2 + 1 = 3
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Practice Problem 3
2 4 2 t
2 2 4 2 0
1 1 3 5 1 1
S 0(0) P0 P1 P2 3 4 0 t 2 3 4 0 0 2
2 8 2 2
1 0 0 1 1 0 0 1
1 2 1 t
2
P3 2 2 1 t
1
S 1(0) P1 P2 ?
2
1 0 0 1
1 2 1 t
2
S 2(0) P2 P3
P4 3 2 1 t
1 ?
2
2 0 0 1
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
Further Reading
• Fundamentals of Computer Graphics, 4th Edition - Chapter 15
• https://www.youtube.com/watch?v=2HvH9cmHbG4
• https://www.youtube.com/watch?v=qhQrRCJ-mVg
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach
End
Credit: Mathematics of Computer Graphics and Virtual Environments – Dr. Jon Siach