Creating curved boundaries/lines
Posted: Wed May 06, 2009 2:10 pm
Hi all,
I would think someone would have asked this by now, but I couldn't find anything in a search. Apologies if I missed something.
What is the best method for creating a curved boundary? I've attached an image illustrating some red balls in the type of space I am trying to create.
I am currently using the following code to create 4 static walls, but don't see an easy way to define a curved line.
// bottom
shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(wins.width,0), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// top
shape = cpSegmentShapeNew(staticBody, cpv(0,wins.height), cpv(wins.width,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// left
shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(0,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// right
shape = cpSegmentShapeNew(staticBody, cpv(wins.width,0), cpv(wins.width,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
Do I just have to make lots of lines to approximate the curves? Can I create a polygon?
-Andrew
I would think someone would have asked this by now, but I couldn't find anything in a search. Apologies if I missed something.
What is the best method for creating a curved boundary? I've attached an image illustrating some red balls in the type of space I am trying to create.
I am currently using the following code to create 4 static walls, but don't see an easy way to define a curved line.
// bottom
shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(wins.width,0), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// top
shape = cpSegmentShapeNew(staticBody, cpv(0,wins.height), cpv(wins.width,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// left
shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(0,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// right
shape = cpSegmentShapeNew(staticBody, cpv(wins.width,0), cpv(wins.width,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
Do I just have to make lots of lines to approximate the curves? Can I create a polygon?
-Andrew