Using a variant of the Douglas-Peucker algorithm in conjunction with the curve-fitting algorithm by Philip J. Schneider found in Graphics Gems I, Carlos wrote this in Corona SDK using nothing but the Corona framework to draw, reduce points, and convert the resulting polyline into a series of cubic bezier curve segments.

Sample code coming soon! (you can bug Carlos if you want it immediately, though)

  1. Very nice results, Carlos!
    Thanks for this helper function!

    Please publish a companion example too, about how we can use such curves to drive the transition of an object along a path. Thanks in advance!

  2. Wow just the line stuff on it’s own is cool and when you add that your doing this on a mobile device with a easy to use API it’s just sweet! Thanks for sharing now get the code out there for us!:)

  3. need to clean up the code a bit and above all comment the part that really matters. all the other routines, the reparametization, newtonrapsody leas squares, etc. don’t really need to be documented, but the part where you pass in the points, and the err tolerance has to be neatly documented and I also need a way to pass back an array of handles. which right now works, but is not intuitive. the idea would be you pass in an array of points, and it will return you an array (or in lua lingo a table) with the points to the Bezier Curve. after that, you can do what ever you would like with the points. Draw them, or use them to ‘walk’ an object along the t values. I am also looking at implementing at reparametirizing the resulting segment…

  4. Rodney Foley says:

    @Carlos, what is the status of posting this sample code? It has been two and half months, it doesn’t have to be perfect it just needs to work. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>