Is there a way to determine the control points of a bezier curve that passes through 4 points? The points are (0,0), (1,1), (8,2) and (27,3). From the points we can know the curve is y = (x)^(1/3), but how do we plot in Bezier curves? Also the curves must be C1 continuous. I really appreciate any help. thx in advance
1. It should be 3 segments, from 0<x<1, 1<x<8, 8<x<27.
2. Use either quadratic or cubic. Example from point (0,0) to (1,1) which are the endpoints, we need to find another control point in between to draw the quadratic bezier. If use cubic need to find 2 control points which is the problem.
Is there a way to determine the control points of a bezier curve that passes through 4 points?
Sure there is. If you follow the Parametric Cubic Spline tutorial link in my signature, you can find the coefficients of 3 parametric cubic splines. However, use a different method of determining the independent variable s. Instead of using the distance between points, just use s1 = 0, s2 = 1, s3 = 2 and s4 = 3 and don't scale them. The net result of this is that each parametric cubic spline segment will have (s-s0) varying from 0 to 1, which is what you want for Bezier segments. In fact, I think I'll modify the tutorial to do it this way.
After you have the spline coefficients for each segment, use the following well known relation for cubic Bezier curves:
x = f1(s) = ax(s-s0)3 + bx(s-s0)2 + cx(s-s0) + dx
y = f2(s) = ay(s-s0)3 + by(s-s0)2 + cy(s-s0) + dy
.
I'm sorry i do not understand this formula. Does this formula also apply to quadratic Bezier? Is there any other method? Thanks a lot for your help by the way...
Where P0, P1, P2, P3 are the Bezier control points and t is the independent variable. Since P0 = (x0,y0), P1 = (x1,y1), P2 = (x2,y2), P3 = (x3,y3), the above equation is just a compact way of expressing the 2 defining equations for a cubic Bezier:
and to find the coefficients,
a1 = (y2"-y1")/6h1
b1 = y1"/2
c1 = (y2-y1)/h1 – y2"h1/6 – y1"h1/3
d1 = y1?
So where is that y4 and y4" coming from? Are my equations correct?
I'm not sure I understand the question. The above equation represents a case where you have 4 points (x1,y1), (x2,y2), (x3,y3), (x4,y4) and equal spacing of the points. You already provided the 4 points, so you know y4. Re y4", that's an unknown (along with y1", y2", y3") that are determined by the solution of the above equation. Note: in the case of natural boundary conditions, y1" and y4" are zero.
Maybe you need to word your question another way.
Last edited by VBAhack; Aug 6th, 2007 at 11:26 AM.
1. The 4 points to be fit are (x1,y1)=(0,0), (x2,y2)=(1,1), (x3,y3)=(8,2), (x4,y4)=(27,3)
2. Pick values of the independent parameter, s. For convenience, I suggested picking s = (0,1,2,3). This means h1=h2=h3=h=1, allowing the simplified equations to be used.
3. The sets of points to fit result in one equation for (s1,x1), (s2,x2), (s3,x3), (s4,x4) and a second equation for (s1,y1), (s2,y2), (s3,y3), (s4,y4)
4. Choose boundary conditions for x1", x4", y1", y4". If natural boundary are chosen, all of these are zero.
5. Solve the following matrix equation for xi" (Note assumes natural boundary conditions):
7. Calculate the parametric cubic polynomial coefficients for each segment (ax, bx, cx, dx, ay, by, cy, dy) using the results of 1,2,5,6. For example, ay,by,cy,dy for segment 1 would be: