matlab - Angle calculation in a Delaunay graph -
i have plotted delaunay graph in matlab one:-
i want calculate angles in graph. have x , y values points in disordered form, , don't know how sort points because x , y values close points on same row.
one way that:
x = randn(1,4)*10; y = randn(1,4)*10; %calculate triangulation tri = delaunay(x,y); %plot graph triplot(tri,x,y) hold on plot(x,y,'ro') text(x,y,strsplit(num2str(1:length(x)))) % determine each angle = 1:size(tri,1) per = perms(tri(i,:)); [~, ind] = unique(per(:,2)); %avoid calculate 2 time same angle. per = per(ind,:); %the 3 * 3 points create angle of each triangle j = 1:3 p_1 = per(j,1); p1 = [x(p_1),y(p_1)]; p_2 = per(j,2); p2 = [x(p_2),y(p_2)]; p_3 = per(j,3); p3 = [x(p_3),y(p_3)]; ang = rad2deg(atan2(abs(det([p3-p2;p1-p2])),dot(p3-p2,p1-p2))); %p2 point in middle fprintf('node %d %d %d angle %f\n',p_1, p_2, p_3, ang) end end
Comments
Post a Comment