% function newModelData = midVeinRibModel(oldPts,connectedPts)
% %%Obsolete function
% 
% debugPlot = 0
% 
% %% reshape the data into a useful format
% data = reshape(oldPts,3,size(oldPts,1)/3)';
% 
% if(debugPlot)
%     plot3(data(:,1),data(:,2),data(:,3),'rx');
%     for j = 1:size(data,1)
%         text(data(j,1),data(j,2),data(j,3),num2str(j))
%     end
%     axis equal
% end
% %% calculate the midvein distances
% midVeinIdxs = connectedPts;
% for i = 1:size(connectedPts,1)-1
%     midVeinDistances(i,:) = sqrt(sum(abs(data(midVeinIdxs(i),:) - data(midVeinIdxs(i+1),:)).^2));
% end
% 
% for i = 1:size(midVeinIdxs,1)-1
%     if(i == 1)
%         firstPtFlag = 1;
%     else
%         firstPtFlag = 0;
%     end
%     %find the pts
%     a = data(midVeinIdxs(i),:);
%     c = data(midVeinIdxs(i+1),:);
%     if(~firstPtFlag)
%         d = data(midVeinIdxs(i-1),:);
%     else
%         d = data(midVeinIdxs(end));
%     end
%     %move vectors to origin
%     a = a-a;
%     c = c-a;
%     d = d-a;
%     
%     abAngles(i) = 180 - (acos(dot(c,d)/(norm(c)*norm(d)))*180/pi);
%     %abAngles(i) = acos(dot(c,d)/(norm(c)*norm(d)))*180/pi;
% end
% 
% figure;hold on
% for i = 1:size(midVeinDistances,1)-1
%     if(i == 1)
%         newModelData(1,:) = [0 0];
%     elseif(i == 2)
%         newModelData(2,:) = newModelData(1,:) - [midVeinDistances(1) 0];
%     elseif(i == 3)
%         if(abAngles(i) < 90)
%             x1 = newModelData(i-1,1) - cos(pi -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%             y1 = newModelData(i-1,2) - sin(pi -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%         else
%             x1 = newModelData(i-1,2) - cos((pi/2) -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%             y1 = newModelData(i-1,1) - sin((pi/2) -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%         end
%         newModelData(i,:) = [x1 - newModelData(i-1,1),y1 - newModelData(i-1,2)];
%     else
%         if(abAngles(i) < 90)
%             x1 = newModelData(i-1,1) - cos(pi -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%             y1 = newModelData(i-1,2) - sin(pi -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%         else
%             x1 = newModelData(i-1,2) - cos((pi/2) -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%             y1 = newModelData(i-1,1) - sin((pi/2) -(abAngles(i) * (pi/180))) * midVeinDistances(i);
%         end
%         newModelData(i,:) = [x1,y1];
%     end
%     plot(newModelData(i,1),newModelData(i,2),'ob')
% end
% figure; plot(newModelData(:,1),newModelData(:,2),'ob')
% hold on
% for j = 1:size(newModelData,1)
%     text(newModelData(j,1),newModelData(j,2),num2str(j))
% end
% 
% 
% end