Re: Drawing smooth curve through control points using NSBezierPath
Re: Drawing smooth curve through control points using NSBezierPath
- Subject: Re: Drawing smooth curve through control points using NSBezierPath
- From: Robert Clair <email@hidden>
- Date: Sat, 2 Apr 2005 10:31:40 -0500
<x-tad-bigger> I would like to allow users in a graphics application to draw a smooth curve through a number of control points defined by clicking the mouse in a view.
</x-tad-bigger>
Not sure exactly what you mean by "control points". A cubic Bezier has four control points: one on each end and two interior ones that don't lie on the curve (except in the degenerate case where the curve is a line). I assume what you meant was "How do I fit a curve through some user-defined data points ?"
<x-tad-bigger>I am wondering whether there is any way to do this efficiently (i.e. an
easy way) using NSBezierPath?
</x-tad-bigger>
No. Not directly.
The easiest thing to do is to adapt the code given in the Graphic Gems article:
An Algorithm for Automatically Fitting Digitized Curves
by Philip J. Schneider
from "Graphics Gems", Academic Press, 1990
The code is available on the web - look for fitCurve.c or fit_cubic.c
You can then tweak it to return a NSBezierPath for the output chain of curves.
<x-tad-bigger> This could also be done using splines
</x-tad-bigger>
???? Bezier curves *are* splines.
.......Bob Clair
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden