Page 1 of 1

Arc wall in chipmunk

Posted: Mon Dec 07, 2009 2:10 pm
by jaganys
I am trying to create a static wall, which has the shape of an arc and some thickness, as a poly shape in the chipmunk space that is also shared by some moving circles. I am planning to generate points on the arc and create a segment out of it so that I see some collisions. Here are my questions:
1. Is there an easier way? It’s a shame that I am putting Chimunk thru so much when its really a part of circle that I am interested in. I have seen posts that suggest using collision responses but in my case I will have numerous arcs on the same circle. Also at least 5 to 6 such circles.
2. If anyone already did this poly shape creation can you please share some code? I think I have to generate points for two arcs so that they both make up a wall.

Thanks in advance

Re: Arc wall in chipmunk

Posted: Wed Dec 09, 2009 3:31 am
by Tam Toucan
1. It depends on whether the code to determine if a collision in on a one of the segments is slower than the hit to creating lots of line segments. I'd say test it and see. Also, you could just set the width of the segment rather than use two arcs.

2. You can easily find how to create a list of points for a circle on the web. Here's what I use

Code: Select all

static void makeCircle(const PolyModel::CirclePart* pCircle, MathStuff::PointsList& pnts)
{
	MathStuff::Coord l_coef = (pCircle->getSegmentRatio()*2.0*MY_PI)/(pCircle->getNumSegments());
	MathStuff::Coord l_radius = pCircle->getRadius();
	// Do the segments in reverse so get CW winding
	for (int i=pCircle->getNumSegments()-1; i >= 0; --i)
	{
		MathStuff::Coord l_rads = i * l_coef;
		pnts.push_back( MathStuff::Point(l_radius * cos(l_rads), l_radius * sin(l_rads),  0.0) );
	}
}
something like that mod'ed to do an arc instead of a full circle The 3rd coord in Point is because everything is actually 3D.

Re: Arc wall in chipmunk

Posted: Wed Apr 28, 2010 10:11 pm
by jaganys
Thanks and sorry for the delayed reply. I am actually dividing the arc into segments and using them as boundaries.
Thanks again!