Qt-interest Archive, December 2006
Bezier control points to draw curve through data points?
Message 1 in thread
Hi,
I'd like to plot a smooth curve through some data points, and its
seems that the right tool for the job is QPainterPath::cubicTo(), but
I don't know how I should specify the Bezier control points to achieve
this.
Can anyone tell me what I need to do, or point me to a Qt example that
does this (draws a curve that passed though a given set of points)?
Thanks,
Ben
--
[ signature omitted ]
Message 2 in thread
Ben Bridgwater wrote:
> Hi,
> I'd like to plot a smooth curve through some data points, and its
> seems that the right tool for the job is QPainterPath::cubicTo(), but
> I don't know how I should specify the Bezier control points to achieve
> this.
>
> Can anyone tell me what I need to do, or point me to a Qt example that
> does this (draws a curve that passed though a given set of points)?
>
> Thanks,
> Ben
That requires some linear algebra and knowledge of internal workings of
Bezier curves. You'll have to set up a linear system (Ax=b), where A is
composed in some fashion from the Bernstein basis functions, b is
something derived from the interpolation points (and probably endpoint
tangent vectors), and x are the unknown coefficients. Then, invert A,
multiply by b, and you get x -- your control points.
This is not trivial. If Qt doesn't provide this functionality, you'll
have to either find a library that will do this for you, or get a book
on NURBS and figure it out on your own.
I suspect you'll probably not want to use Bezier in the end, especially
if the number of points you have to interpolate is greater than 4,
you'll want a cubic BSpline.
Paul.
--
[ signature omitted ]
Message 3 in thread
Paul Koshevoy wrote:
> I suspect you'll probably not want to use Bezier in the end, especially
> if the number of points you have to interpolate is greater than 4,
> you'll want a cubic BSpline.
Maybe http://qwt.sourceforge.net/class_qwt_spline.html helps.
Uwe
--
[ signature omitted ]
Message 4 in thread
Thanks very much to everyone for all the great advice - I think you've
covered the whole gamut there!
Uwe, thanks especially - your libary seems to be exactly what I need!
I've downloaded it, and will give it a try.
Ben
On 12/5/06, Uwe Rathmann <Uwe.Rathmann@xxxxxxxxxxx> wrote:
> Paul Koshevoy wrote:
>
> > I suspect you'll probably not want to use Bezier in the end, especially
> > if the number of points you have to interpolate is greater than 4,
> > you'll want a cubic BSpline.
>
> Maybe http://qwt.sourceforge.net/class_qwt_spline.html helps.
>
> Uwe
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]
Message 5 in thread
Normal bezier splines don't pass through the points specified, rather
it approximates those points into a curve. If you need it to pass
through the specific points there are other versions of splines that do
so, like I believe Cardinal splines, Catmull-Rom splines, and
Kochanek-Bartels splines (check em out on wikipedia).
-----Original Message-----
From: Ben Bridgwater [mailto:bbridgwater@xxxxxxxxx]
Sent: Tuesday, December 05, 2006 8:58 AM
To: qt-interest
Subject: Bezier control points to draw curve through data points?
Hi,
I'd like to plot a smooth curve through some data points, and its seems
that the right tool for the job is QPainterPath::cubicTo(), but I don't
know how I should specify the Bezier control points to achieve this.
Can anyone tell me what I need to do, or point me to a Qt example that
does this (draws a curve that passed though a given set of points)?
Thanks,
Ben
--
[ signature omitted ]
Message 6 in thread
Simon, Cheryl wrote:
> Normal bezier splines don't pass through the points specified, rather
> it approximates those points into a curve. If you need it to pass
> through the specific points there are other versions of splines that do
> so, like I believe Cardinal splines, Catmull-Rom splines, and
> Kochanek-Bartels splines (check em out on wikipedia).
>
>
You can solve for the control points so that the Bezier curve would pass
through a given set of points. The difficulty with Bezier curves is that
their degree is tied directly to the number of control points, unless of
course you go to a piecewise continuous curve composed out of several
Bezier curve segments. However, if a piecewise continuous curve ever
becomes a consideration, you might as well go for a BSpline curve.
Paul.
--
[ signature omitted ]