%Part of these codes are reference to the ME574 2009 project "Particle Evolution
%Under Surface Diffusion and Migration" in University of Michigan

function [x, y, J, J_m] = me574_plotshape(nodes, initial_shape, x_coord, y_coord,radius)

if initial_shape == 1
    for i = 1:nodes
        [x(i,1), y(i,1)]=ginput(1);
        line(x(:,1),y(:,1))
    end
else
    angle = 2*pi()/nodes;

    for i=1:nodes
        x(i) = radius*cos(angle*(i-1))+x_coord;
        y(i) = radius*sin(angle*(i-1))+y_coord;
    end
end

x(nodes+1) = x(1);
y(nodes+1) = y(1);
line(x,y)
pause(2)
J = zeros(1,nodes+1);
J_m = zeros(1,nodes+1);