Rope Joint - custom joint with applyForce. Is the equation missing something?

I thought I nailed this but I’m seeing some jitters when swinging the box around the anchor. Any Codea mathematicians able to tell me what I’m missing? I think it might be how I’m using dot product but I’m no expert so it’s over my head apart from trial and error.

http://pastebin.com/fUhnnBaB

To find it quickly just search ‘equation’ in the editor.

@Luatee I tried your code and had the crate bouncing around the rope and didn’t see any jitters in the crate movement. I kept it moving around for a couple of minutes. I’m on an iPad Air running the latest Codea beta.

@dave1707 does it behave like a rope joint for you?

I noticed some slight jittering in the example. I’m also on an iPad Air, but I’m using Codea 2.3 (from the App Store). Maybe it’s something fixed in the beta?

Edit: I updated to the beta, and I got a tiny, barely noticeable amount of jittering one time, and I wasn’t able to reproduce it. Might have been fixed.

@Luatee The rope looks like lengths of stiff rope connected together. Guess it acts more like a chain with long links.

Well it’s verlet so a series of points and lines
Edit: forgot to mention this is s very simple version of verlet and can’t really be used for much else.

@Luatee Here’s code that I have for a piece of rope.

EDIT: Sorry, forgot the joint table so I added it.


supportedOrientations(PORTRAIT_ANY)
displayMode(FULLSCREEN)

function setup()
    tab={}
    j={}
    dist=5
    for z=1,100 do
        b1=physics.body(CIRCLE,1)
        b1.x=WIDTH/2+z*dist
        b1.y=900
        table.insert(tab,b1)
        b1=nil
    end  
    tab[1].type=STATIC
    for z=2,#tab do   
        j1=physics.joint(ROPE,tab[z-1],tab[z],
            vec2(tab[z-1].x,tab[z-1].y),vec2(tab[z].x,tab[z].y),dist)
        table.insert(j,j1)
        j1=nil
    end
end

function draw()
    background(0)
    stroke(255)
    strokeWidth(2)
    for z=2,#tab do
        line(tab[z-1].x,tab[z-1].y,tab[z].x,tab[z].y)
    end
end

@Luatee The only problem with my code above is if the rope is really long, it stretches and shrinks. I haven’t found a way to stop that.

@dave1707 I think using box2D would count as a semi-implicit Euler equation for the rope leading to a bit of instability (stretching) but this is in unavoidable in pretty much all (Euler,verlet,k1?)