Music Education
  Shopping Stores
  Auctions
  Audio Electronics
  Books
  Business
  CDs
  Concert Tickets
  Downloads
  DVDs
  Magazines
  Memorabilia
  MP3 Players
  Musical Instruments
  P2P File Sharing
  Pro Audio Recording
  Promotion
  SEO Search Ranking
  Sheet Music
  Video Games
  Videos
   
  Artists
  Bands
  Biography
  Blogs
  Charts
  Education
  Forums
  Free Music
  Genres
  Guitar Tabs
  Lyrics
  MySpace Friendster
  News
  Newsletter
  Personals
  Radio
  Resources
  Reviews
  Ringtones
  Shopping
  Web Directory
   
  About Music.us
  Affiliate Program
  Contact Us
  Link To Us
  Marketing Advertising
  Music Industry
  Partners


WorldHistory.com Home
Sign up for the This Day In History Newsletter!

De Casteljau's algorithm

 

In the mathematical subfield of numerical analysis the de Casteljau's algorithm, named after its inventor Paul de Casteljau, is a recursive method to evaluate polynomials in Bernstein form or Bézier curves.

Although the algorithm is slower for most architectures when compared with the direct approach it is numerically more stable.

Definition

Given a polynomial B in Bernstein form of degree n

B(t) = \sum_^\beta_b_(t)

the polynomial at point t0 can be evaluated with recurrence relation

\beta_i^ := \beta_i \mbox i=0,\ldots,n
\beta_i^ := \beta_i^ (1-t_0) + \beta_^ t_0 \mbox i = 0,\ldots,n-j \mbox j= 1,\ldots n

with

B(t_0)=\beta_0^.

Notes

When doing the calculation by hand it is useful to write down the coefficients in a triangle scheme as

\begin

\beta_0 & = \beta_0^ & & & \\ & & \beta_0^ & & \\

\beta_1 & = \beta_1^ & & & \\ & & & \ddots & \\

\vdots & & \vdots & & \beta_0^ \\ & & & & \\

\beta_ & = \beta_^ & & & \\ & & \beta_^ & & \\

\beta_n & = \beta_n^ & & & \\

\end

When choosing a point t0 to evaluate a Bernstein polynomial we can use the two diagonals of the triangle scheme to construct a division of the polynomial

B(t) = \sum_^n \beta_i^ b_(t) \qquad \mbox \in [0,1]

into

B_1(t) = \sum_^n \beta_0^ b_(\frac) \qquad \mbox \in [0,t_0]

and

B_2(t) = \sum_^n \beta_^ b_(\frac) \qquad \mbox \in [t_0,1]

Example

We want to evaluate the Bernstein polynomial of degree 2 with the Bernstein coefficients

\beta_0^ = \beta_0
\beta_1^ = \beta_1
\beta_2^ = \beta_2 at the point t0.

We start the recursion with

\beta_0^ = \beta_0^ (1-t_0) + \beta_1^t = \beta_0(1-t_0) + \beta_1 t_0
\beta_1^ = \beta_1^ (1-t_0) + \beta_2^t = \beta_1(1-t_0) + \beta_2 t_0

and with the second iteration the recursion stops with

\begin

\beta_0^ & = & \beta_0^ (1-t_0) + \beta_1^ t_0 \\

\ & = & \beta_0(1-t_0) (1-t_0) + \beta_1 t_0 (1-t_0) + \beta_1(1-t_0)t_0 + \beta_2 t_0 t_0 \\

\ & = & \beta_0 (1-t_0)^2 + \beta_1 2t_0(1-t_0) + \beta_2 t_0^2 \\

\end

which is the expected Bernstein polynomial of degree n.

Bézier curve

When evaluating a Bézier curve of degree n in 3 dimensional space with n+1 control points Pi

\mathbf(t) = \sum_^ \mathbf_i b_(t) \mbox t \in [0,1]

with

\mathbf_i :=

\begin x_i \\ y_i \\ z_i

\end .

we split the Bézier curve into three separate equations

B_1(t) = \sum_^ x_i b_(t) \mbox t \in [0,1]
B_2(t) = \sum_^ y_i b_(t) \mbox t \in [0,1]
B_3(t) = \sum_^ z_i b_(t) \mbox t \in [0,1]

which we evaluate individually using de Casteljau's algorithm.

Pseudocode example

Here is a pseudo-code example that recursively draws a curve from point P1 to P4, tending towards points P2 and P3. The level parameter is the limiting factor of the recursion. The procedure calls itself recursively with an incremented level parameter. When level reaches the max_level global value, a line is drawn between P1 and P4 at that level. The function midpoint takes two points, and returns the middle point of a line segment between those two points.

