• Announcements

Archived

This topic is now archived and is closed to further replies.

Bezier Curves Explanation PLZ

Recommended Posts

I'm breaking my head on figuring out how bezier curves work in OpenGL. Looked in the red book but still couldn't grasp it.
  glMap1f(GLenum target,float u1,float u2,int stride,int order,const float *points); 
What are u1 & u2 for... something about the range and domain of the u parameter... what is the u parameter and where does it come into play? 2.What exactly does the following code do?
  glBegin(GL_LINE_STRIP); for(int i=0;i<=30;i++) glEvalCoord1f((float)i/30.0f); glEnd(); 
3.And lastly my control points are defined in a [4][3] array but here only the x coordinates are taken into consideration.Why?
  glBegin(GL_POINTS); for(i=0;i<4;i++) glVertex3fv(&ControlArrayPoints[i][0]); glEnd(); 
Edited by - mAdMaLuDaWg on February 20, 2002 3:22:28 PM

Share on other sites
http://geocities.com/dprpg

Have a look on source code and ask if you need any assistance on its understanding.
Cheers.

" Do we need us? "

Share on other sites
I''ve not actually used Beziers, but here''s my guess:

1. I''m not totally sure of the parameters, but the U coordinate is what you''re using in Question 2 below.

2. I think that draws a bezier by subdividing your curve into 30 individual line segments. U typically goes between 0 and 1, 0 being the start of curve, 1 being the end. 0/30 = 0.0, 30/30 = 1.0. You''re just evaluating different points along your spline is all.

3. You''re passing by reference to the vertex, not just the x-coordinate.

Share on other sites

HellRizzer,
Awesome proggies... but I'm a newbie and that stuff is way beyond me. What I would like is a simple comprehensive explanation of how bezier curves work... anyone?
Thanks.

Edited by - mAdMaLuDaWg on February 21, 2002 2:07:58 PM

Share on other sites

A cubic bezier curve is determined by four control points, P0(x0,y0), P1(x1,y1), P2(x2,y2), and P3(x3,y3), and is defined by these parametric equations:
x = x0(1 - t)^3 + 3x1*t(1 - t)^2 + 3x2*t^2(1 - t) + x3*t^3
y = y0(1 - t)^3 + 3y1*t(1 - t)^2 + 3y2*t^2(1 - t) + y3*t^3

Where 0 <= t <= 1

Now notice that when t = 0 we have (x,y) = (x0,y0) and when t = 1 we have (x,y) = (x3,y3) so the curve starts at P0 and ends at P3. Go through the algebra and you will see that this is true.

Now here is an example.
Graph the bezier curve with the control points P0(4,1), P1(28,48), P2(50,42), and P3(40,5). Now graph the line segments P0P1, P1P2, and P2P3. (to do that use the parametric equations x = x1 + (x2 - x1)t and y = y1 + (y2 - y1)t. These equations will describe a line segment for some points P1(x1,y1) and P2(x2,y2). Ok now notice that the middle control points P1 and P2 dont lie on the curve, the curve starts at P0, heads for P1 and P2 without reaching them and ends at P3. See that the tangent at P0 passes through P1 and the tangent at P3 passes through P2.

Ok thats a lot of stuff there, just try out the example and do any algebra you need to understand it. Im sure you will need to work these things out on paper first to see it visually to get a good understanding of it. I didnt show how to derive the bezier parametric equations above but with a bit of thinking you should figure out how they were derived. If you dont want to figure that out yourself then im sure somewhere on the net shows how they were derived. If you want to know that is.

Also, if you understand all of that (or when you do) you should easily see how to extend this into 3d. Remember my examples and stuff are for 2d to keep things as simple as can be.

Hope this helps. And i hope i didnt make any stupid mistakes that will confuse you more than need be.

-SirKnight

Share on other sites
BTW, "t" above is often replaced by "u". That''s the "u" you were asking about before.

Share on other sites
Hmmmm... I sorta got the idea to it but I wasn''t able to graph out the curve using the equations, or do you have to use tangents to get the curve. In other words, is it possible to use a pocket calculator to get the bezier curve using an equation.... I think I''m just really confused. HELP!!?@!

Share on other sites
I don''t think you can do that... or can you?

• Partner Spotlight

• Forum Statistics

• Total Topics
627638
• Total Posts
2978327

• 10
• 12
• 22
• 13
• 34