function demo() % demo of function splitEdges.m % % input of splitEdges.m % edges - N-by-4 array, storing N line segments. % Each line segment (edges(i,:)) is given by coordinates % of two points : [x1 y1 x2 y2]. % % Written by Jiexian Ma at SUNY Binghamton (mjx0799@gmail.com) % edges = [ 0 0 3.5 0; 2 0 3 0; 1 2 1 -1; 1 2 3 -1 ]; new_edges = splitEdges( edges ); figure; drawEdge( edges, 'linewidth', 3 ); axis equal title( ['Number of edges = ', num2str( size(edges,1) ) ]) figure; drawEdge( new_edges, 'linewidth', 3 ); axis equal title( ['Number of edges = ', num2str( size(new_edges,1) ) ]) drawnow; set(figure(1),'units','normalized', ... 'position',[.05,.35,.30,.35]); set(figure(2),'units','normalized', ... 'position',[.35,.35,.30,.35]); end