Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to give shapes in my physics engine roundness/ curvature.

I am aware of various methods for mathematically defining curves; such as bezier-cruves, ellipses, etc. However I am not sure which methods would be most appropriate for use in my physics engine, because speed, feasibility of construction, and flexibility of each method must be considered. I want a system in which a user can easily form fairly complex curves, but still make the intersection calculations simple and fast.

My physics engine is also purely continuous, which means I must be able to calculate the time in which curves will collide with other curves and lines based on a constant linear/angular velocity.

  • What techniques are there for mathematically defining a 2D curve?

  • What are the advantages/disatvantages of each in terms of speed, flexibility, and simplicity of construction?

  • Is the technique feasible for an engine where predictability of shape intersection is crucial?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

The curves you describe looks like the Bézier curves.

Usually simpler shapes are used to simulate curves. It is without any doubt possible to test collision with a Bézier curve, but I don't know whether it is more efficient or not than converting it to a set of primitives (lines, rectangles, circles...).

I think it worth testing collisions using the both to see which one is the more efficient.

And even if the simple shapes are faster to test collision with, than using the Bézier curves equation directly, you could still use it in your game editor to create what you need and feel like with Adobe photoshop and convert the curves in a simpler shape set when exporting the level.

As for the circles; they are often used in collision detection system because the are straightforward to test collision with (distance from center, that's all you need).

share|improve this answer
    
Agreed; I'd think that for "continuous" collision detection (more complicated than just intersection testing) you'd be especially concerned with keeping the shapes as simple as possible...and Bézier splines (or any kind of spline) are definitely not simple. –  Nathan Reed Dec 3 '11 at 7:47
    
@NathanReed Do you know of any other methods to form curved edges on a polygon that would make it easier to pre-detect collisions? –  Griffin Dec 7 '11 at 7:07
add comment

If your physics engine works solely in terms of straight line segments and circles then the collision detection is as straightforward as you can possibly make it.

The standard technique for rendering Bézier curves is to use de Casteljau's algorithm to reduce them to a series of straight lines (bounding the error, aka distance from the original curve, to e.g. 0.5 pixels).

Put the two together and you have a tried and tested approach which allows you to define curves, is familiar to anyone who's ever worked with paths in Photoshop or the GIMP, and can then be transformed into a suitable structure for collision detection.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.