function [nodes,edges] = discretizePolygon(corners,h)

N = size(corners,2);
corners2 = [corners,corners(:,1)];
lengths = sqrt((corners2(1,2:N+1)-corners2(1,1:N)).^2+(corners2(2,2:N+1)-corners2(2,1:N)).^2);
ns = max(floor(lengths/h),1);

n = sum(ns);
nodes = zeros(2,n);
edges = [1:n;[2:n,1]];

idx0 = 1;
for i=1:N
    idx1 = idx0+ns(i)-1;
    corner0 = corners2(:,i);
    corner1 = corners2(:,i+1);
    t = [0:ns(i)-1]/ns(i);
    nodes(:,idx0:idx1) = [corner0(1)+(corner1(1)-corner0(1))*t;corner0(2)+(corner1(2)-corner0(2))*t];
    idx0 = idx1+1;
end