function F = PTO_tether(body1,bodies,n,name,p_a1,p_a2,Spring_Force_Coeffs,nozzle_diam)

j = 0;
for i = 1:length(bodies)
name2 = get(bodies{i},'name');
  if(strcmp(name2,name))
    j = i;
  end
end
if(j == 0)
   error('ERROR: Can not find name match in Hydraulic_tether');
end

body2 = bodies{j};

%disp(['Computing Forces on ',get(body1,'name'),' due to ',get(body2,'name')]);

sv1 = get(body1,'sv');
sv2 = get(body2,'sv');

xo1 = get(body1,'x0');
xo2 = get(body2,'x0');
pos1 = sv1(1:6);
vel1 = sv1(7:12);
pos2 = sv2(1:6);
vel2 = sv2(7:12);

[Elongation,ElongationRate,s] = TetherElongations(xo1,pos1,vel1,p_a1,xo2,pos2,vel2,p_a2);

F = zeros(1,6);

if(Elongation > 0)  %If ram is fully retracted, tether is slack and no force is exerted.
  SpringTension = ppval(Spring_Force_Coeffs,Elongation);
  F(1) = SpringTension*s(1);
  F(3) = SpringTension*s(3);
  
%Replace this line with the PTO algorithm:  DampingTension = ppval(Damping_Force_Coeffs,ElongationRate);
  DampingTension = PTO_algo(ElongationRate,nozzle_diam,...);

  F(1) = F(1) + DampingTension*s(1);
  F(3) = F(3) + DampingTension*s(3);
end

R = eye(3);
R(1,1) = cos(pos1(5)); R(1,3) = sin(pos1(5));
R(3,1) = -R(1,3);  R(3,3) = R(1,1);
p_size = size(p_a1);
if(p_size(2) > p_size(1)) 
    p_a1 = p_a1'; 
end
M  = cross(R*p_a1,F(1:3));
F(5) = M(2);

end



