Create bezier curve from 2 conected curve

  • Thread starter temp
  • Start date
  • Tags
    Curve
In summary, the conversation discusses a method for finding a quadratic bezier curve based on two connected curves, as well as a specific example and the potential use of least squares to achieve this. The steps for using least squares are outlined, including calculating x,y values for an arbitrary number of points, making initial guesses for control points, and finding the optimal p_{1y} value through a series of calculations. An example is provided for illustration.
  • #1
temp
13
0
hello
commonly when we have 2 connected curve and we want to find quadratic bezier curve base on them we can use this interesting method:
(see the 4 picture in the middle of following page and you quickly understand)

http://www.actionscript.org/resources/articles/172/1/Understanding-curves-and-control-point-placement/Page1.html [Broken]

but this method isn't intelligence and has poor result in some cases
for example see this case:

http://i23.tinypic.com/2z4n776.jpg

fig1 is two original connected curve
fig2 is the result from this algorithm (black curve)
fig3 is the favorite result that i want (black curve)

so this is final question:
having two connected curve, how i can find the best quadratic bezier curve that fits this two curves?
 
Last edited by a moderator:
Mathematics news on Phys.org
  • #2
Looks like you are fitting a single quad bezier to a composite of two curves. If this is true, I'd probably use least squares. It is straightforward but tedious. If you want, I can explain in detail, but I'd like to use a specific example to illustrate. Can you post an example (equations for the 2 curves or x,y data points)?
 
  • #3
Per our PM exchanges last night, my understanding is that you want to combine two quad bezier curves into a single quad bezier curve. This is effectively reducing the order/flexibility of the curves. I know of no analytical/closed form way of doing this. Other Forum members might.

If least squares is a suitable approach for your situation (it may not be if computational efficiency is important), then the approach depends on a couple of important factors:

1. Whether the final curve needs to exactly go through the beginning and end points. In general, this isn't true with least squares, but in the case of quad bezier, the analysis is easier if the curve is forced to go through the end points.

2. Whether [itex]p_{1x}[/itex] of the final curve needs to be iteratively determined or not. The example you provided looks symmetric, which means the optimal value of [itex]p_{1x}[/itex] would be half way between the [itex]p_{1x}[/itex]'s of the two curves to consolidate. Even if [itex]p_{1x}[/itex] needs to be determined, the situation boils down to a univariate optimization problem that can be solved using a variety of techniques (e.g. bisection, Newton Raphson, Brent's method, Simplex, etc.)

Assuming the most simplistic situation (i.e. the curve goes through the end points, meaning [itex]p_{0y}[/itex] and [itex]p_{2y}[/itex] are known, and [itex]p_{1x}[/itex] is known, perhaps due to symmetry), then only 1 variable is to be determined using least squares, and that is [itex]p_{1y}[/itex]. With these assumption, here is a method that will work:


a. Calculate x,y for an aribtrary number (n) points for each of the original curves. I picked n = 10 for an example I did. The result is 20 x,y values that will be fit with a single quad bezier.

b. Make an initial guess for all six control points of the final quad bezier curve. Using the assumptions from #2 above, this really means just picking an initial value for [itex]p_{1y}[/itex].

c. For each x from step a, find the corresponding value of t that will produce the same x using the control points from step b. This means solving 2n-1 quadratic equations.

d. Once you know t for each x, calculate corresponding y values using the control points from step b. This allows you to readily calculate the sum-of-squares residual.

e. Calculate 2t(1-t) for each value of t from step c. This is used for performing least squares analysis to find the optimal [itex]p_{1y}[/itex]. Effectively:
[tex]2t(1-t) = \frac{\partial p_{1y}}{\partial y}[/tex]

f. Take each value of 2t(1-t) from step e, square and sum. Call this number z. Thus:
[tex]z = \sum (2t(1-t))^2 = \sum (2t - 2t^2)^2[/tex]

g. Calculate the difference between y calculated in step d and y from step a. This is an array that we will call f-y.

h. For each element of f-y, multiply by the corresponding element from step e and sum. Thus:
[tex]\sum (f-y)2t(1-t) = \sum (f-y)(2t-2t^2)[/tex]

i. The optimal value of [itex]p_{1y}[/itex] is simply the original guess minus the quantity from step h divided by z from step f. In other words:
[tex](p_{1y})_f = p_{1y} - \frac{\sum (f-y)(2t-2t^2)}{\sum (2t-2t^2)^2}= p_{1y} - \frac{\sum (p_{0y}(1-t)^2+2p_{1y}t(1-t)+p_{2y}t^2-y)(2t-2t^2)}{\sum (2t-2t^2)^2}[/tex]

Example using the above:

http://www.hostdump.com/uploads/83d023211c.jpg [Broken]

:smile:
 
Last edited by a moderator:

1. What is a bezier curve?

A bezier curve is a type of mathematical curve commonly used in computer graphics and geometric modeling. It is defined by a series of points called control points, which determine the shape of the curve.

2. How do you create a bezier curve from two connected curves?

To create a bezier curve from two connected curves, you first need to identify the control points for each curve. Then, you can use the control points to create a smooth transition between the two curves by calculating the position of points along the bezier curve.

3. What are the advantages of using bezier curves?

Bezier curves offer several advantages in computer graphics and geometric modeling. They allow for smooth, continuous curves with a high degree of control over the shape. They are also relatively easy to manipulate and calculate, making them a commonly used tool in design software.

4. Can a bezier curve be modified after it is created?

Yes, bezier curves can be modified after they are created. Since they are defined by control points, these points can be adjusted to change the shape of the curve. Additionally, some software programs have tools specifically designed for modifying bezier curves.

5. Are all bezier curves the same?

No, not all bezier curves are the same. The shape and smoothness of a bezier curve can vary depending on the number and placement of the control points. Additionally, different types of bezier curves, such as quadratic and cubic, have different mathematical formulas and produce different results.

Similar threads

Replies
8
Views
3K
Replies
2
Views
2K
  • Differential Geometry
Replies
1
Views
3K
  • Special and General Relativity
Replies
27
Views
4K
Replies
4
Views
4K
Replies
2
Views
3K
  • General Math
Replies
5
Views
4K
  • General Math
Replies
12
Views
11K
  • Special and General Relativity
2
Replies
51
Views
2K
  • Special and General Relativity
Replies
13
Views
1K
Back
Top