Tony Polinelli
Tarwin Stroh-Spijer

contact [at]

6/25 Easey Street
Collingwood, 3066
Vic, Australia

+61 3 8060 5321

Making Convex Polygons from Concave Ones: Ear Clipping

We’ve recently been playing around with a physics engines in Flash, including a little romance with Glaze, a slight flirting with PhysaXe and now seeming to settle for Box2D … (the dependable old dog)

All these engines work only with convex polygons, and in no way support concave polygons. They do however support more than one shape (or polygon) in each of their rigid bodies. This gives us the change to fake concave shapes by making multiple convex ones. But how do we convert from concave to convex?

I did a bit of a search around and heard about such things as Ear Clipping and Minimum Convex Decomposition. The second I could even find code for ( which was awesome, and in Java none the less. But alas, even with the help of this awesome Java to AS3 converter, I failed at getting it to work.

Then I stumbled upon a great post on the Box2D forumsConcave Polygon Decomposition in Flash“. Someone had converted an Ear Clipping example in Processsing to a JSFL tool. Sweet!

So between the two example I managed to cobble together some not too shabby AS3 classes, and an example app. I’m hoping to add this to our Box2D wrapper (more on that later) so we can easily draw concave polygons ASAP.

Have fun!

Tags: , , , ,


  1. And NOW I found it… after having done it all by myself :)

  2. [...] was already a nice port here : unfortunately, first I found it too late, second I was not clever enough to understand clearly what [...]

  3. [...] évidemment, il y a déja des gens qui l’ont porté: mais je suis juste trop con et j’ai pas compris. donc j’ai repris à la base en [...]

  4. I read your blog for a long time and should tell you that your posts are always valuable to readers.

  5. [...] som digging I found this post at Touch My Pixel’s blog, featuring a few awsome AS3 classes for doing this trick. After [...]

  6. So happy to have found this! Excellent work!

  7. veryyyyyyyyyyyyyy



Leave a Reply

Our Friends:

Powered by haXe / poko cms | Copyright 2008-09 TouchMyPixel