3
$\begingroup$

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

I am aware of various methods for mathematically defining curvature such as bezier-curves, ellipses, etc; but I'm not sure which methods are most appropriate for use in a physics engine. I must consider the speed, flexibility, and difficulty of constructing/joining the curves when choosing my approach. The ideal is a system where a user could easily construct and collide a large amount of curved, aesthetic polygon bodies together, yet I could still maintain a satisfactory framerate. However it's inevitable that ease-of-use and other attributes will suffer.

NOTE: my physics engine is continuous, which means I must pre-calculate the times at which polygons will collide. Keep in mind that the curve's route my not be linear.


For each suggestion please give the positives/negatives!

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

  • Advantages/Disadvantages (speed, flexibility, ease of construction/use)?

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

  • 0
    @JayeshBadwaik Yes, they are2012-08-17

2 Answers 2

3

TL;DR If you want to specify a curve for computation in a computer system, use actual points rather than equations. It will be better anytime. And for analysis, use piecewise linear (polygonal) models.

NOW THE LONGER PART

Stick with piecewise linear as far as possible. Why? Absolutely simple to construct, good speed, large flexibility. Accuracy can be easily improved using a higher resolution.

Your ease of use seems to be a problem. The solution to that will be to make an interface so that user has to specify only the points of the boundary of the body with a sufficient accuracy. He can use whatever methods he wants to do so. Once that is done, you can take those points and design whatever curves you want from it. As in this case, you can see, piecewise linear is quiet simpler than other curves and also, it imposes least restriction on the user.

There are many other advantages of piecewise linear. You can use mesh libraries to construct a matrix based description of your system, and then use it predict crashes. Once the crash has occured, if your bodies are not getting deformed, great, you can just reuse the descriptions but with a little change in the equations.

  • 0
    Of course you can construct the curves with any method, and then approximate them as piecewise linear curves in the desired accuracy. That way you can produce the curves with whatever method is appropriate for the user interface, while still having the simplicity and speed of piecewise linear curves during the calculation.2012-08-17
-1

If you can get your functions in the form of:

f(t)=... and

g(t) =...

and you want the intersection, all you have to do is use Desmos Graphs

You could also do something like f(t)-g(t) = 0 and the graph of the result will show the intersection as well.

After the graph is displayed, you can place the mouse on the graph to show the point of interest. It helps when you color the graphs.

Example

  • 1
    I am not an expert in C++ but you could check these: http://en.wikipedia.org/wiki/NAG_Numerical_Libraries and http://en.wikipedia.org/wiki/List_of_numerical_libraries also, MATLAB can be called from C++ to the best of my knowledge. I hope this answers your questions.2011-12-15