Page 1 of 1

How can I build a ellipse shape by Chipmunk?

Posted: Thu Feb 24, 2011 8:13 am
I am new to Chipmunk

Re: How can I build a ellipse shape by Chipmunk?

Posted: Mon Mar 21, 2011 4:14 am
Approximate it with segments

Re: How can I build a ellipse shape by Chipmunk?

Posted: Sat Mar 26, 2011 8:21 pm
Would it be better to use a polygon instead of line segments? What are the pros and cons?

Re: How can I build a ellipse shape by Chipmunk?

Posted: Sun Mar 27, 2011 4:24 pm
If the ellipse is static, line segments will probably be more efficient and allow you to make a smother shape. Because line segments don't collide with other line segments, it's better to make an ellipse using a polygon if you want it to be active.

Re: How can I build a ellipse shape by Chipmunk?

Posted: Fri Jan 17, 2014 3:50 pm
Sorry to up such an old topic, but i couldn't find it anywhere.
Will ellipses be supported by chipmunk's further versions?
I'm tempted to try to add it, however i've got absolutely no idea about its complexity.
Is it worth to give it a try?

Thanks

Re: How can I build a ellipse shape by Chipmunk?

Posted: Thu Jan 23, 2014 8:58 pm
I think line segment or polygon approximation is still your best bet unless you're constructing a really large number of them. You can also do beveled line segments with semi-circular endcaps (just define a line segment with a radius > 0).

If your shapes are small or fast moving the approximation shouldn't really be noticeable. I'd suggest trying it out at least before you plow forward with what could be quite a lot of work.

FYI segment-to-segment collisions are now detectable (I believe by default). If you use them, you may also want to call cpSegmentShapeSetNeighbors to ignore collisions in the "cracks" between segments.

Re: How can I build a ellipse shape by Chipmunk?

Posted: Fri Jan 31, 2014 3:07 pm
Analytic collisions between ellipses isn't so bad, but colliding them with other shapes gets more tricky. AFAIK, there isn't a good way to do a collision between an elipse and a polygon without doing it approximately. The new GJK based collision code could handle that ok with a bunch of tweaks, but it would still probably be almost as slow as using a polygon shape. All you would be saving is memory since the shape would be sampled as needed. It would add a lot of extra complexity though, which is why I've never been keen on implementing it.

The next best thing then is just to make a rough polygon approximation of it (6-10 verts is probably good) and use the beveling radius to smooth out the vertexes. You'll be able to get pretty close really.