- #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.
[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.