Quadratic bezier problem

  • Thread starter makc
  • Start date
  • Tags
    Quadratic
In summary, the conversation discusses the use of quadratic bezier splines in flash scripting to draw smooth curves between points on the screen. The problem is how to connect multiple points with smooth curves using these splines. The first attempt was to solve for subsequent control points, but this resulted in control points that jump around. The next step was to make the derivatives of x and y the same, using a parameter "a" to adjust the curve. However, this approach is not ideal as it requires a free parameter. The solution suggested is to use multiple quadratic splines per segment, with a floating middle point that is solved using the Cardinal spline method.
  • #1
makc
65
0
This is about flash scripting, actually. There's that thing called quadratic bezier spline,

[tex]p_0(1-t)^2+2p_1 t(1-t)+p_2 t^2[/tex],

right, and flash plugin has that "curveTo" command that apparently uses above expression for x(t) and y(t) to draw a curve between two points on screen. So, I was wondering how do I make it so that N points could be connected by smooth curve using N-1 such segments.

What I did originally was solving [tex]x'_{i-1}(1) = x'_i(0)[/tex] for subsequent control points ([tex]p_{1,i}[/tex]) and same for y'-s:

[tex]p_{1,i} = 2p_{2,i-1} - p_{1,i-1}[/tex],

but this did not worked out well, because control points tend to jump around like crazy this way.

So, my next step was getting dx/dy to be same. I concluded that the curve will be still smooth if you multiply x' and y' by any positive number, and so my solution is now [tex]p_{1,i} = p_{2,i-1} + a ((2p_{2,i-1} - p_{1,i-1}) - p_{2,i-1}), 0 < a < 1[/tex] (see example for a = 0.6 here; click a few times in white rectangle).

My problem is that I don't like the way "a" hangs in it as free parameter. I need some idea how to calculate it based on real curve data (e.g., [tex]x_i, y_i[/tex]). The objective can be vaguely described as getting curve to look as nice as Catmull-Rom spline does.

Thanks for reading.
 
Mathematics news on Phys.org
  • #2
I've suddenly realized that my pitfall was attempting to solve 2D problem in 1D... so, get ready for another update.
 
  • #3
hey makc,

Just solving p_0'(1)=p_1'(0) puts no constraint on how you want the curve to look. That is, imagine all the possible solutions to that constraint, like fitting a sinusoidal wave through your corner points. Cardinal splines put a constraint on the shape of the curve, namely that the derivative at each corner point must be in the general direction of the curve (p_i+1 - p_i-1).

You can come up with similar constraints for a spline with quadratic segments, although the details are different. With cubic segments, for each segment, you have two free control points and two constraints -- the derivatives are equal to the general direction of the curve. With quadratic segments, for each segment, you have one free control point and two constraints -- the same two. So using just a single quadratic per segment is overconstrained (there isn't a solution that satisfies both constraints) ... you need to introduce more free control points in the segment ...

One approach is to make each segment a sequence of two quadratics, which in total yields three free points per segment. The first and last should be solved using the normal Cardinal spline method. The middle can be c1, by using your original approach. Since the two end points are molded into the general shape using the Cardinal spline method, this floating center point usually comes out nicely for small "alpha" (i.e. tight). When the spline is loose, the floating middle point usually starts to turn into a visible hump.

Anyway, I have an implementation if you care for it. Just send me a note (bubble.up.soda@gmail.com).

Hope that helps.

Brien
 
  • #4
For some reason the links to the pics don't work. Can you post a specific set of x,y values you are trying to fit?
 

FAQ: Quadratic bezier problem

What is a quadratic bezier problem?

A quadratic bezier problem is a mathematical problem that involves finding the curve created by a quadratic bezier function, which is a type of parametric curve used in computer graphics and other applications. It is defined by three points, known as control points, and can be used to create smooth and curved lines.

How do you solve a quadratic bezier problem?

To solve a quadratic bezier problem, you can use the quadratic bezier formula, which involves plugging in the coordinates of the three control points into a mathematical equation. This will give you the x and y coordinates of points along the curve, which can be used to plot the curve or solve for specific points of interest.

What is the purpose of a quadratic bezier problem?

The purpose of a quadratic bezier problem is to create smooth and curved lines that can be used in computer graphics, animation, and other applications. It allows for more complex and natural-looking shapes to be created using just a few control points, making it a useful tool for designers and programmers.

Are there any limitations to quadratic bezier problems?

Yes, quadratic bezier problems have some limitations. They can only create curves that are smooth and continuous, meaning they cannot create sharp corners or angles. Also, they are limited to creating curves in two dimensions, so they cannot be used to create three-dimensional shapes or objects.

How are quadratic bezier problems used in real-world applications?

Quadratic bezier problems have many practical applications in the real world. They are commonly used in computer graphics software to create smooth curves in designs and animations. They are also used in engineering and architecture for designing curved structures and in physics for modeling the motion of objects along curved paths.

Similar threads

Replies
5
Views
6K
Replies
8
Views
4K
Replies
20
Views
2K
Replies
0
Views
959
Replies
1
Views
1K
Back
Top