global max_level = 5 procedure draw_curve(P1, P2, P3, P4, level) if (level > max_level) draw_line(P1, P4) else L1 = P1 L2 = midpoint(P1, P2) H = midpoint(P2, P3) R3 = midpoint(P3, P4) R4 = P4 L3 = midpoint(L2, H) R2 = midpoint(R3, H) L4 = midpoint(L3, R2) R1 = L4 draw_curve(L1, L2, L3, L4, level + 1) draw_curve(R1, R2, R3, R4, level + 1) end procedure draw_curve

Sample implementations

Haskell

 Compute a point R by performing a linear interpolation of points P and Q with parameter t. Usage: linearInterp P Q t           P = list representing a point           Q = list representing a point           t = parametric value for the linear interpolation, t<-[0..1] Returns: List representing the point (1-t)P + tQ

> linearInterp :: [Float]->[Float]->Float->[Float] > linearInterp [] [] _ = [] > linearInterp (p:ps) (q:qs) t = (1-t)*p + t*q : linearInterp ps qs t

Compute one level of intermediate results by performing a linear interpolation between each pair of control points. Usage: eval t b t = parametric value for the linear interpolation, t<-[0..1] b = list of control points Returns: For n control points, returns a list of n-1 interpolated points

> eval :: Float->Float->Float

> eval t (bi:bj:[]) = [linearInterp bi bj t] > eval t (bi:bj:bs) = (linearInterp bi bj t) : eval t (bj:bs)

Compute a point on a Bezier curve using the de Casteljau algorithm. Usage: deCas t b t = parametric value for the linear interpolation, t<-[0..1] b = list of control points Returns: List representing a single point on the Bezier curve

> deCas :: Float->Float->[Float] > deCas t (bi:[]) = bi > deCas t bs = deCas t (eval t bs)

Compute the points along a Bezier curve using the de Casteljau algorithm. Points are returned in a list. Usage: bezierCurve n b n = number of points along the curve to compute b = list of Bezier control points Returns: A list of n+1 points on the Bezier curve Example: bezierCurve 50 [[0,0],[1,1],[0,1],[1,0]]

> bezierCurve :: Int->Float->Float

> bezierCurve n b = [deCas (fromIntegral x / fromIntegral n) b | x<-[0 .. n] ]

References

  • Farin, Gerald & Hansford, Dianne (2000). The Essentials of CAGD. Natic, MA: A K Peters, Ltd. ISBN 1-56881-123-3

See also

© 2005 Music Entertainment Network. A Cyprus Roussos Music Entertainment Company. All Rights Reserved.

Articles from Wikipedia Encyclopedia are licensed under the GNU Free Documentation License. You may copy and modify it as long as the entire work (including additions) remains under this license. You must provide a link to http://www.gnu.org/copyleft/fdl.html. All text is available under the terms of the GNU Free Documentation License. All trademarks and service marks including Napster, Rio MP3 Player, iRock, Creative MP3 Player, iRiver, Apple iPod Portable MP3 Players + iTunes, eMusic, Guitar Center Musicians Friend, Zzounds Musical Instrument Equipment Store, BMG Music Service, Columbia House DVD Club, eBay, Amazon, Netflix, Jamster, Gamefly, Friendster, Music123 Musical Instruments, Billboard, MTV, Yahoo Launch, Overture Yahoo Search Marketing, MusicMatch, Kazaa, Kazaa Lite, Morpheus software, Real Rhapsody, Bose, Sheet Music Plus, Billboard Magazine, Rolling Stone Magazine, Walmart Downloads, Barnes and Noble book store, CDUniverse, Tower Records, MSN Music, MySpace, Limewire, WinMX, Google Adsense, Alibris, TicketsNow, MusicSpace, uBid are property of their respective owners. Music.us has no affiliation with MySpace or Friendster, but offers alternative services. Disclaimer: Uploading or downloading of copyrighted works without permission or authorization of copyright holders may be illegal and subject to civil or criminal liability and penalties. Please buy music and refrain from any illegal downloading activity. User submitted free content, including Wikipedia encyclopedia or modification thereof by end users, do not reflect the views and opinions of Music.us and are for educational and research development purposes. Our website offers advanced search for bands and artists bio and albums and browse options for artist band biographies resources and information. We offer blogs and community building tools for authors, bands and users. The Music.us Entertainment Network is web's most comprehensive one-stop shopping, community networking and education site. Find song lyrics, guitar tablature, posters, ring tones, free MP3 downloads and hourly updating news feeds on musicians and any genre style including rock, pop, hip hop, country, christian, rap, classical, folk, dance, latin, R and B, blues, punk, heavy metal, alternative, guitar, bass, drums, gospel, wedding, arabic, jazz, soundtrack, world, reggae, soul and more. Privacy Policy - Site Map - MP3 - Music Downloads - Song Lyrics