% draws an instance of an eigen model according to the given scaling parameters

function draweigenmodel(meanvertex,modeldev,weights,scale,tr,tc)

  % get model
  [X,N2] = size(meanvertex);
  offset = sum(modeldev .* (weights'*ones(1,N2)));
  model = meanvertex + scale*offset;
  N = N2/2;
  vertices = reshape(model,N,2);
  
  plot(tr*ones(N,1)+vertices(:,1),tc*ones(N,1)+vertices(:,2),'b-')
  plot([tr+vertices(N,1),tr+vertices(1,1)],[tc+vertices(N,2),tc+vertices(1,2)],'b-')
