I’m thinking this is due to the iteration direction but then again, why would it be if its all done in one frame anyway?

```
--# Main
function setup()
r = Rope(vec2(50,600),vec2(700,350),40)
touches = {}
end
function touched(t)
if t.state == BEGAN then
table.insert(touches,t)
end
for k,v in pairs(touches) do
if v.id == t.id then
if k == 1 then
r.p1 = vec2(t.x,t.y)
elseif k == 2 then
r.p2 = vec2(t.x,t.y)
end
end
if t.state == ENDED then
table.remove(touches,k)
end
end
end
function draw()
background()
r:draw()
end
--# Rope
Rope = class()
function Rope:init(pos1,pos2,segamnt)
-- you can accept and set parameters here
self.p1 = pos1
self.p2 = pos2
self.m = mesh()
self.r = {}
self.dst = pos1:dist(pos2)
self.segamnt = segamnt
self.seglen = self.dst/segamnt
self.segtbl = {}
for i=1,segamnt do
self.segtbl[i] = {}
self.segtbl[i].pos = pos1+(pos2-pos1):normalize()*self.seglen*i
self.segtbl[i].vel = vec2()
self.segtbl[i].ang = 0
self.r[i] = self.m:addRect(self.segtbl[i].pos.x,self.segtbl[i].pos.y,5,self.seglen)
end
self.i = 0
end
function Rope:draw()
for i=1,self.segamnt do
local maxl = self.seglen
local prevpos = vec2()
local pos = self.segtbl[i].pos
local nextpos = vec2()
if i==1 then
prevpos = self.p1
nextpos = self.segtbl[i+1].pos
elseif i==self.segamnt then
prevpos = self.segtbl[i-1].pos
nextpos = self.p2
else
prevpos = self.segtbl[i-1].pos
nextpos = self.segtbl[i+1].pos
end
pos = self.segtbl[i].pos
local mlen = ((nextpos+prevpos)/2):dist(pos)
if mlen > 0 then
self.segtbl[i].pos = pos + (((nextpos+prevpos)/2)-pos):normalize()*mlen*1.8
end
self.segtbl[i].pos = self.segtbl[i].pos -vec2(0,1)
self.m:setRect(self.r[i],pos.x,pos.y,5,10,angleOfPoint(pos-prevpos)/mp)
end
self.m:draw()
end
function Rope:touched(touch)
-- Codea does not automatically call this method
end
--# SpecFuncs
mp = 180/math.pi
function angleOfPoint( pt )
local ang = math.atan2(pt.y,pt.x)*(180/math.pi)
if ang < 0 then ang = 360+ang elseif ang > 360 then ang = 0+(ang-360) end
return ang
end
```

Physical rope with 2 attached ends, first finger moves left point, second moves right point. The rope seems very static when moved with the first finger but if you use a second finger to move the other point you get the more desired elastic effect, but this is not correct due to its correcting itself backwards instead of forwards. I tried doing two seperate iterations over the table in both directions which gave a static effect on both sides but the second finger point dragged behind. Has anyone dealt with rope yet with good frame rates? If so please give me some advice as I have never tried simulating rope between two points only one. It’s easy to get the desired effects from one end. Thanks!