Line VS Bezier Curve
Kurva Bezier Sesi 09 Dosen Pembina Danang Junaedi Sriyani Violina IF-UTAMA
1
IF-UTAMA
Other Curves
IF-UTAMA
2
Drawing the Curve (1)
3
Drawing the Curve (2)
IF-UTAMA
4
Algoritma de Casteljau • Algoritma untuk untuk membuat membuat kurva menggunakan menggunakan sejumlah titik kontrol, dan menggunakan menggunakan teknik in-betweening in-betweening untuk mendapatkan kurva yang diinginkan. • Dikembangkan oleh P. de Casteljau, Casteljau, dan merupakan merupakan cikal bakal kurva Bezier, yang secara terpisah dikembangkan lebih lanjut oleh P. Bezier. • Implementasi Algoritma Algoritma de de Casteljau yang paling paling sederhana adalah pembentukan kurva berdasarkan 3 titik kontrol yaitu P1
P1
P11(t)
P01(t) P02(t)
IF-UTAMA
5
P0
P2
IF-UTAMAP0
P2
6
1
Representasi de Casteljau
IF-UTAMA
Representasi de Casteljau
7
Bezier Curve • • • • • •
IF-UTAMA
8
Kurva Bezier
Bezier curves are used in computer graphics to produce curves which appear reasonably smooth at all scales (as opposed to polygonal lines, which will not scale nicely). Bezier curves are named after their inventor, Dr. Pierre Bezier. Bezier was an engineer with the Renault car company and set out in the early 1960’s to develop a curve formulation which would lend itself to shape design. The Bezier curve is a parametric function of four points; two endpoints and two “control” points. The curve connects the endpoints, but doesn’t necessarily touch the control points. The general form Bezier equation, which describes each point on the curve as a function of time
IF-UTAMA
9
Kurva Bezier
IF-UTAMA
10
Kurva bezier Perhitungan bezier bisa dibantu dengan cara sebagai berikut : – Untuk n titik kontrol maka persamaan kurva bezier adalah (x+y)n-1 – Ganti x dengan (1-t) dan y dengan t, kemudian selesaikan persamaan dengan titik yang dimaksud
IF-UTAMA
11
IF-UTAMA
12
2
Contoh soal
solusi a. Dengan kenaikan sebanyak 0.02 maka jumlah titik yang diperlukan antara 0 dan 1 adalah
Diketahui 3 buah titik kontrol dengan koordinat C1(1,2), C2(7,10), C3(15,4) , dengan menggunakan kenaikan t=0.02 maka tentukanlah:
1 t
1 =
0.02
=
50titik
b. Karena terdiri dari 3 titik kontrol maka persamaan menjadi :
1. Berapa titik yang digunakan untuk membangun kurva bezier? 2. Berapa nilai titik pada kurva pada saat t=0.8?
(x+y)3-1= (x+y)2 x2 + 2xy + y2 = 0 x = (1-t) dan y = t Maka persamaan tersebut menjadi : L(t) = (1-t)2 + 2(1-t)t + t 2
IF-UTAMA
13
Solusi (lanjutan)
Diketahui 4 buah titik kontrol dengan koordinat C1(0,1), C2(1,2), C3(2,2), C4(3,1) dengan menggunakan kenaikan t=0.02 maka tentukanlah:
= (1-t)2.x1 + 2(1-t)t.x2 + t2.x3 = (1-t)2.y1 + 2(1-t)t.y2 + t2.y3
Catatan : x1, x2, x3, y1, y2 dan y3 diambil dari titik kontrol
x
= (1-0.8)2.1 + 2(1-0.8)(0.8).7 + (0.8) 2.15
x
= 0.04 + 2.24 + 9.6 = 11.88 ~ 12
y y
= (1-0.8)2.2 + 2(1-0.8)(0.8).10 + (0.8) 2.4 = 0.08 + 3.2 + 2.56 = 5.84 ~ 6
14
Soal (untuk 4 titik kontrol)
Titik untuk t=0.8
x y
IF-UTAMA
Berapa nilai titik pada kurva pada saat t=0.8?
Nilai titik pada kurva saat t = 0.8 adalah (12,6) IF-UTAMA
15
IF-UTAMA
16
Linear Bézier curves • Given points P0 and P1, a linear Bézier curve is simply a straight line between those two points. The curve is given by
Ilustrasi Pembuatan Kurva Bezier en.wikipedia.org/wiki/Bézier_curve
• and is equivalent to linear interpolation.
IF-UTAMA
17
IF-UTAMA
18
3
Quadratic Bézier curves
Ilustrasi: kurva linier • The t in the function for a linear Bézier curve can be thought of as describing how far B(t ) is from P0 to P1. • For example when t=0.25 , B(t ) is one quarter of the way from point P0 to P1. • As t varies from 0 to 1, B(t ) describes a curved line from P0 to P1. IF-UTAMA
19
• A quadratic Bézier curve is also a parabolic segment. IF-UTAMA
20
Cubic Bézier curves
Ilustrasi: kurva kuadratik • For quadratic Bézier curves one can construct intermediate points Q0 and Q1 such that as t varies from 0 to 1: • Point Q0 varies from P0 to P1 and describes a linear Bézier curve. • Point Q1 varies from P1 to P2 and describes a linear Bézier curve. • Point B(t ) varies from Q0 to Q1 and describes a quadratic IF-UTAMA 21 Bézier curve.
Ilustrasi : Kurva Cubic
• Four points P0, P1, P2 and P3 in the plane or in three-dimensional space define a cubic Bézier curve. • The curve starts at P0 going toward P1 and arrives at P3 coming from the direction of P2. Usually, it will not pass through P1 or P2; these points are only there to provide directional information. The distance between P0 and P1 determines "how long" the curve moves into direction P2 before turning towards P3. • The parametric form of the curve is: IF-UTAMA
22
Ilustrasi: Fourth-order curve
• For higher-order curves one needs correspondingly more intermediate points. For cubic curves one can construct intermediate points Q0,Q1 & Q2 th at describe linear Bézier curves, and points R0 & R1 that describe quadratic Bézier curves IF-UTAMA
• A quadratic Bézier curve is the path traced by the function B(t ), given points P0, P1, and P2,
23
• For fourth-order curves one can construct intermediate points Q0, Q1, Q2 & Q3 that describe linear Bézier curves, points R0, R1 & R2that describe quadratic Bézier curves, and points S0 & S1 that describe cubic Bézier curves IF-UTAMA
24
4
The Math Behind the Bezier Curve • A cubic Bezier curve is defined by four points. • Two are endpoints .
www.moshplant.com/director/bezier/math.html
– (x 0 ,y 0 ) is the origin endpoint. – (x 3 ,y 3 ) is the destination endpoint. IF-UTAMA
25
• The points (x 1,y 1) and (x 2 ,y 2 ) are control points . IF-UTAMA
26
• This is how the equations are defined in Adobe's PostScript references. x(t) = a x t 3 + b x t 2 + c x t + x 0 x 1 = x 0 + c x / 3 x 2 = x 1 + (c x + b x ) / 3 x 3 = x 0 + c x + b x + a x
• Two equations define the points on the curve. Both are evaluated for an arbitrary number of values of t between 0 and 1. • As increasing values for t are supplied to the equations, the point defined by x(t),y(t) moves from the origin to the destination. IF-UTAMA
y(t) = a y t 3 + b y t 2 + c y t + y 0 y 1 = y 0 + c y / 3 y 2 = y 1 + (c y + b y ) / 3 y 3 = y 0 + c y + b y + a y 27
IF-UTAMA
• This method of definition can be reverseengineered, so:
Referensi 1. 2.
c x = 3 (x 1 - x 0 ) b x = 3 (x 2 - x 1) - c x a x = x 3 - x 0 - c x - b x
3.
4.
c y = 3 (y 1 - y 0 ) b y = 3 (y 2 - y 1) - c y a y = y 3 - y 0 - c y - b y IF-UTAMA
28
5.
29
-,2009, Chapter 8 - Kurva Beizer, Departement Teknik Informatika – IT Telkom David W. Smith ,-, Bezier Curve Ahead!, http://www.mactech.com/articles/mactech/Vol.05/05.01/BezierCur ve/ , Tanggal Akses: 10 November 2010 -,-, Bezier Curves, http://freespace.virgin.net/hugo.elias/graphics/x_bezier.htm atau http://freespace.virgin.net/hugo.elias/graphics/x_main.htm#3 , Tanggal Akses : 10 November 2010 Nils Pipenbrinck , 1999, DeCasteljau Algorithm, http://www.cubic.org/docs/bezier.htm Tanggal Akses : 10 November 2010 Bill Casselman,-, Bezier curves, http://www.math.ubc.ca/~cass/gfx/bezier.html, Tanggal Akses : 10 November 2010
IF-UTAMA
30
5