Posted on by

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)

Posted by . Thanks for reading...

8 Responses to “Corona SDK Tutorial: Polygon point reduction with curve-fitting”

  1. Magenda

    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. Bob

    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. Carlos Icaza

    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

    @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

  • (Will Not Be Published)