Forcing an object to move along a b2EdgeChain

Is there a way to basically fix an object's movement so that it's always moving along the surface of a b2EdgeChain? Like if you had something such as:

====\

(awesome art, I know) where the slash is an inclined plane (45 degrees in this case). The idea is if the object was moving rightward, instead of flying off at the end of the horizontal stretch it'd just keep moving at the same X rate and its Y position would be such that its base is always making contact with the edge chain, and never parting from it to go into the air. Essentially the edge chain is acting like a rail. Is this doable?
I think I found the answer...this appears to work. Does this seem reasonable:

Code:
<update world>

If object is on an edge chain:
{
   objectx = Is object moving left ? object.x <otherwise:> object.x + object.width

   iterate over all points on the edge chain:
   {
      if ((objectx >= point1.x) && (objectx <= point2.x))
      {
         slope = (point2.y - point1.y) / (point2.x - point1.x)      
         dx = objectx - point1.x
         edge_y = point1.y + slope*dx
         bottom_object_y = object.y + object.height
         
         // time_step in this case is 1/50
         force = (object.mass * time_step) * (edge_y - bottom_object_y)
         object.SetLinearVelocity(object.GetLinearVelocity().x, object.GetLinearVelocity().y + force)
         exit loop
      }
   }
}


It does appear to work. I do notice though that if I'm going UP the slope of an inclined plane, and if the segment that it's attached to is at a smaller angle than the plane I was just riding up, that I can sometimes fly off of it a little bit. So perhaps I'm not quite calculating the amount of force I need to apply correctly? It does at least seem to be going in the right direction...
The amount of force required to keep an object on an edge chain is technically infinite right at the angle point, so you're never going to get an exact solution by setting a force.

It looks like you're basically applying some sort of spring force (though you're doing it by setting the velocity) to pull the object towards the edge chain; that will work as long as you're happy with the results. You can play with the strength of that force by multiplying "force" by a constant, and probably tune things the way you want them.

Is this for a character, or is it for something that always has to be on the platform?
It's for a character, but the more I play around with it, the more I realise it's actually kind of a nice effect. You don't really launch much at all, and when traveling quickly it gives a nice feel. So I think I'll just leave it as is, or tune it a little bit if I really need to.

Original thread: https://box2d.org/forum/viewtopic.php?t=3112