문제

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?

도움이 되었습니까?

해결책

Like your tag says, you are describing Bezier curves. It is mathematically well defined, so you'd be able to use that for collision detection, although depending on what you're doing it might make the equations slightly harder to write and solve. I don't know much about it, but something that seems to be the standard way to approach splines is NURBS, and wikipedia seems to have quite an article on the topic. The NURBS article probably covers all this, but a quick and dirty way to draw a smooth curve between a bunch of points is to use cubic splines by interpolating a cubic polynomial in between every two points such that the first derivatives match at the edges. That way you get a curve that goes through all your points and looks smooth everywhere, with no sharp corners at the initial points.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top