Talk:Bézier curve
From Wikipedia, the free encyclopedia
[edit] G1 continuity
What is G1 continuity? --AxelBoldt
Continuous curves with tangents pointing in the same direction. Used by graphics/font workers http://www.google.com/search?q=g1.continuity
What is the point on the cubic curve in the recursive algorithm?
What does "A truly parallel Bézier curve cannot be derived mathematically" mean?
- Good question... I have no idea. Κσυπ Cyp 21:59, 15 Sep 2004 (UTC)
-
- It means you can't derive a second curve that is parallel to the first by mathematical operations on the control points of the first. It works for some cases, but not in general. Maybe the phrasing could be better, but it seemed clear enough to me.Graham 22:57, 15 Sep 2004 (UTC)
-
-
-
- Well strictly speaking parallel refers to straight lines or planes, so if we are speaking strictly, then 'parallel curves' is an oxymoron. However, in everyday language it should be clear what this means - a second curve that maintains a constant distance from the first at every similar point, like a pair of railway tracks rounding a bend. If there is a "proper" word for this I don't know what it is. The ability to do this is actually rather important in the real world, where bezier curves are not just mathematical curiosities but are a practical way of implementing computer graphics, etc. Creating a curve 'parallel' to another is often needed, but coming up with an algorithm for it requires some cunning, because of the mentioned limitation of the curve's essential properties. I made a stab at rewording the sentence, but 'parallel' is still in there ;-) Graham 23:47, 15 Sep 2004 (UTC)
-
-
Wow, if only there was an explanation for the layman. Someone below claims this is it: I did maths to the end of school and have no idea about this, and in particular the use of these curves in Illustrator remains a mystery to me. Please help!
[edit] Merging Bezier curve & Bernstein polynomial
I want to merge Bézier curve and Bernstein polynomial. I do not care what the resulting article is called. The two article are talking about the same subject and so there is a lot of duplicated material and inconsistent notation. Any comments ?MathMartin 12:52, 19 Sep 2004 (UTC)
I changed my opinion. The material should stay on separate pages, although the notation should be more consistent. What is the term for splines that are patched together using polynomials in Bézier form ? And what exactly is a Bezigon ? Is the term common ? What I was trying to do when rewriting Bézier curve and Bernstein polynomial was to make the connection between the two topics clearer. At the moment I think the articles should be structured like this
- Bernstein polynomial mathematical treatment of Bernstein polynomials.
- Bézier curve a Bernstein polynomial restricted to [0,1], cubic and quartic curves as examples
- Bezigon or ?? a spline composed of polynomials in Bezier form, application in industry
It is not clear to me what the last two pages should be called, perhaps someone with more knowledge can propose some naming. MathMartin 10:20, 20 Sep 2004 (UTC)
[edit] Removed from page
- Generalizing the cubic case leads to higher order curves which require more than four control points. The use of high order Bezier curves and surfaces has been limited to a few highly specialized and expensive surface modeling and industrial design applications.
- For most applications, complicated curves are pieced together from cubic curves to form bezigons: the first Bézier curve has control points A, B, C, and D, the second has control points D, E, F, and G, and if G1 continuity (i.e. smoothness of the curve) at D is required, then the direction of C-D needs to equal the direction of D-E.
I removed the following two paragraphs from the page. The first does not contain information, and the second is a bit obscure. MathMartin 17:09, 19 Sep 2004 (UTC)
- I would hazard a guess from your user name that you're a mathematician rather than one who soils his hands on real-world applications ;-) If that's the case then I'd gently put you straight about the second part being "a bit obscure". This is how bezier curves are almost always used in practice for computer graphics, etc. Cubic curves are relatively fast to compute, higher order ones are not, so chaining the cubic segments together to form a desired shape is done in every case I've ever come across. And to ensure a smooth "join" between segments, the end point tangents are made the same, which is what that statement is saying. Another reason higher order curves ar not generally used is because most graphics programs need to implement the "find closest point on the curve to an arbitrary point" functionality, and that requires finding the roots of a fifth order polynomial - which can be done. But higher orders have no known algorithm. I really think that the article would be of most interest and use to BOTH mathematicians and as in an introduction for graphics. Therefore these real-world aspects should definitely be included.Graham 23:50, 19 Sep 2004 (UTC)
You misunderstood me, perhaps because my comment was too cryptic. I understand the sentence
- Generalizing the cubic case leads to higher order curves which require more than four control points. The use of high order Bezier curves and surfaces has been limited to a few highly specialized and expensive surface modeling and industrial design applications.
I put the mathematical definition at the top, so there is no need to generalize form the cubic case to higher order curves. Stating that only low order curves are used in the industry without any reason is not very useful.
- Another reason higher order curves ar not generally used is because most graphics programs need to implement the "find closest point on the curve to an arbitrary point" functionality, and that requires finding the roots of a fifth order polynomial - which can be done
Now that is a good reason not to use high order Bezier curves, you should have put it in the article. I intend to expand the article in the next few days and will include it. Just a short correction, even roots of a fifth order polynomial can generally not be found analytically.
- For most applications, complicated curves are pieced together from cubic curves to form bezigons: the first Bézier curve has control points A, B, C, and D, the second has control points D, E, F, and G, and if G1 continuity (i.e. smoothness of the curve) at D is required, then the direction of C-D needs to equal the direction of D-E.
I understand the need to patch together low degree Bezier curves to form splines, and that one must observe certain smoothness conditions when patching the curves together. But I think Bezier curve article is the wrong place to talk about splines, (to some extend I already talked about splines in the introduction) and the paragraph was very badly written. What is the direction C-D ? What is G1 continuity ? You do not have to explain those terms to me, I know them or can guess them. But for the reader who does not know the material, who just wants to look up some information, the paragraph is obscure.
To sum up the gist of my arguments. Yes I am a mathematician. I believe there should be formal mathematical definition even if they scare the laymen. But there should be real world explanations and examples too. But the math definitions and the laymen explanations should not be mixed, they should be put in separate sections. In an encylopaedia it is better to provide a general definition and then give examples then to give an example and then generalize form this example.
On a different note perhaps you can shed some light on the notation used on the page. What is the deal with the upper case Bézier coefficients (A, B etc.) written in bold ? Why not call them p_0, p_1 ..?MathMartin 10:20, 20 Sep 2004 (UTC)
[edit] Removed some more paragraphs
Points on a quadratic Bézier curve can be computed recursively:
- Let A, B and C be the startpoint, control point and endpoint of the curve respectively.
- Let D be the midpoint of the line AB.
- Let E be the midpoint of the line BC.
- Let F be the midpoint of the line DE. F is a point on the curve.
- Recurse with A = A, B = D and C = F.
- Recurse with A = F, B = E and C = C.
The points on a Bézier curve can be quickly computed using a recursive procedure which uses division by two as its fundamental operation and avoids floating point arithmetic altogether;
- or
D:=(C+D)/2, C:=(B+C)/2, D:=(C+D)/2, B:=(A+B)/2, C:=(B+C)/2, D:=(C+D)/2 (No language in particular)
I removed the above paragraphs from the article. They don't make any sense to me. MathMartin 15:00, 20 Sep 2004 (UTC)
- Not sure who wrote what in there (know I wrote the matrix), but reading it (the removed paragraphs, that is) now, it doesn't make any sense to me either... It was supposed to mean that, given a Bézier curve with points A, B, C, D, the Bézier curve can be cut into two separate Bézier curves, one with points A', B', C' and D', and the other with points 'A, 'B, 'C and 'D, where and . (Equivalent of substituting t:=2t and t:=2t-1. (Where := is assignment.)) Instead of using matrices, it is possible to cut the curve in half by setting the points to the average of neighbouring points several times in the right order, where the talk of a mysterious division by two comes in. Κσυπ Cyp 01:00, 21 Sep 2004 (UTC) and 00:27, 21 Sep 2004 (UTC)
- The article is much better for Martin's edits I think. I didn't follow the mtraix stuff either since there's no context for it - I've added a simple C example in the applications section which does give a practical method for computing a cubic curve. I hope it's not too long, and reasoanably correct (untested). Feel free to fix any bugs! Graham 00:36, 21 Sep 2004 (UTC).
Is it possible to return structures in C? (Haven't tried testing the code.)
Here's something like what I'd write (which isn't quite as long), to do the same thing. Haven't tested. Not sure whether 2 multiplies or 6 add/subtracts are faster.
#define ComputeBezier(a,b,c) computebezier((float *)(a),(b),(float *)(c)) void computebezier(float *cp, int n, float *res) { float s, s2, s3, t, t2, t3, st2, s2t, ds; float ax, ay, bx, by, cx, cy, dx, dy; ax=*cp++; ay=*cp++; bx=3**cp++; by=3**cp++; cx=3**cp++; cy=3**cp++; dx=*cp++; dy=*cp; ds=1./(n-1); s=0; t=1; while(n--) { s+=ds; s2=s*s; s3=s*s2; t-=ds; t2=t*t; t3=t*t2; st2=s*t2; s2t=s2*t; *res++=ax*t3+bx*st2+cx*s2t+dx*s3; *res++=ay*t3+by*st2+cy*s2t+dy*s3; } }
Κσυπ Cyp 11:03, 21 Sep 2004 (UTC)
- You can return structs at least from ANSI C 99, not sure when this came in, I know that old dialects couldn't. My code is meant to serve as a clear example, not necessarily what a software engineer would actually write as optimum code. I believe it's easier to relate the code to the maths in the article than your example, which is no doubt faster... we must remember that this is an encyclopaedia, not a code text book - maybe even C is too technical here, a BASIC (shudder) or Pascal example might be better for readability.Graham 23:46, 21 Sep 2004 (UTC)
[edit] Dimension
Just a short note on the introduction.
Generalizations of Bézier curves to three (or more) dimensions are called a Bézier surface and a Bézier triangle.
This is not a very clear formulation. In mathematics a curve is a 1 dimensional object because it depends on one parameter t. A Bézier surface would be a 2 dimensional object because it depends on 2 parameters. Consider this explanation: a curve can be drawn in a 2 dimensional space or in a 3 dimensional space (or any dimension for this matter) but it still is a curve, a 1 dimensional object.
For me this is clear. But other people may not know this. Perhaps someone can reformulate the sentence to make it clearer. Until then I will just remove the exact dimension number and speak about higher dimension. MathMartin 12:22, 21 Sep 2004 (UTC)
- Again this may be a layman vs. mathematician situation. Mathematically the bezier curve may be one dimensional, but intuitively it's two dimensional because it produces a point (x,y). I agree that the maths should be rigorous but I also think we musn't lose sight of the audience - which in general are not other mathematicians (who will have better references to work from than this), or even computer graphics programmers, but just people who are interested and looking for a simple introduction to the topic, but with enough info to go away and do something useful with it if they want to. That's my opinion anyway. Graham 23:52, 21 Sep 2004 (UTC)
Mathematically the bezier curve may be one dimensional, but intuitively it's two dimensional because it produces a point (x,y).
I rewrote the defininition to clear this up. How many points the curve produces is dependend on the dimension of the control points. If I choose control points in 3 dimensional space I get a curve in 3 dimensional space. If this is not clear I will expand the material in the article.
mathematicians (who will have better references to work from than this)
You should not make assumptions about the audience :) Even mathematicians need to look stuff up, and start from the beginning when learning a new topic. Most math books are crap because they do not contain enough examples and motivation.
An encyclopaedia should be accessible to a wide range of people. I think at the moment the article is well balanced. The laymen can read and understand the history section (should be expanded) and the applications in computer graphics sections. The programmer can grab the examples and implement them. And the mathematician (or any person with some training in math) can lookup the definition.
I believe it's easier to relate the code to the maths in the article than your example, which is no doubt faster... we must remember that this is an encyclopaedia, not a code text book - maybe even C is too technical here, a BASIC (shudder) or Pascal example might be better for readability
I agree. The code should match the math in the article and perhaps C is not the best choice. But as far as I know there is no standard computer language on wikipedia for examples, so whoever writes the code gets to choose the language. In my opinion code should only be used the make algorithms clearer. Complete implementations should be put at http://wikisource.org/wiki/Wikisource:Source_code and linked form the article.
MathMartin 12:11, 22 Sep 2004 (UTC)
[edit] source code
should be put here http://wikisource.org/w/index.php?title=Beizer_Curve&action=edit preferred language should be Python cause it's a high level, easily readable, used by mathematicians worldwide language that has bright future (pascal/fortran/basic are dead)
- Well feel free to do that then. However, I think you'll find that C is more universally understood by programmers since most other languages that are commonly used now are based on it - C, C++, Java, Javascript, etc etc. Perhaps Python is for all I know but I don't know Python - but I do know C which is why I wrote the Bezier code in that language. I think we should guard against just using a language because it's "flavour of the month" - let's give it a chance to establoish itself as C has in the last 30+ years. Graham 06:24, 26 Dec 2004 (UTC)
The coefficients for the cubic curive are calculated wrong in the example source code given. This can easily be verified by drawing lines between the control points and see that the points on the curve calculated by the example code goes outside the lines between the control points.
The correct coefficients should be (easily expanded from the parametric form):
a = − A + 3B − 3C + D
b = 3A − 6B + 3C
c = 3B − 3A
such as:
B(t) = at3 + bt2 + ct + A
The code for generating this (in Java) is:
private Point pointOnCubic(float t) { Point res = new Point(); float t2 = t * t; float t3 = t2 * t; // cp[] is an array of Point's specifying the control points float ax = -cp[0].x + 3*cp[1].x - 3*cp[2].x + cp[3].x; float bx = 3*cp[0].x - 6*cp[1].x + 3*cp[2].x; float cx = 3*cp[1].x - 3*cp[0].x; float ay = -cp[0].y + 3*cp[1].y - 3*cp[2].y + cp[3].y; float by = 3*cp[0].y - 6*cp[1].y + 3*cp[2].y; float cy = 3*cp[1].y - 3*cp[0].y; res.x = (int) ((ax * t3) + (bx * t2) + (cx * t) + cp[0].x); res.y = (int) ((ay * t3) + (by * t2) + (cy * t) + cp[0].y); return res; }
-- netd
- I will check it and try and set up a place where I can actually run it. The code is derived from some I'm using in a project and it draws Bezier's correctly - as far as I can see it looks right here but I may be missing something. Certainly the actual code I'm using (which is far too complex to use directly as an example here) does not draw outside the control point bounds.
- Please note that when adding comments to a talk page, you should always add them to the bottom of the page (not the top) if they are a new toic, or appended to an existing section if it's an already open topic. You should always sign and date your comment using four tildes (~) following the comment, otherwise it's very hard to see whan something was added. I had to use the history and diffing the file to pick out your comment, so you're lucky I even noticed it. I have moved it to the right place on the page. Graham 00:51, 17 Apr 2005 (UTC)
-
- I have just now tested the code posted here exactly as given. It works exactly correctly as far as I can see, and does not draw outside the control point tangent lines. This isn't much of a surprise, since I've been using very similar code for quite a while with no problems, but it might help to reassure others who don't trust it having read the above. While I don't necessarily dispute the analysis, I'm a practical guy and the code as given works well. I stick by it! Graham 04:06, 26 October 2005 (UTC)
[edit] History
The history section says that Pierre Bézier just used the curve, but [here] I found that he actually discovered the curve independently: "This set of curves was discovered around the same time by two people: Bezier and de Casteljau. Bezier discovered it using the Berstein polynomials, while de Casteljau found a geometric representation". Is it right? Rodrigo Rocha 02:05, 16 Jun 2005 (UTC)
- It is right. Due to the fact they didn't come from the same engenieer school, it is still a French issue to know who found that the first one. Generally people say that Bezier discovered the mathematical form and de Casteljau invented the algorithm - the only reason which made bezier surfaces so usefull -. Celui from french wikipedia.
[edit] 00
Am I missing something or should we adopt the convention that 00 = 1? Say we need to calculate the following Bernstein polynomial (for a given n, with i=0 and t=0):
Here we have 00.
- Of course 00 = 1 !!
[edit] Dropped roots comment
I dropped "and there is no analytic formula to calculate the roots of polynomials of degree 5 and higher" for 2 reasons : Firstly, in most cases numerical approximations can be used instead of analytical solutions. But more importantly, it is seldom necessary to compute t. The most frequent operation is to compute the coeficients with Gaussian elimination if not directly. -- Nic Roets 09:18, 30 July 2005 (UTC)
I'd second dropping that phrase. There is no *algebraic* formula for the roots of a quintic, but there is a closed form solution in terms of hypergeometric functions (which are analytic). That is, there is no formula for the roots in terms of the coefficients using a finite number of additions, multiplications, and root takings (for quintic and higher order polynomials). There is, however, a formula involving a finite number of additions, multiplications, root takings, and evaluations of hypergeometric functions (for polynomials of degree greater than five, one needs generalizations of the hypergeometric functions). -- jimbo 00:44, 12 October 2005 (CDT)
[edit] Circle description
Some curves that seem simple, like the circle, cannot be described by a Bézier curve or a piecewise Bézier curve
I have a different opinion. If you create a cubic Bezière curve which starts at [0,1],goes through [sqrt(1/2),sqrt(1/2)] and ends at [1,0] (its control points are [0,1],[x,1],[1,x],[1,0] where x=0.552285), the resulting curve is equivalent to a circle - the point distance from radius only differs in tenths of permille of the radius.--janndvorakk 10:13, 1 January 2006 (UTC)
If there is some difference in radius, no matter how miniscule, then the curve cannot describe the circle. Dysprosia 10:24, 1 January 2006 (UTC)
[edit] Constructing Bézier curves
I've added a section on constructing Bézier curves including some animated GIFs, because I think it helps to visualise Bézier curve formulae. I thought about adding a derivation so you can see from the construction how the Bézier formula comes about because someone was complaning "Wow, if only there was an explanation for the layman". For example something like this for a quadratic curve:
So doing some substitution...
I decided this was more appropriate to a high school textbook than an encyclopedia so I left it out. Twirlip 16:43, 27 August 2006 (UTC)
- Wow, your section rocks. The article was understandable enough, but your section really finished the deal (especially the sexy animations.) Thank you JakeParker 02:07, 2 September 2006 (UTC)
In main page I have change these formulae:
Correct formulae (Bézier curve is an interpolation between two degree n − 1 Bézier curves):
[edit] Animations
The animations for the curves are too fast for anyone who actually wants to study them. Perhaps slow them down by about fifty percent or so.
Radical 05:34, 10 September 2006 (UTC)
- How's that? Twirlip 20:15, 12 September 2006 (UTC)
These animations are great! Someone should nominate one as a featured animation. I never really understood bézier curves as fully as I should have before, but all the math is clear, without even reading the math. --jacobus (t) 17:53, 12 October 2006 (UTC)
I agree, the animations are incredibly helpful. 70.22.140.232 22:09, 3 February 2007 (UTC)
- I also agree, and have suggested the animations for WP:FPC at WP:PPR (Wikipedia:Picture peer review/Bézier curve animations). --Lph 01:09, 11 February 2007 (UTC)
- This animations finally helped me understand what is so special about Bezier curves. The small size of the sample C code also gives a hint to its importance, they are much easier than the formula that appear so prominent at the beginning of the article. I would even add that I was lucky to skip over those formula and got to the animation and code section before dismissing the article and remain in the dark.
As it turns out, the animations seem to indicate that the figures made with nails and string, as shown, for example, at http://www.stitchingcards.com/section.php?xSec=25 make the contour of a Bezier curve. (You'll probably think the next think I'll do is promote lava-lamps in articles related to convection or materials density change with temperature)
As for the layman understanding of what Beziers curves are or why are they so useful, I would like to suggest to change the order of the article so the explanations easier for the laymen go first. After all, few of us would have never learned there was something called a Bezier curve if it wasn't for their simple construction. --DevaSatyam 12:07, 19 August 2007 (UTC)
[edit] New links
I added a few links to my pages on how to construct Bezier curves geometrically. If you want to incorporate that into the main article, go right ahead. -SharkD 21:45, 30 October 2006 (UTC)
[edit] a bit of doubt... would be thankfull if answered
well.. i'm into high school, so i don't really have much understanding about bezier curves. But i was trying to plot a bezier curve in PowerToy Calc. I used the formula given in the talk section "Construction Bezier curves". This was what i used:
B(t) = ((1 - t)^2)*p + (2*t*(1 - t))*q + (t^2)*r
here, p, q and r were integral variables which i gave different values later. Now my doubt was.. whatever it is that i'm doing, is it right?? coz the curves which were plotted.. didn't really seem like bezier curves to me. If i'm not doing it right.. how is it done right?? i'd be grateful for the help.
Rohan2kool 10:47, 11 April 2007 (UTC)
In order to get a curve, p,q, and r need to be 2 dimensional vectors (i.e. points). If you just use scalar values, you'll probably end up with a parabola. I'm not familiar with PowerToy Calc, so I don't know what kind of support it has for parametric equations. Hope that helps.
mistercow (talk) 01:11, 26 January 2008 (UTC)
[edit] Reference link in doubt
The first reference Bézier curves, [1], redirects to [2], which is about Bézier surfaces. I wonder if perhaps this page [3] on Bézier curves was intended.--Jwwalker 18:11, 10 August 2007 (UTC)
[edit] The code for rendering
The C code we give for rendering cubic Béziers is very inefficient. Why don't we present the standard technique of repeatedly dividing the curve into two until each part is sufficiently close to a straight line? --P3d0 14:55, 19 August 2007 (UTC)
- I have removed it. De Casteljau's algorithm is much more efficient. --P3d0 (talk) 01:22, 14 December 2007 (UTC)
[edit] Cubic beziers in fonts
Should say that one reason that cubic beziers are convenient in fonts (such as in PostScript Type 1 etc.) is that you can require that a cubic curve has two specified endpoints, and a specified tangent angle at each endpoint, and still have some further control over the shape of the curve between the endpoints. By contrast, if you use quadratic beziers, then specifying two endpoints and two corresponding tangent angles completely specifies the shape of the curve -- if you then want to change the shape of the curve, the only way is to recut it (using different endpoints), and this may have a further chain-reaction effect on neighboring quadratic curve segments (the dreaded non-locality problem when attempting to edit Truetype fonts in native format, i.e. without converting them). AnonMoos 18:47, 1 September 2007 (UTC)