i need a new constraint that force a point on a body to follow a curve on another body, the so called point to curve constraint.
does any one have experience with this or has any advice on how to extend box2d to support this type of constraint?
How would you specify the curve? Bezier? Hermite? Would the curve intersect itself? Would it loop?
The interpolation might be a B-spline of order >=2, good default might be 4. for example, cubic B-spline is order 4.
It would be nice to allow the curve to loop. But support for intersection is not necessary.
Yeah, I think this would be cool. You could fake it by creating a pair of edge chains that form a curvy channel on one fixture and a circle on another fixture. Then the circle could slide through that channel. Let me know how that goes. If it is not working, we can investigate building a curve API.
To do a curve we need to be able to compute the tangent quickly. Also the tangent must never be zero.
I'll put in a vote in favor of this. It would be really cool to have smooth sliding curved constraints. Mere mortals like me wouldn't be able to figure out the math to get that right!
This is something I'd be really interested in discussing; our home-rolled simulator (now collecting dust for the past couple years) has point-to-curve, with curves defined as chains of linesegments and circular arcs.
This allowed all sorts of interesting stuff, such as covering any object with a conveyor belt -- a proper one where different constraint points on the belt interacted (i.e if you grab a point on a belt and pull, it slides the belt and everything on it).
Anyway, I'd be interested in hearing about your thoughts Erin, because although we got things working, it was one of the ugliest and least clean sections of the simulator.
We use a position-based solver so we didn't have the tangent problem, however the problem of determining the closest point on a curve in general is very annoying. There are ambiguous cases which can cause "jumping" -- analogous to how the penetration depth/MTV jumps from one face to another as a point moves through a solid.
Disallowing self-intersection doesn't really help much, since the problem in general is the existence of two or more equidistant closest-points, which happens even without self-intersection (e.g two nearby parallel segments, or a tightly curved section, can result in multiple closest points).
AFAICR our solution was to track the previous closest point on the curve and use this in a heuristic (i.e we calculated the current closest N points on the curve and then weighed/scaled them according to their distance-along-curve from the previous closest point). This actually helped quite a bit since there are many cases -- when objects are moving quickly or violently -- where the "correct" point on the curve isn't actually the absolute closest.
Could probably build the framework for this to be agnostic to the *type* of spline.
I know I've already expressed my interest, but this would be seriously cool. It's a great step forward in terms of modeling intricately detailed constraints...
I think that true curves using splines may not even be necessary for most use cases though. Simply being able to define a polyline which a joint can slide along, optimizing the "circle-inside-channel" approach and eliminating snagging, would be great.
That'd be a point-to-segment-list constraint.
Couldn't be more relevant! Great work there.