Cone/angle joints in impulse method
However, the 'chain' demo is extremely unstable and the slightest shake can break it. I'm not sure if its due to lack of proper position projection, or just a bug in my code.
I found the 6-DOF constraint a save way to shoot yourself into the food. I never really implemented it and I use specif joint types (e.g. spherical, prismatic, cylindrical, revolute and rigid) .But I think that is a matter of taste and I don't want to sound religious about that decision.
Either way I recommend starting with a specific joint type. E.g. spherical joint with cone limit and revolute joint with unsymmetrical limits are two good exercises. This is much simpler than starting with a generic type.

You should be able to model a small ragdoll this way. Ragdolls are usually spherical joints with cone limits and revolute joints. Did you look at the angle limits? It should be fairly easy to convert this data. I have done this many times.
It goes along the same way. Assume u is the axis pointing down the joint axis. You would now measure the twist using the orthogonal axes v1, w1, v2, w2. You just need to be careful that your swing limit doesn't exceed 90 degrees as you get problems with projections then. The twist is much more complex than the swing and I use a framework of quaternion constraints for that. I really need to publish this!
I have some sketches for a simple twist constraint following the same approach as described above. Let me look it up when I am home later today.
Assume we have a joint setup like in the picture above for the swing angle and you look along the u-axis. You would see something along the line like this:
Let's call the twist angle between v1 and v2 alpha. From basis trigonometry we get:
sin( alpha ) = dot( v2, w1 )
cos( alpha ) = dot( v2, v1 )
I am a little rusty here, but iirc when frame 2 swings relatively to frame 1 then the dot products are of course not sin and cos of the twist angle anymore, but their ratio is the tan. Therefore:
tan( alpha ) = dot( v2, w1 ) / dot( v2, v1 )
From there we can compute the angle:
alpha = atan( dot( v2, w1 ) / dot( v2, v1 ) ) and dot( v2, v1 ) != 0
In an implementation you would of course use atan2 so you don't need to check for dot( v2, v1 ) =0. From here everything goes like for the swing above:
C = atan( dot( v2, w1 ) / dot( v2, v1 ) )
Build dC/dt and find the Jacobian by inspection. From there you can then enforce MinAlpha < Alpha < MaxAlpha easily.
Maybe try to find the Jacobian yourself and I happily have a look and will definitely help if you get stuck.
Cheers,
-Dirk
Yup the 90 degree cone limit seems to be an issue here. As long as its not exceeded, then projection onto the V1W1 plane does the trick. Is there no way to get it to work with an arbitrary cone limit (or even no limit at all)?
Why do we only consider v2 and not w2? If U1 is not parallel to U2, then projections of v2 and w2 would not form a right angle, so they would yield different twist angles.