• If there are only two control points P0 and P1, ie: N=1 then the formula reduces to a line segment between the two control points.

  • the term

  • is called a blending function since it blends the control points to form the Bézier curve.
  • The blending function is always a polynomial one degree less than the number of control points. Thus 3 control points results in a parabola, 4 control points a cubic curve etc.

  • Closed curves can be generated by making the last control point the same as the first control point. First order continuity can be achieved by ensuring the tangent between the first two points and the last two points are the same.

  • Adding multiple control points at a single position in space will add more weight to that point 'pulling' the Bézier curve towards it.

  • As the number of control points increases it is necessary to have higherorder polynomials and possibly higher factorials. It is common therefore topiece together small sections of Bézier curves to form a longer curve. Thisalso helps control local conditions, normally changing the position of onecontrol point will affect the whole curve. Of course since the curve starts andends at the first and last control point it is easy to physically match thesections. It is also possible to match the first derivative since the tangentat the ends is along the line between the two points at the end.
    Second order continuity is generally not possible.

  • Except for the redundant cases of 2 control points (straight line), it is generally not possible to derive a Bézier curve that is parallel to another Bézier curve.

  • A circle cannot be exactly represented with a Bézier curve.

  • It isn't possible to create a Bézier curve that is parallel to another, except in the trivial cases of coincident parallel curves or straight line Bézier curves.

  • Special case, 3 control points

    B(u) = P0 * ( 1 - u ) 2 + P1 * 2 * u ( 1 - u ) + P2 u2
  • Special case, 4 control points

    B(u) = P0 * ( 1 - u )3 + P1 * 3 * u * ( 1 - u )2 + P2 * 3 * u2 * ( 1 - u ) + P3 * u3
  • Bézier curves have wide applications because they are easy to compute and verystable. There are similar formulations which are also called Bézier curveswhich behave differently, in particular it is possible to create a similarcurve except that it passes through the control points. See also Spline curves. Examples

    The pink lines show the control point polygon, the grey lines theBézier curve.

    The degree of the curve is one less than the number of controlpoints, so it is a quadratic for 3 control points.It will always be symmetric for a symmetric control point arrangement.

    The curve always passes through the end points and is tangent tothe line between the last two and first two control points.This permits ready piecing of multiple Bézier curves togetherwith first order continuity.

    Compress 1 0 2 – image compression socks. The curve always lies within the convex hull of the control points.Thus the curve is always 'well behaved' and does not oscillating erratically.

    Closed curves are generated by specifying the first point the same as the last point. If the tangents at the first and last points matchthen the curve will be closed with first order continuity.In addition, the curve may be pulled towards a control point byspecifying it multiple times.

    C source

    Written by Paul Bourke
    March 2000

    Given four points p0, p1, p2, and p3in 3D space the cubic Bézier curve is defined as

    Beziercode 1 26
    p(t) = a t3 + b t2 + c t + p0

    where t ranges from 0 (the start of the curve, p0) to 1 (the end of the curve, p3). The vectors a, b, c are given as follows:

    In the following examples the green markers correspond to p0and p3 of each section. The blue markers correspond top1 and p2. The grey curve is theBézier curve sampled 20 times, the samples are shown in red.The coordinates for each vertex is shown on the right.

    Example 1
    This is a single minimum piece of a piecewise Bézier curve.It is defined by 4 points, the curve passes through the two end points.The tangent at the end points is along the line to the middle two points.

    0 0 1
    0.5 0 1
    1 0 0.5
    1 0 0

    Example 2
    Multiple curve pieces can be joined together to form longer continuouscurves. The curve is made continuous by the setting the tangents thesame at the join. Note that each piece of the curve is defined by tranging from 0 to 1.

    0 0 1
    0.5 0 1
    1 0 0.5
    1 0 0
    1 0 0
    1 0 -0.5
    2 0 0
    2 0 0.5

    Example 3
    By changing the tangent points between two curve pieces, sharp transitionscan be created.

    0 0 1
    0.5 0 1
    1 0 0.5
    1 0 0
    1 0 0
    1.5 0 0
    2 0 0
    2 0 0.5

    Example 4
    The 'strength' at the end points is controlled by the length of thetangent lines. The longer the line the more effect that tangent has.If the curve is being used for animation steps then the strength alsocontrols the velocity, note the samples shown in red are further apartfor the long tangent vectors.

    0 0 1
    1.75 0 1
    1 0 0.5
    1 0 0
    1 0 0
    1 0 -0.5
    2 0 -0.5
    2 0 1

    Example 5
    Straight line geometry can readily be made by aligning the tangentvectors along the line. While this may seem a frivolous use, it canbe put to good effect in animations applications. By adjusting thetangent points p1 and p2 thevelocity along the line can be controlled.


    0 0 1
    0.25 0 1
    0.75 0 1
    1 0 1
    1 0 1
    1 0 0.75
    1 0 0.25
    1 0 0
    Notes
    Source code

    FAQ

    0to p5, in order to use the Piecewise Cubic Bézierfor each section (between points pi and pi+1)one needs to find the tangent vectors shown in red.Note that for continuity between the points the tangent vector atthe end of one piece is the negative of the tangent at thestart of the next piece.

    In this first case the tangent vectors are just the differences betweensubsequent keyframe points. So for example, for the segment between p1 and p2 the four points use for the Bézierwould be p1, p2, 2p2-p3, p2. Depending on the lengthscaling for the tangent vectors, the resulting Bézier curvebetween points p1 and p3 is shown in blue.

    A generally better method is shown below, again one needs to find thered tangent vectors. The exact implementation will be left up to thereader but the approach I've used is to find the cross product betweenthe vectors to each neighbour, that is a vector coming outof the page (or into the page) in the diagram below. The tangentvectors (red) are found by taking the cross product of that withthe green normal vectors. The main reason for using this approachis that it overcomes a mirror symmetry problem that occurs if onesimple tries to rotate the green normal vectors +- 90 degrees.Note that the case of 3 collinear points needs to be treated as a specialcase.

    An improvement by Lars Jensen is illustrated below. It uses a normalthat bisects the two vectors to the neighbouring points along with wayof limiting the tangent lengths.

    The only remaining comment is how one deals with the first and lastpoint, normally there are some ad hoc approaches that are applicationspecific.

    2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
    地址:https://cloud.tencent.com/act/cps/redirect?redirect=1073

    Beziercode 1 268

    2020阿里云最低价产品入口,含代金券(新老用户有优惠),
    地址:https://www.aliyun.com/minisite/goods
    If I have a simple 2-D matrix with normalized values on x-axis between 0 and 1 and y-axys between 0 and 1, and I have 3 points in this matrix e.g. P1 (x=0.2,y=0.9), P2 (x=0.5,y=0.1) and P3 (x=0.9,y=0.4).
    How can I simply calculate a curve thru this points, meaning having a function which is giving me the y for any x.
    I now that there are any number of possible curves thru 3 points. But hey, you know what I mean: I want a smooth curve thru it, usable for audio-sample-interpolation, usable for calculation a volume-fade-curve, usable for calculating a monster-walking-path in a game.
    Now I have searched the net for this question about 3 days, and I cannot believe that there is no usable solution for this task. All the text dealing about Catmull-rom-Splines, bezier-curves and all that theroretical stuff has all at least one point which doesn't make it for me usable. For example Catmull-Rom-splines need to have a fix distance between the control-points (I would use this code and set the 4. point-y to the 3. point y) :
    But I don't see that x1 to x4 have any affect on the calculation of y, so I think x1 to x4 must have the same distance?
    ..

    Beziercode 1 263

    Or bezier-code doesn't calcuate the curve thru the points. The points (at least the 2. point) seem only to have a force-effect on the line.
    This is better than nothing, but it is 1. very slow (recursive) and 2. as I said doesn't really calculate the line thru the 2. point.
    Is there a mathematical brain outside which could help me?
    c++beziercurvesplines
    |
    this question asked Feb 21 '13 at 17:18 Tobias Findeisen 16 4 stackoverflow.com/q/6711707/1458030 – qPCR4vir Feb 21 '13 at 18:45 |

    2 Answers
    2

    Beziercode 1 264

    Thank you TOCS (Scott) for providing your code, I will also try it if I have some time. But what I have tested now is the hint by INFACT (answer 3): This 'Largrange polynomials' are very very close to what I am searching for:
    I have renamed my class bezier to curve, because I have added some code for lagrangeinterpolation. I also have added 3 pictures of graphical presentation what the code is calculation.
    In Picture 1 you can see the loose middle point of the old bezier-function.
    In Picture 2 you can now see the going thru all-points-result of lagrange interpolation.
    In Picture 3 you can see the only problem, or should I say 'thing which I also need to be solved' (anyway its the best solution till now): If I move the middle point, the curve to going to fast, to quick to the upper or lower boundaries). I would like it to go more smoothely to the upper and lower. So that it looks more logarithm-function like. So that it doesn't exeed the y-boundaries between 0 and 1 too soon.
    Now my code looks like this:
    Do you have any ideas how I could get the new solution a little bit more 'soft'? So that I can move the 2. Point in larger areas without the curve going out of boundaries? Thank you

    |
    this answer answered Feb 22 '13 at 16:25 Tobias Findeisen 16 4 |
    Untested, but should return a bezier curve where at t=0.5 the curve passes through point 'b'.
    Dropdmg 3 5. Additionally (more untested code ahead), you can calculate your points using bernstein basis polynomials like so.

    |
    Beziercode 1 26

    Beziercode 1 26th

    this answeredited Feb 23 '13 at 5:45 answered Feb 21 '13 at 20:04 Tocs 601 3 15 Shouldn't you have another PushPoint2D in there somewhere? A Bezier requires 4 points, unless you're using the rarer Quadradic form rather than a Cubic. – Mark Ransom Feb 21 '13 at 20:26 Bezier works for n points. – user1157123 Feb 21 '13 at 20:33 Bezier's are just recursively defined? I don't see why you need 4 points. So long as you supply the proper Bernstein basis polynomials it shouldn't matter. The quadratic Bezier curve is (1-t)^2P0 + 2(1-t)tP1 + t^2P2 And if you look at the bernstein polynomials B0,2 = (1 - x)^2 B1,2 = 2(1-x)x and B2,2 = x^2 They match, so there shouldn't be a problem regardless of pointcount. Op however is doing the recursive definition it appears, he would benifit from switching to the more straightforward sum definition. – Tocs Feb 21 '13 at 20:45 @infact, yes theoretically a Bezier can be defined with as many points as you'd like. However the most commonly used form is the Cubic with 4 points; if more than 4 points are needed then the curve is broken into multiple independent segments with the end point of one defining the start point of the next. – Mark Ransom Feb 21 '13 at 22:03 @MarkRansom I'm not sure how that would work, you wouldn't get a smooth curve at those intersections.. Where are you getting this from? – Tocs Feb 22 '13 at 0:41 | show more comments

    最新文章