Ways to define a curve

1.5k Views Asked by At

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?

2

There are 2 best solutions below

4
On

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
On

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.