View Single Post
  #2  
Old June 24th, 2009, 04:06 AM
HallsofIvy HallsofIvy is offline
MHF Contributor
 
Join Date: Apr 2005
Posts: 3,499
Thanks: 328
Thanked 1,214 Times in 1,115 Posts
HallsofIvy has much to be proud ofHallsofIvy has much to be proud ofHallsofIvy has much to be proud ofHallsofIvy has much to be proud ofHallsofIvy has much to be proud ofHallsofIvy has much to be proud ofHallsofIvy has much to be proud ofHallsofIvy has much to be proud ofHallsofIvy has much to be proud of
Default

A "Bezier curve" is a cubic spline, that is, a piecewise cubic function that fits the conditions: y= ax^3+ bx^2+ cx+ d. A single cubic won't do it- you have 4 numbers to fit and have 6 conditions. If you use one cubicy= a_1x^3+ b_1x^2+ c_1x+ d_1, for the first two points and another y= a_2x^3+ b_2x^2+ c_2x+ d_2, for the second two (the middle point being used in both), you will also require that the values and the first derivative match at the middle point.

Assuming that the points are (x_0, y_0), (x_1, y_1), x_2, y2, and that the slopes at these points are m_0, m_1, and m_2, respectively, then you have the equations:
values:
a_1x_0^3+ b_1x_0^2+ c_1x_0+ d_1= y_0
a_1x_1^3+ b_1x_1^2+ c_1x_1+ d_1= y_1
a_2x_1^3+ b_2x_1^2+ c_2x_1+ d_2= y_1
a_2x_2^3+ b_2x_1^2+ c_2x_2+ d_2= y_2

slopes:
3a_1x_0^2+ 2b_1x_0+ d_1= m_0
3a_1x_1^2+ 2b_1x_1+ d_1= m_1
3a_2x_1^2+ 2b_2x_1+ d_2= m_1
3a_2x_2^2+ 2b_2x_2+ d_2= m_2

That gives eight equations to solve for the eight coefficients.
Reply With Quote
The following users thank HallsofIvy for this useful post:
Donate to MHF