you can also use the exact analytic solution of the problem:
y(x) = c3 + 1 / c1 * cosh( c1 * x + c2)
where the parameters c1, c2 and c3 are found using the rope length constraint:
L = \int\sqrt{1+y'(x)}dx
and its endpoints:
y(x1)=y1
y(x2)=y2
assuming x1=0 and y1=0, then c3=-1/c1*cosh(c2) and we ends up with the following two equations:
y2 = 1 / c1 * ( - cosh( c2 ) + cosh( c1 * x2 + x2 ) )
L = 1 / c1 * ( - sinh( c2 ) + sinh( c1 * x2 + x2 ) )
which can be solved numerically for c1 and c2 (in matlab or octave):
m-file for solving the equations set, called rope.m:
Code: ags
running the solver
Code: ags
now a lookup table can be calculated for all the desired x2, y2 and L values. for example:
x2 = 1.00, y2 = 1.00, L = 1.50 | c1 = 1.65, c2 = -0.022565
x2 = 1.00, y2 = 1.00, L = 2.00 | c1 = 3.83, c2 = -1.364008
x2 = 1.00, y2 = 1.00, L = 2.50 | c1 = 4.82, c2 = -1.986330
x2 = 1.00, y2 = 1.00, L = 3.00 | c1 = 5.50, c2 = -2.401198
x2 = 1.00, y2 = 1.00, L = 3.50 | c1 = 6.01, c2 = -2.712692
x2 = 1.00, y2 = 1.00, L = 4.00 | c1 = 6.43, c2 = -2.961918
x2 = 1.00, y2 = 1.00, L = 4.50 | c1 = 6.79, c2 = -3.169477
x2 = 1.00, y2 = 1.00, L = 5.00 | c1 = 7.10, c2 = -3.347194
plotting y(x) = - 1 / c1 * cosh( c2 ) + 1 / c1 * cosh( c1 * x + c2 ):

y(x) = c3 + 1 / c1 * cosh( c1 * x + c2)
where the parameters c1, c2 and c3 are found using the rope length constraint:
L = \int\sqrt{1+y'(x)}dx
and its endpoints:
y(x1)=y1
y(x2)=y2
assuming x1=0 and y1=0, then c3=-1/c1*cosh(c2) and we ends up with the following two equations:
y2 = 1 / c1 * ( - cosh( c2 ) + cosh( c1 * x2 + x2 ) )
L = 1 / c1 * ( - sinh( c2 ) + sinh( c1 * x2 + x2 ) )
which can be solved numerically for c1 and c2 (in matlab or octave):
m-file for solving the equations set, called rope.m:
function f=rope(c,x2,y2,L)
f(1) = L + 1 / c(1) * ( - sinh( x2 * c(1) + c(2) ) + sinh( c(2) ) );
f(2) = y2 + 1 / c(1) * ( - cosh( x2 * c(1) + c(2) ) + cosh( c(2) ) );
running the solver
% boundary and length
x2 = 1; y2 = 1; L = 5;
% initial guess
c0 = [1; 1];
% solver
c = fsolve(@(x) rope(x, x2, y2, L),c0)
now a lookup table can be calculated for all the desired x2, y2 and L values. for example:
x2 = 1.00, y2 = 1.00, L = 1.50 | c1 = 1.65, c2 = -0.022565
x2 = 1.00, y2 = 1.00, L = 2.00 | c1 = 3.83, c2 = -1.364008
x2 = 1.00, y2 = 1.00, L = 2.50 | c1 = 4.82, c2 = -1.986330
x2 = 1.00, y2 = 1.00, L = 3.00 | c1 = 5.50, c2 = -2.401198
x2 = 1.00, y2 = 1.00, L = 3.50 | c1 = 6.01, c2 = -2.712692
x2 = 1.00, y2 = 1.00, L = 4.00 | c1 = 6.43, c2 = -2.961918
x2 = 1.00, y2 = 1.00, L = 4.50 | c1 = 6.79, c2 = -3.169477
x2 = 1.00, y2 = 1.00, L = 5.00 | c1 = 7.10, c2 = -3.347194
plotting y(x) = - 1 / c1 * cosh( c2 ) + 1 / c1 * cosh( c1 * x + c2 ):
