There is something fishy with your code. For example what's direction2 in the first snippet? And why you constantly convert from display to sim units. When doing physics you should work with physics units - meters, kilograms, seconds. Convert to display
units only in your draw method. To say it more formally I prefer a general design pattern that does not push the physics to the scenegraph but pulls the physics whenever necessary from inside the graphics routines. Basically run your physics independently
and let the draw method pull the coordinates from the physics objects and convert them (with ConvertUnits or even automagically through a carefully set up projection matrices). You are more or less doing this but it's somewhat confusing. For example why do
your physics need to know about the diplay units?
Sorry for digressing, I'll try to be more helpful. A revolute joint (aka pin joint) pins two bodies together at a common anchor so they can rotate but not translate relative to each other. It's perhaps easier to visualize it like this. Note that the first
thing the engine does is bring the bodies together so they share the anchor so the constraint is satisfied (no relative translation at the anchor). That means if the anchor is not set properly the simulation will explode and that's especially true with many
constraints that suddenly can't be satisfied. This is probably what you are seeing.
Basically you can do this (vertical rope):
rectangle1=PolygonTools.CreateRectangle(half-width, half-height). (note that PolygonTools uses half lenghts which is perhaps somewhat counter-intuitive)
Vector2 anchor1=new Vector2(x1,y1) where x,y is a point in the *local* coordinates of the rectangle1. For example the center of the *lower* half like in your second snippet. E.g. if the rectangle is 1 mx1m (PolygonTools.CreateRectangle(0.5,0.5))
it's center in local coordinates is 0,0 and vertices are (-0.5,-0.5) (0.5,-0.5) (0.5,0.5) (0.5,0.5)
Vector2 anchor2=new Vector2(x2,y2) where x,y is a point in the *local* coordinates of the rectangle2. For example the center of the *upper* half.
Note the use of a local coordinate system for anchors.
This will make a joint where the upper body's bottom slighly overlaps the lower body's top. By adjusting the overlap you can make the thing more or less stiff. You can even try negative overlap. I also like making two seperate revolute joints on the two
upper/lower corners. I.e. use quadrants instead of halves. Makes the "chain" pretty cool and with different properties than just using one joint (more elastic-like with joint limits and motors).
P.S: there is also a rope joint (in the spirit of a chain of distance joints) that might be of use. It's more like real rope whereas a chain of revolute joints is more like a metal chain or rather a long thin rod.