Corona SDK Tutorial: Polygon point reduction with curve-fitting

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0

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)

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0

This entry has 9 replies

  1. Magenda says:

    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 says:

    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. salim madjd says:

    Great stuff, carlos! Can’t wait to see the sample codes, etc.

  4. Carlos Icaza says:

    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…

  5. Carlos Icaza says:
  6. 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. 🙂

  7. Carlos Icaza says:


    Point reduction is at

    Curvefitting is being added as part of the framework. That’s why it is taken longer. The C++ code shows a discernible performance increase.

    • @Carlos
      Any news about the curve-fitting part?

  8. Quang Le says:

    Guys, if you want the source code … check this
    Hope this helps! 🙂